http_router 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -7,10 +7,6 @@ Spec::Rake::SpecTask.new(:spec) do |t|
7
7
  t.spec_files = FileList['spec/**/*_spec.rb']
8
8
  end
9
9
 
10
- task 'tumbler:preflight' do
11
- Rake::Task["spec"].invoke
12
- end
13
-
14
10
  begin
15
11
  require 'code_stats'
16
12
  CodeStats::Tasks.new
@@ -25,8 +21,6 @@ Rake::RDocTask.new do |rd|
25
21
  rd.rdoc_dir = 'rdoc'
26
22
  end
27
23
 
24
+ require 'ext/gem_rake'
28
25
 
29
- # automatically added Tumbler tasks
30
-
31
- require 'tumbler'
32
- Tumbler.use_rake_tasks
26
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,126 @@
1
+ module Bundler
2
+ class GemHelper
3
+
4
+ def self.install_tasks
5
+ dir = caller.find{|c| /Rakefile:/}[/^(.*?)\/Rakefile:/, 1]
6
+ GemHelper.new(dir).install
7
+ end
8
+
9
+ attr_reader :spec_path, :base, :name
10
+
11
+ def initialize(base, name = nil)
12
+ @base = base
13
+ @name = name || interpolate_name
14
+ @spec_path = File.join(@base, "#{@name}.gemspec")
15
+ end
16
+
17
+ def install
18
+ desc 'Build your gem into the pkg directory'
19
+ task 'build' do
20
+ build_gem
21
+ end
22
+
23
+ desc 'Install your gem into the pkg directory'
24
+ task 'install' do
25
+ install_gem
26
+ end
27
+
28
+ desc 'Push your gem to rubygems'
29
+ task 'push' do
30
+ push_gem
31
+ end
32
+ end
33
+
34
+ def build_gem
35
+ file_name = nil
36
+ sh("gem build #{spec_path}") {
37
+ file_name = File.basename(built_gem_path)
38
+ FileUtils.mkdir_p(File.join(base, 'pkg'))
39
+ FileUtils.mv(built_gem_path, 'pkg')
40
+ }
41
+ File.join(base, 'pkg', file_name)
42
+ end
43
+
44
+ def install_gem
45
+ built_gem_path = build_gem
46
+ sh("gem install #{built_gem_path}")
47
+ end
48
+
49
+ def push_gem
50
+ guard_clean
51
+ guard_already_tagged
52
+ tag_version {
53
+ git_push
54
+ rubygem_push(build_gem)
55
+ }
56
+ end
57
+
58
+ protected
59
+ def rubygem_push(path)
60
+ sh("gem push #{path}")
61
+ end
62
+
63
+ def built_gem_path
64
+ Dir[File.join(base, "#{name}-*.gem")].sort_by{|f| File.mtime(f)}.last
65
+ end
66
+
67
+ def interpolate_name
68
+ gemspecs = Dir[File.join(base, "*.gemspec")]
69
+ raise "Unable to determine name from existing gemspec." unless gemspecs.size == 1
70
+
71
+ File.basename(gemspecs.first)[/^(.*)\.gemspec$/, 1]
72
+ end
73
+
74
+ def git_push
75
+ sh "git push --all"
76
+ sh "git push --tags"
77
+ end
78
+
79
+ def guard_already_tagged
80
+ sh('git tag').split(/\n/).include?(current_version_tag) and raise("This tag has already been committed to the repo.")
81
+ end
82
+
83
+ def guard_clean
84
+ clean? or raise("There are files that need to be committed first.")
85
+ end
86
+
87
+ def clean?
88
+ sh("git ls-files -dm").split("\n").size.zero?
89
+ end
90
+
91
+ def tag_version
92
+ sh "git tag #{current_version_tag}"
93
+ yield if block_given?
94
+ rescue
95
+ sh "git tag -d #{current_version_tag}"
96
+ raise
97
+ end
98
+
99
+ def current_version
100
+ raise("Version file could not be found at #{version_file_path}") unless File.exist?(version_file_path)
101
+ File.read(version_file_path)[/V(ERSION|ersion)\s*=\s*(["'])(.*?)\2/, 3]
102
+ end
103
+
104
+ def version_file_path
105
+ File.join(base, 'lib', name, 'version.rb')
106
+ end
107
+
108
+ def current_version_tag
109
+ "v#{current_version}"
110
+ end
111
+
112
+ def sh(cmd, &block)
113
+ output, code = sh_with_code(cmd, &block)
114
+ code == 0 ? output : raise(output)
115
+ end
116
+
117
+ def sh_with_code(cmd, &block)
118
+ output = ''
119
+ Dir.chdir(base) {
120
+ output = `#{cmd}`
121
+ block.call if block and $? == 0
122
+ }
123
+ [output, $?]
124
+ end
125
+ end
126
+ end
@@ -7,8 +7,9 @@ Gem::Specification.new do |s|
7
7
  s.version = HttpRouter::VERSION
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
9
9
  s.authors = ["Joshua Hull"]
10
- s.date = '2010-07-12'
11
- s.description = %q{A kick-ass HTTP router for use in Rack & Sinatra}
10
+ s.date = HttpRouter::RELEASE_DATE
11
+ s.summary = "A kick-ass HTTP router for use in Rack & Sinatra"
12
+ s.description = "This library allows you to recognize and build URLs in a Rack application. As well it contains an interface for use within Sinatra."
12
13
  s.email = %q{joshbuddy@gmail.com}
13
14
  s.extra_rdoc_files = ['README.rdoc']
14
15
  s.files = `git ls-files`.split("\n")
@@ -16,8 +17,8 @@ Gem::Specification.new do |s|
16
17
  s.rdoc_options = ["--charset=UTF-8"]
17
18
  s.require_paths = ["lib"]
18
19
  s.rubygems_version = %q{1.3.7}
19
- s.summary = %q{A kick-ass HTTP router for use in Rack & Sinatra}
20
20
  s.test_files = `git ls-files`.split("\n").select{|f| f =~ /^spec/}
21
+ s.rubyforge_project = 'http_router'
21
22
 
22
23
  # dependencies
23
24
  s.add_runtime_dependency 'rack', '>=1.0'
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
2
  class HttpRouter #:nodoc
3
- VERSION = '0.3.4'
3
+ VERSION = '0.3.5'.freeze
4
+ RELEASE_DATE = '2010-07-18'.freeze
4
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http_router
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 4
10
- version: 0.3.4
9
+ - 5
10
+ version: 0.3.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Joshua Hull
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-12 00:00:00 -04:00
18
+ date: 2010-07-18 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -121,7 +121,7 @@ dependencies:
121
121
  version: 0.0.11
122
122
  type: :development
123
123
  version_requirements: *id007
124
- description: A kick-ass HTTP router for use in Rack & Sinatra
124
+ description: This library allows you to recognize and build URLs in a Rack application. As well it contains an interface for use within Sinatra.
125
125
  email: joshbuddy@gmail.com
126
126
  executables: []
127
127
 
@@ -153,6 +153,7 @@ files:
153
153
  - examples/static/images/cat3.jpg
154
154
  - examples/variable.ru
155
155
  - examples/variable_with_regex.ru
156
+ - ext/gem_rake.rb
156
157
  - http_router.gemspec
157
158
  - lib/ext/rack/rack_mapper.rb
158
159
  - lib/ext/rack/rack_urlmap.rb
@@ -210,7 +211,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
210
211
  version: "0"
211
212
  requirements: []
212
213
 
213
- rubyforge_project:
214
+ rubyforge_project: http_router
214
215
  rubygems_version: 1.3.7
215
216
  signing_key:
216
217
  specification_version: 3