Skip to content

Commit

Permalink
Create version file and use it for Rakefile, instead of parsing with …
Browse files Browse the repository at this point in the history
…regexp
  • Loading branch information
davispuh committed May 28, 2014
1 parent cd739fd commit 61570de
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 16 deletions.
24 changes: 13 additions & 11 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
require 'date'
$:.unshift File.expand_path('../lib', __FILE__)
require 'chronic/version'

def version
contents = File.read File.expand_path('../lib/chronic.rb', __FILE__)
contents[/VERSION = "([^"]+)"/, 1]
Chronic::VERSION
end

def do_test
require 'chronic'
$:.unshift './test'
Dir.glob('test/test_*.rb').each { |t| require File.basename(t) }
end
Expand All @@ -21,14 +22,15 @@ def open_command
end
end

desc 'Run tests'
task :test do
do_test
end

desc "Generate SimpleCov test coverage and open in your browser"
desc 'Generate SimpleCov test coverage and open in your browser'
task :coverage do
require 'simplecov'
FileUtils.rm_rf("./coverage")
FileUtils.rm_rf('./coverage')
SimpleCov.command_name 'Unit Tests'
SimpleCov.at_exit do
SimpleCov.result.format!
Expand All @@ -38,9 +40,9 @@ task :coverage do
do_test
end

desc "Open an irb session preloaded with this library"
desc 'Open an irb session preloaded with this library'
task :console do
sh "irb -Ilib -rchronic"
sh 'irb -Ilib -rchronic'
end

desc "Release Chronic version #{version}"
Expand All @@ -56,11 +58,11 @@ task :release => :build do
sh "gem push pkg/chronic-#{version}.gem"
end

desc "Build a gem from the gemspec"
desc 'Build a gem from the gemspec'
task :build do
FileUtils.mkdir_p "pkg"
sh "gem build chronic.gemspec"
FileUtils.mkdir_p 'pkg'
sh 'gem build chronic.gemspec'
FileUtils.mv("./chronic-#{version}.gem", "pkg")
end

task :default => :test
task :default => :test
8 changes: 4 additions & 4 deletions chronic.gemspec
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
$:.unshift File.expand_path('../lib', __FILE__)
require 'chronic'
require 'chronic/version'

Gem::Specification.new do |s|
s.name = 'chronic'
Expand All @@ -18,8 +18,8 @@ Gem::Specification.new do |s|

s.add_runtime_dependency 'numerizer', '~> 0.2'

s.add_development_dependency 'rake'
s.add_development_dependency 'simplecov'
s.add_development_dependency 'rake', '~> 10'
s.add_development_dependency 'simplecov', '~> 0'
s.add_development_dependency 'minitest', '~> 5.0'
s.add_development_dependency 'activesupport'
s.add_development_dependency 'activesupport', '~> 4'
end
3 changes: 2 additions & 1 deletion lib/chronic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
require 'date'
require 'numerizer'

require 'chronic/version'

require 'chronic/parser'
require 'chronic/date'
require 'chronic/time'
Expand Down Expand Up @@ -54,7 +56,6 @@
# Chronic.parse('monday', :context => :past)
# #=> Mon Aug 21 12:00:00 PDT 2006
module Chronic
VERSION = '0.10.2'

class << self

Expand Down
3 changes: 3 additions & 0 deletions lib/chronic/version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module Chronic
VERSION = '0.10.2'
end

0 comments on commit 61570de

Please sign in to comment.