Browse files

Bring build process up to date using RakeGem.

  • Loading branch information...
1 parent 180e447 commit 4b1e593818c73c0b225b06edddc5ab7b63d55276 @mojombo committed Oct 22, 2010
Showing with 256 additions and 70 deletions.
  1. +4 −0 History.txt
  2. +21 −0 LICENSE
  3. +0 −25 README
  4. +145 −18 Rakefile
  5. +85 −17 chronic.gemspec
  6. +1 −1 lib/chronic.rb
  7. 0 lib/{ → chronic}/numerizer/numerizer.rb
  8. +0 −9 test/suite.rb
View
4 History.txt
@@ -1,3 +1,7 @@
+= 0.3.0
+
+* the dark days
+
= 0.2.4
* fixed numerizer number combination bug (27 Oct 2006 7:30pm works now) (reported by reynard h)
View
21 LICENSE
@@ -0,0 +1,21 @@
+The MIT License
+
+Copyright (c) Tom Preston-Werner
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
View
25 README
@@ -140,28 +140,3 @@ local time zone. You can set this to something like ActiveSupport's TimeZone cl
== LIMITATIONS:
Chronic uses Ruby's built in Time class for all time storage and computation. Because of this, only times that the Time class can handle will be properly parsed. Parsing for times outside of this range will simply return nil. Support for a wider range of times is planned for a future release.
-
-== LICENSE:
-
-(The MIT License)
-
-Copyright (c) 2008 Tom Preston-Werner
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
163 Rakefile
@@ -1,19 +1,146 @@
-# -*- ruby -*-
-
require 'rubygems'
-require 'hoe'
-require './lib/chronic.rb'
-
-Hoe.new('chronic', Chronic::VERSION) do |p|
- p.rubyforge_name = 'chronic'
- p.summary = 'A natural language date parser'
- p.author = 'Tom Preston-Werner'
- p.email = 'tom@rubyisawesome.com'
- p.description = p.paragraphs_of('README', 2).join("\n\n")
- p.url = p.paragraphs_of('README', 0).first.split(/\n/)[1..-1]
- p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
- p.need_tar = false
- p.extra_deps = []
-end
-
-# vim: syntax=Ruby
+require 'rake'
+require 'date'
+
+#############################################################################
+#
+# Helper functions
+#
+#############################################################################
+
+def name
+ @name ||= Dir['*.gemspec'].first.split('.').first
+end
+
+def version
+ line = File.read("lib/#{name}.rb")[/^\s*VERSION\s*=\s*.*/]
+ line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
+end
+
+def date
+ Date.today.to_s
+end
+
+def rubyforge_project
+ name
+end
+
+def gemspec_file
+ "#{name}.gemspec"
+end
+
+def gem_file
+ "#{name}-#{version}.gem"
+end
+
+def replace_header(head, header_name)
+ head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
+end
+
+#############################################################################
+#
+# Standard tasks
+#
+#############################################################################
+
+task :default => :test
+
+require 'rake/testtask'
+Rake::TestTask.new(:test) do |test|
+ test.libs << 'lib' << 'test'
+ test.pattern = 'test/**/test_*.rb'
+ test.verbose = true
+end
+
+desc "Generate RCov test coverage and open in your browser"
+task :coverage do
+ require 'rcov'
+ sh "rm -fr coverage"
+ sh "rcov test/test_*.rb"
+ sh "open coverage/index.html"
+end
+
+require 'rake/rdoctask'
+Rake::RDocTask.new do |rdoc|
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = "#{name} #{version}"
+ rdoc.rdoc_files.include('README*')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+end
+
+desc "Open an irb session preloaded with this library"
+task :console do
+ sh "irb -rubygems -r ./lib/#{name}.rb"
+end
+
+#############################################################################
+#
+# Custom tasks (add your own tasks here)
+#
+#############################################################################
+
+
+
+#############################################################################
+#
+# Packaging tasks
+#
+#############################################################################
+
+task :release => :build do
+ unless `git branch` =~ /^\* master$/
+ puts "You must be on the master branch to release!"
+ exit!
+ end
+ sh "git commit --allow-empty -a -m 'Release #{version}'"
+ sh "git tag v#{version}"
+ sh "git push origin master"
+ sh "git push origin v#{version}"
+ sh "gem push pkg/#{name}-#{version}.gem"
+end
+
+task :build => :gemspec do
+ sh "mkdir -p pkg"
+ sh "gem build #{gemspec_file}"
+ sh "mv #{gem_file} pkg"
+end
+
+task :gemspec => :validate do
+ # read spec file and split out manifest section
+ spec = File.read(gemspec_file)
+ head, manifest, tail = spec.split(" # = MANIFEST =\n")
+
+ # replace name version and date
+ replace_header(head, :name)
+ replace_header(head, :version)
+ replace_header(head, :date)
+ #comment this out if your rubyforge_project has a different name
+ replace_header(head, :rubyforge_project)
+
+ # determine file list from git ls-files
+ files = `git ls-files`.
+ split("\n").
+ sort.
+ reject { |file| file =~ /^\./ }.
+ reject { |file| file =~ /^(rdoc|pkg)/ }.
+ map { |file| " #{file}" }.
+ join("\n")
+
+ # piece file back together and write
+ manifest = " s.files = %w[\n#{files}\n ]\n"
+ spec = [head, manifest, tail].join(" # = MANIFEST =\n")
+ File.open(gemspec_file, 'w') { |io| io.write(spec) }
+ puts "Updated #{gemspec_file}"
+end
+
+task :validate do
+ libfiles = Dir['lib/*'] - ["lib/#{name}.rb", "lib/#{name}"]
+ unless libfiles.empty?
+ puts "Directory `lib` should only contain a `#{name}.rb` file and `#{name}` dir."
+ exit!
+ end
+ unless Dir['VERSION*'].empty?
+ puts "A `VERSION` file at root level violates Gem best practices."
+ exit!
+ end
+end
View
102 chronic.gemspec
@@ -1,18 +1,86 @@
-SPEC = Gem::Specification.new do |s|
- s.name = 'chronic'
- s.version = '0.3.0'
- s.author = 'Tom Preston-Werner'
- s.email = 'tom@rubyisawesome.com'
- s.homepage = 'http://chronic.rubyforge.org'
- s.platform = Gem::Platform::RUBY
- s.summary = "A natural language date parser with timezone support"
- # Explicitly list all files because Dir[] is incompatible with safelevel 3
- # Just run irb >> Dir["{lib,test}/**/*"] to get the newest array of files
- s.files = ["lib/chronic", "lib/chronic/chronic.rb", "lib/chronic/grabber.rb", "lib/chronic/handlers.rb", "lib/chronic/ordinal.rb", "lib/chronic/pointer.rb", "lib/chronic/repeater.rb", "lib/chronic/repeaters", "lib/chronic/repeaters/repeater_day.rb", "lib/chronic/repeaters/repeater_day_name.rb", "lib/chronic/repeaters/repeater_day_portion.rb", "lib/chronic/repeaters/repeater_fortnight.rb", "lib/chronic/repeaters/repeater_hour.rb", "lib/chronic/repeaters/repeater_minute.rb", "lib/chronic/repeaters/repeater_month.rb", "lib/chronic/repeaters/repeater_month_name.rb", "lib/chronic/repeaters/repeater_season.rb", "lib/chronic/repeaters/repeater_season_name.rb", "lib/chronic/repeaters/repeater_second.rb", "lib/chronic/repeaters/repeater_time.rb", "lib/chronic/repeaters/repeater_week.rb", "lib/chronic/repeaters/repeater_weekday.rb", "lib/chronic/repeaters/repeater_weekend.rb", "lib/chronic/repeaters/repeater_year.rb", "lib/chronic/scalar.rb", "lib/chronic/separator.rb", "lib/chronic/time_zone.rb", "lib/chronic.rb", "lib/numerizer", "lib/numerizer/numerizer.rb", "test/suite.rb", "test/test_Chronic.rb", "test/test_Handler.rb", "test/test_Numerizer.rb", "test/test_parsing.rb", "test/test_RepeaterDayName.rb", "test/test_RepeaterFortnight.rb", "test/test_RepeaterHour.rb", "test/test_RepeaterMonth.rb", "test/test_RepeaterMonthName.rb", "test/test_RepeaterTime.rb", "test/test_RepeaterWeek.rb", "test/test_RepeaterWeekday.rb", "test/test_RepeaterWeekend.rb", "test/test_RepeaterYear.rb", "test/test_Span.rb", "test/test_Time.rb", "test/test_Token.rb"]
- s.require_path = "lib"
- s.autorequire = "chronic"
- s.test_file = "test/suite.rb"
- s.has_rdoc = true
- s.extra_rdoc_files = ['README']
- s.rdoc_options << '--main' << 'README'
+Gem::Specification.new do |s|
+ s.specification_version = 2 if s.respond_to? :specification_version=
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
+ s.rubygems_version = '1.3.5'
+
+ s.name = 'chronic'
+ s.version = '0.3.0'
+ s.date = '2010-10-22'
+ s.rubyforge_project = 'chronic'
+
+ s.summary = "Natural language date/time parsing."
+ s.description = "Chronic is a natural language date/time parser written in pure Ruby."
+
+ s.authors = ["Tom Preston-Werner"]
+ s.email = 'tom@mojombo.com'
+ s.homepage = 'http://github.com/mojombo/chronic'
+
+ s.require_paths = %w[lib]
+
+ s.rdoc_options = ["--charset=UTF-8"]
+ s.extra_rdoc_files = %w[README LICENSE]
+
+ # = MANIFEST =
+ s.files = %w[
+ History.txt
+ LICENSE
+ Manifest.txt
+ README
+ Rakefile
+ benchmark/benchmark.rb
+ chronic.gemspec
+ lib/chronic.rb
+ lib/chronic/chronic.rb
+ lib/chronic/grabber.rb
+ lib/chronic/handlers.rb
+ lib/chronic/numerizer/numerizer.rb
+ lib/chronic/ordinal.rb
+ lib/chronic/pointer.rb
+ lib/chronic/repeater.rb
+ lib/chronic/repeaters/repeater_day.rb
+ lib/chronic/repeaters/repeater_day_name.rb
+ lib/chronic/repeaters/repeater_day_portion.rb
+ lib/chronic/repeaters/repeater_fortnight.rb
+ lib/chronic/repeaters/repeater_hour.rb
+ lib/chronic/repeaters/repeater_minute.rb
+ lib/chronic/repeaters/repeater_month.rb
+ lib/chronic/repeaters/repeater_month_name.rb
+ lib/chronic/repeaters/repeater_season.rb
+ lib/chronic/repeaters/repeater_season_name.rb
+ lib/chronic/repeaters/repeater_second.rb
+ lib/chronic/repeaters/repeater_time.rb
+ lib/chronic/repeaters/repeater_week.rb
+ lib/chronic/repeaters/repeater_weekday.rb
+ lib/chronic/repeaters/repeater_weekend.rb
+ lib/chronic/repeaters/repeater_year.rb
+ lib/chronic/scalar.rb
+ lib/chronic/separator.rb
+ lib/chronic/time_zone.rb
+ lib/numerizer/numerizer.rb
+ test/suite.rb
+ test/test_Chronic.rb
+ test/test_DaylightSavings.rb
+ test/test_Handler.rb
+ test/test_Numerizer.rb
+ test/test_RepeaterDayName.rb
+ test/test_RepeaterFortnight.rb
+ test/test_RepeaterHour.rb
+ test/test_RepeaterMinute.rb
+ test/test_RepeaterMonth.rb
+ test/test_RepeaterMonthName.rb
+ test/test_RepeaterTime.rb
+ test/test_RepeaterWeek.rb
+ test/test_RepeaterWeekday.rb
+ test/test_RepeaterWeekend.rb
+ test/test_RepeaterYear.rb
+ test/test_Span.rb
+ test/test_Time.rb
+ test/test_Token.rb
+ test/test_parsing.rb
+ ]
+ # = MANIFEST =
+
+ ## Test files will be grabbed from the file list. Make sure the path glob
+ ## matches what you actually use.
+ s.test_files = s.files.select { |path| path =~ /^test\/test_.*\.rb/ }
end
View
2 lib/chronic.rb
@@ -39,7 +39,7 @@
require 'chronic/separator'
require 'chronic/time_zone'
-require 'numerizer/numerizer'
+require 'chronic/numerizer/numerizer'
module Chronic
VERSION = "0.3.0"
View
0 lib/numerizer/numerizer.rb → lib/chronic/numerizer/numerizer.rb
File renamed without changes.
View
9 test/suite.rb
@@ -1,9 +0,0 @@
-require 'test/unit'
-
-tests = Dir["#{File.dirname(__FILE__)}/test_*.rb"]
-tests.delete_if { |o| o =~ /test_parsing/ }
-tests.each do |file|
- require file
-end
-
-require File.dirname(__FILE__) + '/test_parsing.rb'

0 comments on commit 4b1e593

Please sign in to comment.