straides 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2012 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,3 @@
1
+ = Straides
2
+
3
+ This project rocks and uses MIT-LICENSE.
data/Rakefile ADDED
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+ require 'rspec/core/rake_task'
15
+
16
+ RDoc::Task.new(:rdoc) do |rdoc|
17
+ rdoc.rdoc_dir = 'rdoc'
18
+ rdoc.title = 'Straides'
19
+ rdoc.options << '--line-numbers'
20
+ rdoc.rdoc_files.include('README.rdoc')
21
+ rdoc.rdoc_files.include('lib/**/*.rb')
22
+ end
23
+
24
+ Bundler::GemHelper.install_tasks
25
+
26
+ desc 'Default: run the specs and features.'
27
+ task :default => 'spec:unit' do
28
+ system("bundle exec rake spec")
29
+ end
30
+
31
+ namespace :spec do
32
+
33
+ desc "Run unit specs"
34
+ RSpec::Core::RakeTask.new('unit') do |t|
35
+ t.pattern = 'spec/{*_spec.rb}'
36
+ end
37
+ end
38
+
39
+ desc "Run the unit tests"
40
+ task :spec => ['spec:unit']
41
+
@@ -0,0 +1,8 @@
1
+ # A custom exception for bubbling up HTTP errors and showing the correspending error pages.
2
+ class ReturnHttpCodeError < RuntimeError
3
+ attr_accessor :render_options
4
+
5
+ def initialize render_options
6
+ @render_options = render_options
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ module Straides
2
+ VERSION = "0.0.1"
3
+ end
data/lib/straides.rb ADDED
@@ -0,0 +1,37 @@
1
+ require 'return_http_code_error'
2
+ require 'active_record'
3
+
4
+ class ApplicationController < ActionController::Base
5
+
6
+ rescue_from(ReturnHttpCodeError) { |error| show_error(error) }
7
+
8
+
9
+ protected
10
+
11
+ # Makes the current action abort and return an HTTP error.
12
+ def error status, render_options = {}
13
+ render_options[:status] = status
14
+ raise ReturnHttpCodeError, render_options
15
+ end
16
+
17
+
18
+ private
19
+
20
+ # Outputs the given error to the client.
21
+ def show_error error
22
+ respond_to do |format|
23
+ format.html do
24
+ if (error.render_options.keys & [:file, :text, :json, :nothing]).empty?
25
+ error.render_options[:file] = "public/#{error.render_options[:status]}.html"
26
+ end
27
+ render error.render_options
28
+ end
29
+ format.json do
30
+ if (error.render_options.keys & [:file, :text, :json, :nothing]).empty?
31
+ error.render_options[:text] = ''
32
+ end
33
+ render error.render_options
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :straides do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: straides
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Kevin Goslar
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-02-25 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: &70245816341000 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70245816341000
25
+ - !ruby/object:Gem::Dependency
26
+ name: sqlite3
27
+ requirement: &70245816340580 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70245816340580
36
+ - !ruby/object:Gem::Dependency
37
+ name: rspec-rails
38
+ requirement: &70245816340160 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70245816340160
47
+ description: A more convenient way to return different HTTP status codes from Rails.
48
+ email:
49
+ - kevin.goslar@gmail.com
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - lib/return_http_code_error.rb
55
+ - lib/straides/version.rb
56
+ - lib/straides.rb
57
+ - lib/tasks/straides_tasks.rake
58
+ - MIT-LICENSE
59
+ - Rakefile
60
+ - README.rdoc
61
+ homepage: http://github.com/kevgo/straides
62
+ licenses: []
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ! '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ requirements: []
80
+ rubyforge_project:
81
+ rubygems_version: 1.8.12
82
+ signing_key:
83
+ specification_version: 3
84
+ summary: HTTP Status codes for Rails
85
+ test_files: []
86
+ has_rdoc: