http_status_exceptions 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -3,4 +3,5 @@ http_status_exceptions-*.gem
3
3
  /doc
4
4
  /pkg
5
5
  /coverage
6
- .DS_Store
6
+ .DS_Store
7
+ /.bundle
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source :rubygems
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,25 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ http_status_exceptions (0.2.0)
5
+ actionpack (~> 2)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ actionpack (2.3.9)
11
+ activesupport (= 2.3.9)
12
+ rack (~> 1.1.0)
13
+ activesupport (2.3.9)
14
+ rack (1.1.0)
15
+ rake (0.8.7)
16
+ rspec (1.3.0)
17
+
18
+ PLATFORMS
19
+ ruby
20
+
21
+ DEPENDENCIES
22
+ actionpack (~> 2)
23
+ http_status_exceptions!
24
+ rake
25
+ rspec
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 20082-2009 Willem van Bergen
1
+ Copyright (c) 2008-2010 Willem van Bergen
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.rdoc CHANGED
@@ -1,11 +1,3 @@
1
- <b>WARNING:</b> the gem version that Github currently serves is faulty. The issue
2
- is already fixes in the repository, but Github is not yet building new gem
3
- versions. As soon as this is fixed, I will release a new version that resolves
4
- the issue. For now, install version 0.1.5 which is unaffected:
5
-
6
- sudo gem install wvanbergen-http_status_exceptions \
7
- --source http://gems.github.com --version "= 0.1.5"
8
-
9
1
  = HTTP status exception
10
2
 
11
3
  This simple plugin will register exception classes for all HTTP status. These exceptions can then be raised from your controllers, after
@@ -14,17 +6,21 @@ which a response will be send back to the client with the desired HTTP status, p
14
6
  You can use this plugin to access control mechanisms. You can simply raise a HTTPStatus::Forbidden if a user is not allowed to
15
7
  perform a certain action. A nice looking error page will be the result. See the example below:
16
8
 
17
- See the project wiki (http://github.com/wvanbergen/http_status_exceptions/wikis) for additional documentation.
9
+ See the project wiki (http://wiki.github.com/wvanbergen/http_status_exceptions) for additional documentation.
18
10
 
19
11
  == Installation
20
12
 
21
- Installation is simple. Simply add the gem in your <tt>environment.rb</tt>:
13
+ Installation is simple. Simply add the gem to the configuration in your <tt>environment.rb</tt> or <tt>Gemfile</tt>:
22
14
 
15
+ # environment.rb
23
16
  Rails::Initializer.run do |config|
24
17
  ...
25
- config.gem 'wvanbergen-http_status_exceptions', :lib => 'http_status_exceptions', :source => 'http://gems.github.com'
18
+ config.gem 'http_status_exceptions'
26
19
  end
27
20
 
21
+ # Gemfile
22
+ gem 'http_status_exceptions'
23
+
28
24
  Run <tt>rake gems:install</tt> to install the gem if needed.
29
25
 
30
26
  == Configuration
@@ -3,13 +3,15 @@ Gem::Specification.new do |s|
3
3
 
4
4
  # Do not update the version and date values by hand.
5
5
  # This will be done automatically by the gem release script.
6
- s.version = "0.2.0"
7
- s.date = "2009-10-07"
6
+ s.version = "0.2.1"
7
+ s.date = "2010-09-24"
8
8
 
9
9
  s.summary = "A Rails plugin to use exceptions for generating HTTP status responses"
10
10
  s.description = "Clean up your controller code by raising exceptions that generate responses with different HTTP status codes."
11
11
 
12
- s.add_runtime_dependency('actionpack', '>= 2.1.0')
12
+ s.add_runtime_dependency('actionpack', '~> 2')
13
+
14
+ s.add_development_dependency('rake')
13
15
  s.add_development_dependency('rspec')
14
16
 
15
17
  s.authors = ['Willem van Bergen']
@@ -18,6 +20,6 @@ Gem::Specification.new do |s|
18
20
 
19
21
  # Do not update the files and test_files values by hand.
20
22
  # This will be done automatically by the gem release script.
21
- s.files = %w(spec/spec_helper.rb http_status_exceptions.gemspec .gitignore init.rb lib/http_status_exceptions.rb Rakefile MIT-LICENSE tasks/github-gem.rake README.rdoc spec/http_status_exception_spec.rb)
23
+ s.files = %w(spec/spec_helper.rb spec/http_status_exception_spec.rb http_status_exceptions.gemspec .gitignore MIT-LICENSE lib/http_status_exceptions.rb Gemfile init.rb Rakefile README.rdoc Gemfile.lock tasks/github-gem.rake)
22
24
  s.test_files = %w(spec/http_status_exception_spec.rb)
23
25
  end
@@ -19,7 +19,7 @@ module HTTPStatus
19
19
 
20
20
  # The current gem release version. Do not set this value by hand, it will
21
21
  # be done automatically by them gem release script.
22
- VERSION = "0.2.0"
22
+ VERSION = "0.2.1"
23
23
 
24
24
  # The Base HTTP status exception class is used as superclass for every
25
25
  # exception class that is constructed. It implements some shared
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  describe HTTPStatus::Base, 'class inheritance' do
4
4
  before(:all) do
data/spec/spec_helper.rb CHANGED
@@ -1,10 +1,12 @@
1
1
  $: << File.join(File.dirname(__FILE__), '..', 'lib')
2
2
 
3
3
  require 'rubygems'
4
- require 'spec/autorun'
4
+ require 'bundler'
5
5
 
6
- require 'action_controller'
6
+ Bundler.setup
7
7
 
8
+ require 'spec/autorun'
9
+ require 'action_controller'
8
10
  require 'http_status_exceptions'
9
11
 
10
12
  # Include all files in the spec_helper directory
@@ -119,23 +119,43 @@ module GithubGem
119
119
  checks = [:check_current_branch, :check_clean_status, :check_not_diverged, :check_version]
120
120
  checks.unshift('spec:basic') if has_specs?
121
121
  checks.unshift('test:basic') if has_tests?
122
- checks.push << [:check_rubyforge] if gemspec.rubyforge_project
122
+ # checks.push << [:check_rubyforge] if gemspec.rubyforge_project
123
123
 
124
124
  desc "Perform all checks that would occur before a release"
125
125
  task(:release_checks => checks)
126
126
 
127
- release_tasks = [:release_checks, :set_version, :build, :github_release]
128
- release_tasks << [:rubyforge_release] if gemspec.rubyforge_project
127
+ release_tasks = [:release_checks, :set_version, :build, :github_release, :gemcutter_release]
128
+ # release_tasks << [:rubyforge_release] if gemspec.rubyforge_project
129
129
 
130
- desc "Release a new verison of the gem"
130
+ desc "Release a new version of the gem using the VERSION environment variable"
131
131
  task(:release => release_tasks) { release_task }
132
+
133
+ namespace(:release) do
134
+ desc "Release the next version of the gem, by incrementing the last version segment by 1"
135
+ task(:next => [:next_version] + release_tasks) { release_task }
132
136
 
133
- task(:check_rubyforge) { check_rubyforge_task }
134
- task(:rubyforge_release) { rubyforge_release_task }
137
+ desc "Release the next version of the gem, using a patch increment (0.0.1)"
138
+ task(:patch => [:next_patch_version] + release_tasks) { release_task }
139
+
140
+ desc "Release the next version of the gem, using a minor increment (0.1.0)"
141
+ task(:minor => [:next_minor_version] + release_tasks) { release_task }
142
+
143
+ desc "Release the next version of the gem, using a major increment (1.0.0)"
144
+ task(:major => [:next_major_version] + release_tasks) { release_task }
145
+ end
146
+
147
+ # task(:check_rubyforge) { check_rubyforge_task }
148
+ # task(:rubyforge_release) { rubyforge_release_task }
149
+ task(:gemcutter_release) { gemcutter_release_task }
135
150
  task(:github_release => [:commit_modified_files, :tag_version]) { github_release_task }
136
151
  task(:tag_version) { tag_version_task }
137
152
  task(:commit_modified_files) { commit_modified_files_task }
138
153
 
154
+ task(:next_version) { next_version_task }
155
+ task(:next_patch_version) { next_version_task(:patch) }
156
+ task(:next_minor_version) { next_version_task(:minor) }
157
+ task(:next_major_version) { next_version_task(:major) }
158
+
139
159
  desc "Updates the gem release tasks with the latest version on Github"
140
160
  task(:update_tasks) { update_tasks_task }
141
161
  end
@@ -159,6 +179,32 @@ module GithubGem
159
179
  sh "mv #{gemspec.name}-#{gemspec.version}.gem pkg/#{gemspec.name}-#{gemspec.version}.gem"
160
180
  end
161
181
 
182
+ def newest_version
183
+ git.tags.map { |tag| tag.name.split('-').last }.compact.map { |v| Gem::Version.new(v) }.max || Gem::Version.new('0.0.0')
184
+ end
185
+
186
+ def next_version(increment = nil)
187
+ next_version = newest_version.segments
188
+ increment_index = case increment
189
+ when :micro then 3
190
+ when :patch then 2
191
+ when :minor then 1
192
+ when :major then 0
193
+ else next_version.length - 1
194
+ end
195
+
196
+ next_version[increment_index] ||= 0
197
+ next_version[increment_index] = next_version[increment_index].succ
198
+ ((increment_index + 1)...next_version.length).each { |i| next_version[i] = 0 }
199
+
200
+ Gem::Version.new(next_version.join('.'))
201
+ end
202
+
203
+ def next_version_task(increment = nil)
204
+ ENV['VERSION'] = next_version(increment).version
205
+ puts "Releasing version #{ENV['VERSION']}..."
206
+ end
207
+
162
208
  # Updates the version number in the gemspec file, the VERSION constant in the main
163
209
  # include file and the contents of the VERSION file.
164
210
  def version_task
@@ -171,10 +217,8 @@ module GithubGem
171
217
 
172
218
  def check_version_task
173
219
  raise "#{ENV['VERSION']} is not a valid version number!" if ENV['VERSION'] && !Gem::Version.correct?(ENV['VERSION'])
174
- proposed_version = Gem::Version.new(ENV['VERSION'] || gemspec.version)
175
- # Loads the latest version number using the created tags
176
- newest_version = git.tags.map { |tag| tag.name.split('-').last }.compact.map { |v| Gem::Version.new(v) }.max
177
- raise "This version (#{proposed_version}) is not higher than the highest tagged version (#{newest_version})" if newest_version && newest_version >= proposed_version
220
+ proposed_version = Gem::Version.new(ENV['VERSION'].dup || gemspec.version)
221
+ raise "This version (#{proposed_version}) is not higher than the highest tagged version (#{newest_version})" if newest_version >= proposed_version
178
222
  end
179
223
 
180
224
  # Checks whether the current branch is not diverged from the remote branch
@@ -215,18 +259,22 @@ module GithubGem
215
259
  git.push(remote, remote_branch, true)
216
260
  end
217
261
 
218
- # Checks whether Rubyforge is configured properly
219
- def check_rubyforge_task
220
- # Login no longer necessary when using rubyforge 2.0.0 gem
221
- # raise "Could not login on rubyforge!" unless `rubyforge login 2>&1`.strip.empty?
222
- output = `rubyforge names`.split("\n")
223
- raise "Rubyforge group not found!" unless output.any? { |line| %r[^groups\s*\:.*\b#{Regexp.quote(gemspec.rubyforge_project)}\b.*] =~ line }
224
- raise "Rubyforge package not found!" unless output.any? { |line| %r[^packages\s*\:.*\b#{Regexp.quote(gemspec.name)}\b.*] =~ line }
225
- end
226
-
227
- # Task to release the .gem file toRubyforge.
228
- def rubyforge_release_task
229
- sh 'rubyforge', 'add_release', gemspec.rubyforge_project, gemspec.name, gemspec.version.to_s, "pkg/#{gemspec.name}-#{gemspec.version}.gem"
262
+ # # Checks whether Rubyforge is configured properly
263
+ # def check_rubyforge_task
264
+ # # Login no longer necessary when using rubyforge 2.0.0 gem
265
+ # # raise "Could not login on rubyforge!" unless `rubyforge login 2>&1`.strip.empty?
266
+ # output = `rubyforge names`.split("\n")
267
+ # raise "Rubyforge group not found!" unless output.any? { |line| %r[^groups\s*\:.*\b#{Regexp.quote(gemspec.rubyforge_project)}\b.*] =~ line }
268
+ # raise "Rubyforge package not found!" unless output.any? { |line| %r[^packages\s*\:.*\b#{Regexp.quote(gemspec.name)}\b.*] =~ line }
269
+ # end
270
+
271
+ # # Task to release the .gem file toRubyforge.
272
+ # def rubyforge_release_task
273
+ # sh 'rubyforge', 'add_release', gemspec.rubyforge_project, gemspec.name, gemspec.version.to_s, "pkg/#{gemspec.name}-#{gemspec.version}.gem"
274
+ # end
275
+
276
+ def gemcutter_release_task
277
+ sh "gem push pkg/#{gemspec.name}-#{gemspec.version}.gem"
230
278
  end
231
279
 
232
280
  # Gem release task.
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http_status_exceptions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ hash: 21
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 2
9
+ - 1
10
+ version: 0.2.1
5
11
  platform: ruby
6
12
  authors:
7
13
  - Willem van Bergen
@@ -9,29 +15,51 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2009-10-07 00:00:00 +02:00
18
+ date: 2010-09-24 00:00:00 +02:00
13
19
  default_executable:
14
20
  dependencies:
15
21
  - !ruby/object:Gem::Dependency
16
22
  name: actionpack
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ hash: 7
30
+ segments:
31
+ - 2
32
+ version: "2"
17
33
  type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: rake
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
20
40
  requirements:
21
41
  - - ">="
22
42
  - !ruby/object:Gem::Version
23
- version: 2.1.0
24
- version:
43
+ hash: 3
44
+ segments:
45
+ - 0
46
+ version: "0"
47
+ type: :development
48
+ version_requirements: *id002
25
49
  - !ruby/object:Gem::Dependency
26
50
  name: rspec
27
- type: :development
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
51
+ prerelease: false
52
+ requirement: &id003 !ruby/object:Gem::Requirement
53
+ none: false
30
54
  requirements:
31
55
  - - ">="
32
56
  - !ruby/object:Gem::Version
57
+ hash: 3
58
+ segments:
59
+ - 0
33
60
  version: "0"
34
- version:
61
+ type: :development
62
+ version_requirements: *id003
35
63
  description: Clean up your controller code by raising exceptions that generate responses with different HTTP status codes.
36
64
  email:
37
65
  - willem@vanbergen.org
@@ -43,15 +71,17 @@ extra_rdoc_files: []
43
71
 
44
72
  files:
45
73
  - spec/spec_helper.rb
74
+ - spec/http_status_exception_spec.rb
46
75
  - http_status_exceptions.gemspec
47
76
  - .gitignore
48
- - init.rb
77
+ - MIT-LICENSE
49
78
  - lib/http_status_exceptions.rb
79
+ - Gemfile
80
+ - init.rb
50
81
  - Rakefile
51
- - MIT-LICENSE
52
- - tasks/github-gem.rake
53
82
  - README.rdoc
54
- - spec/http_status_exception_spec.rb
83
+ - Gemfile.lock
84
+ - tasks/github-gem.rake
55
85
  has_rdoc: true
56
86
  homepage: http://github.com/wvanbergen/http_status_exceptions/wikis
57
87
  licenses: []
@@ -62,21 +92,27 @@ rdoc_options: []
62
92
  require_paths:
63
93
  - lib
64
94
  required_ruby_version: !ruby/object:Gem::Requirement
95
+ none: false
65
96
  requirements:
66
97
  - - ">="
67
98
  - !ruby/object:Gem::Version
99
+ hash: 3
100
+ segments:
101
+ - 0
68
102
  version: "0"
69
- version:
70
103
  required_rubygems_version: !ruby/object:Gem::Requirement
104
+ none: false
71
105
  requirements:
72
106
  - - ">="
73
107
  - !ruby/object:Gem::Version
108
+ hash: 3
109
+ segments:
110
+ - 0
74
111
  version: "0"
75
- version:
76
112
  requirements: []
77
113
 
78
114
  rubyforge_project:
79
- rubygems_version: 1.3.5
115
+ rubygems_version: 1.3.7
80
116
  signing_key:
81
117
  specification_version: 3
82
118
  summary: A Rails plugin to use exceptions for generating HTTP status responses