short_circuit 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.
Files changed (43) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.md +84 -0
  3. data/Rakefile +21 -0
  4. data/lib/active_record_extension.rb +13 -0
  5. data/lib/short_circuit.rb +5 -0
  6. data/lib/short_circuit/presentable.rb +27 -0
  7. data/lib/short_circuit/presenter.rb +33 -0
  8. data/lib/short_circuit/version.rb +3 -0
  9. data/lib/tasks/short_circuit_tasks.rake +4 -0
  10. data/spec/dummy/README.rdoc +261 -0
  11. data/spec/dummy/Rakefile +7 -0
  12. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  13. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  14. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  15. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  16. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  17. data/spec/dummy/config.ru +4 -0
  18. data/spec/dummy/config/application.rb +59 -0
  19. data/spec/dummy/config/boot.rb +10 -0
  20. data/spec/dummy/config/database.yml +25 -0
  21. data/spec/dummy/config/environment.rb +5 -0
  22. data/spec/dummy/config/environments/development.rb +37 -0
  23. data/spec/dummy/config/environments/production.rb +67 -0
  24. data/spec/dummy/config/environments/test.rb +37 -0
  25. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  26. data/spec/dummy/config/initializers/inflections.rb +15 -0
  27. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  28. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  29. data/spec/dummy/config/initializers/session_store.rb +8 -0
  30. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  31. data/spec/dummy/config/locales/en.yml +5 -0
  32. data/spec/dummy/config/routes.rb +58 -0
  33. data/spec/dummy/db/test.sqlite3 +0 -0
  34. data/spec/dummy/log/development.log +1 -0
  35. data/spec/dummy/log/test.log +37 -0
  36. data/spec/dummy/public/404.html +26 -0
  37. data/spec/dummy/public/422.html +26 -0
  38. data/spec/dummy/public/500.html +25 -0
  39. data/spec/dummy/public/favicon.ico +0 -0
  40. data/spec/dummy/script/rails +6 -0
  41. data/spec/short_circuit/presentable_spec.rb +29 -0
  42. data/spec/spec_helper.rb +24 -0
  43. metadata +168 -0
File without changes
@@ -0,0 +1 @@
1
+ Connecting to database specified by database.yml
@@ -0,0 +1,37 @@
1
+ Connecting to database specified by database.yml
2
+ Connecting to database specified by database.yml
3
+ Connecting to database specified by database.yml
4
+ Connecting to database specified by database.yml
5
+ Connecting to database specified by database.yml
6
+ Connecting to database specified by database.yml
7
+ Connecting to database specified by database.yml
8
+ Connecting to database specified by database.yml
9
+ Connecting to database specified by database.yml
10
+ Connecting to database specified by database.yml
11
+ Connecting to database specified by database.yml
12
+ Connecting to database specified by database.yml
13
+ Connecting to database specified by database.yml
14
+ Connecting to database specified by database.yml
15
+ Connecting to database specified by database.yml
16
+ Connecting to database specified by database.yml
17
+ Connecting to database specified by database.yml
18
+ Connecting to database specified by database.yml
19
+ Connecting to database specified by database.yml
20
+ Connecting to database specified by database.yml
21
+ Connecting to database specified by database.yml
22
+ Connecting to database specified by database.yml
23
+ Connecting to database specified by database.yml
24
+ Connecting to database specified by database.yml
25
+ Connecting to database specified by database.yml
26
+ Connecting to database specified by database.yml
27
+ Connecting to database specified by database.yml
28
+ Connecting to database specified by database.yml
29
+ Connecting to database specified by database.yml
30
+ Connecting to database specified by database.yml
31
+ Connecting to database specified by database.yml
32
+ Connecting to database specified by database.yml
33
+ Connecting to database specified by database.yml
34
+ Connecting to database specified by database.yml
35
+ Connecting to database specified by database.yml
36
+ Connecting to database specified by database.yml
37
+ Connecting to database specified by database.yml
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/404.html -->
21
+ <div class="dialog">
22
+ <h1>The page you were looking for doesn't exist.</h1>
23
+ <p>You may have mistyped the address or the page may have moved.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/422.html -->
21
+ <div class="dialog">
22
+ <h1>The change you wanted was rejected.</h1>
23
+ <p>Maybe you tried to change something you didn't have access to.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,25 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/500.html -->
21
+ <div class="dialog">
22
+ <h1>We're sorry, but something went wrong.</h1>
23
+ </div>
24
+ </body>
25
+ </html>
File without changes
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
@@ -0,0 +1,29 @@
1
+ require_relative '../spec_helper'
2
+
3
+ module ShortCircuit
4
+ describe Presentable do
5
+ before :each do
6
+ @model = TestModel.new('foo', 'bar')
7
+ end
8
+
9
+ it "should have a presenter" do
10
+ @model.presenter.should be_an_instance_of TestModelPresenter
11
+ end
12
+
13
+ it "should present model attributes" do
14
+ @model.present(:foo).should eql 'Foo'
15
+ end
16
+
17
+ it "should delegate model attributes" do
18
+ @model.present(:bar).should eql 'bar'
19
+ end
20
+
21
+ it "should fail silently by default" do
22
+ expect { @model.present(:not_a_method) }.not_to raise_error NoMethodError
23
+ end
24
+
25
+ it "should throw errors when using bang method" do
26
+ expect { @model.present!(:not_a_method) }.to raise_error NoMethodError
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,24 @@
1
+ ENV['RAILS_ENV'] ||= 'test'
2
+
3
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
4
+ require 'rspec/rails'
5
+
6
+ require_relative '../lib/short_circuit/presentable'
7
+ require_relative '../lib/short_circuit/presenter'
8
+
9
+ class TestModel
10
+ include ShortCircuit::Presentable
11
+
12
+ attr_accessor :foo, :bar
13
+
14
+ def initialize(foo, bar)
15
+ self.foo = foo
16
+ self.bar = bar
17
+ end
18
+ end
19
+
20
+ class TestModelPresenter < ShortCircuit::Presenter
21
+ def foo
22
+ @testmodel.foo.titleize
23
+ end
24
+ end
metadata ADDED
@@ -0,0 +1,168 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: short_circuit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jim Pruetting
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-05-28 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 3.2.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 3.2.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: rspec-rails
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: sqlite3
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: Short Circuit enables simple presenters for Rails views.
63
+ email:
64
+ - jim@roboticmethod.com}
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - lib/active_record_extension.rb
70
+ - lib/short_circuit/presentable.rb
71
+ - lib/short_circuit/presenter.rb
72
+ - lib/short_circuit/version.rb
73
+ - lib/short_circuit.rb
74
+ - lib/tasks/short_circuit_tasks.rake
75
+ - MIT-LICENSE
76
+ - Rakefile
77
+ - README.md
78
+ - spec/dummy/app/assets/javascripts/application.js
79
+ - spec/dummy/app/assets/stylesheets/application.css
80
+ - spec/dummy/app/controllers/application_controller.rb
81
+ - spec/dummy/app/helpers/application_helper.rb
82
+ - spec/dummy/app/views/layouts/application.html.erb
83
+ - spec/dummy/config/application.rb
84
+ - spec/dummy/config/boot.rb
85
+ - spec/dummy/config/database.yml
86
+ - spec/dummy/config/environment.rb
87
+ - spec/dummy/config/environments/development.rb
88
+ - spec/dummy/config/environments/production.rb
89
+ - spec/dummy/config/environments/test.rb
90
+ - spec/dummy/config/initializers/backtrace_silencers.rb
91
+ - spec/dummy/config/initializers/inflections.rb
92
+ - spec/dummy/config/initializers/mime_types.rb
93
+ - spec/dummy/config/initializers/secret_token.rb
94
+ - spec/dummy/config/initializers/session_store.rb
95
+ - spec/dummy/config/initializers/wrap_parameters.rb
96
+ - spec/dummy/config/locales/en.yml
97
+ - spec/dummy/config/routes.rb
98
+ - spec/dummy/config.ru
99
+ - spec/dummy/db/test.sqlite3
100
+ - spec/dummy/log/development.log
101
+ - spec/dummy/log/test.log
102
+ - spec/dummy/public/404.html
103
+ - spec/dummy/public/422.html
104
+ - spec/dummy/public/500.html
105
+ - spec/dummy/public/favicon.ico
106
+ - spec/dummy/Rakefile
107
+ - spec/dummy/README.rdoc
108
+ - spec/dummy/script/rails
109
+ - spec/short_circuit/presentable_spec.rb
110
+ - spec/spec_helper.rb
111
+ homepage: http://www.roboticmethod.com
112
+ licenses: []
113
+ post_install_message:
114
+ rdoc_options: []
115
+ require_paths:
116
+ - lib
117
+ required_ruby_version: !ruby/object:Gem::Requirement
118
+ none: false
119
+ requirements:
120
+ - - ! '>='
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
124
+ none: false
125
+ requirements:
126
+ - - ! '>='
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ requirements: []
130
+ rubyforge_project:
131
+ rubygems_version: 1.8.24
132
+ signing_key:
133
+ specification_version: 3
134
+ summary: Simple presenters for Rails.
135
+ test_files:
136
+ - spec/dummy/app/assets/javascripts/application.js
137
+ - spec/dummy/app/assets/stylesheets/application.css
138
+ - spec/dummy/app/controllers/application_controller.rb
139
+ - spec/dummy/app/helpers/application_helper.rb
140
+ - spec/dummy/app/views/layouts/application.html.erb
141
+ - spec/dummy/config/application.rb
142
+ - spec/dummy/config/boot.rb
143
+ - spec/dummy/config/database.yml
144
+ - spec/dummy/config/environment.rb
145
+ - spec/dummy/config/environments/development.rb
146
+ - spec/dummy/config/environments/production.rb
147
+ - spec/dummy/config/environments/test.rb
148
+ - spec/dummy/config/initializers/backtrace_silencers.rb
149
+ - spec/dummy/config/initializers/inflections.rb
150
+ - spec/dummy/config/initializers/mime_types.rb
151
+ - spec/dummy/config/initializers/secret_token.rb
152
+ - spec/dummy/config/initializers/session_store.rb
153
+ - spec/dummy/config/initializers/wrap_parameters.rb
154
+ - spec/dummy/config/locales/en.yml
155
+ - spec/dummy/config/routes.rb
156
+ - spec/dummy/config.ru
157
+ - spec/dummy/db/test.sqlite3
158
+ - spec/dummy/log/development.log
159
+ - spec/dummy/log/test.log
160
+ - spec/dummy/public/404.html
161
+ - spec/dummy/public/422.html
162
+ - spec/dummy/public/500.html
163
+ - spec/dummy/public/favicon.ico
164
+ - spec/dummy/Rakefile
165
+ - spec/dummy/README.rdoc
166
+ - spec/dummy/script/rails
167
+ - spec/short_circuit/presentable_spec.rb
168
+ - spec/spec_helper.rb