From 61570de76914ed5b1bd21e681a0a36ef5b474140 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C4=81vis?= Date: Wed, 28 May 2014 17:51:58 +0300 Subject: [PATCH] Create version file and use it for Rakefile, instead of parsing with regexp --- Rakefile | 24 +++++++++++++----------- chronic.gemspec | 8 ++++---- lib/chronic.rb | 3 ++- lib/chronic/version.rb | 3 +++ 4 files changed, 22 insertions(+), 16 deletions(-) create mode 100644 lib/chronic/version.rb diff --git a/Rakefile b/Rakefile index 43283300..50a32f55 100644 --- a/Rakefile +++ b/Rakefile @@ -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 @@ -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! @@ -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}" @@ -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 \ No newline at end of file +task :default => :test diff --git a/chronic.gemspec b/chronic.gemspec index e0dff675..169ae011 100644 --- a/chronic.gemspec +++ b/chronic.gemspec @@ -1,5 +1,5 @@ $:.unshift File.expand_path('../lib', __FILE__) -require 'chronic' +require 'chronic/version' Gem::Specification.new do |s| s.name = 'chronic' @@ -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 diff --git a/lib/chronic.rb b/lib/chronic.rb index 914e02f0..1659a929 100644 --- a/lib/chronic.rb +++ b/lib/chronic.rb @@ -2,6 +2,8 @@ require 'date' require 'numerizer' +require 'chronic/version' + require 'chronic/parser' require 'chronic/date' require 'chronic/time' @@ -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 diff --git a/lib/chronic/version.rb b/lib/chronic/version.rb new file mode 100644 index 00000000..af461fdc --- /dev/null +++ b/lib/chronic/version.rb @@ -0,0 +1,3 @@ +module Chronic + VERSION = '0.10.2' +end