soulless 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +8 -1
  3. data/Gemfile +15 -7
  4. data/README.md +223 -31
  5. data/lib/soulless/associations.rb +27 -0
  6. data/lib/soulless/locale/en.yml +30 -0
  7. data/lib/soulless/model.rb +8 -1
  8. data/lib/soulless/validations/associated_validator.rb +17 -0
  9. data/lib/soulless/validations/uniqueness_validator.rb +38 -0
  10. data/lib/soulless/validations.rb +10 -0
  11. data/lib/soulless/version.rb +1 -1
  12. data/lib/soulless.rb +10 -0
  13. data/soulless.gemspec +4 -2
  14. data/spec/associated_validator_spec.rb +31 -0
  15. data/spec/associations_spec.rb +45 -0
  16. data/spec/dummy/.gitignore +17 -0
  17. data/spec/dummy/README.rdoc +28 -0
  18. data/spec/dummy/Rakefile +6 -0
  19. data/spec/dummy/app/assets/images/.keep +0 -0
  20. data/spec/dummy/app/assets/javascripts/application.js +16 -0
  21. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  22. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  23. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  24. data/spec/dummy/app/forms/dummy_form.rb +7 -0
  25. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  26. data/spec/dummy/app/mailers/.keep +0 -0
  27. data/spec/dummy/app/models/.keep +0 -0
  28. data/spec/dummy/app/models/concerns/.keep +0 -0
  29. data/spec/dummy/app/models/dummy_model.rb +3 -0
  30. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  31. data/spec/dummy/bin/bundle +3 -0
  32. data/spec/dummy/bin/rails +4 -0
  33. data/spec/dummy/bin/rake +4 -0
  34. data/spec/dummy/config/application.rb +28 -0
  35. data/spec/dummy/config/boot.rb +6 -0
  36. data/spec/dummy/config/database.yml +25 -0
  37. data/spec/dummy/config/environment.rb +5 -0
  38. data/spec/dummy/config/environments/development.rb +29 -0
  39. data/spec/dummy/config/environments/production.rb +80 -0
  40. data/spec/dummy/config/environments/test.rb +36 -0
  41. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  42. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  43. data/spec/dummy/config/initializers/inflections.rb +16 -0
  44. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  45. data/spec/dummy/config/initializers/secret_token.rb +12 -0
  46. data/spec/dummy/config/initializers/session_store.rb +3 -0
  47. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  48. data/spec/dummy/config/locales/en.yml +23 -0
  49. data/spec/dummy/config/routes.rb +56 -0
  50. data/spec/dummy/config.ru +4 -0
  51. data/spec/dummy/db/migrate/20131106221200_create_dummy_models.rb +9 -0
  52. data/spec/dummy/db/schema.rb +22 -0
  53. data/spec/dummy/db/seeds.rb +7 -0
  54. data/spec/dummy/db/test.sqlite3 +0 -0
  55. data/spec/dummy/lib/assets/.keep +0 -0
  56. data/spec/dummy/lib/tasks/.keep +0 -0
  57. data/spec/dummy/log/.keep +0 -0
  58. data/spec/dummy/public/404.html +58 -0
  59. data/spec/dummy/public/422.html +58 -0
  60. data/spec/dummy/public/500.html +57 -0
  61. data/spec/dummy/public/favicon.ico +0 -0
  62. data/spec/dummy/public/robots.txt +5 -0
  63. data/spec/dummy/vendor/assets/javascripts/.keep +0 -0
  64. data/spec/dummy/vendor/assets/stylesheets/.keep +0 -0
  65. data/spec/soulless_spec.rb +1 -1
  66. data/spec/spec_helper.rb +22 -3
  67. data/spec/support/dummy_association.rb +30 -0
  68. data/spec/support/en.yml +8 -0
  69. data/spec/uniqueness_validator_spec.rb +17 -0
  70. metadata +148 -7
@@ -0,0 +1,58 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/422.html -->
52
+ <div class="dialog">
53
+ <h1>The change you wanted was rejected.</h1>
54
+ <p>Maybe you tried to change something you didn't have access to.</p>
55
+ </div>
56
+ <p>If you are the application owner check the logs for more information.</p>
57
+ </body>
58
+ </html>
@@ -0,0 +1,57 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/500.html -->
52
+ <div class="dialog">
53
+ <h1>We're sorry, but something went wrong.</h1>
54
+ </div>
55
+ <p>If you are the application owner check the logs for more information.</p>
56
+ </body>
57
+ </html>
File without changes
@@ -0,0 +1,5 @@
1
+ # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
2
+ #
3
+ # To ban all spiders from the entire site uncomment the next two lines:
4
+ # User-agent: *
5
+ # Disallow: /
File without changes
File without changes
@@ -26,7 +26,7 @@ describe Soulless do
26
26
  @dummy_class.update_attributes(name: 'Yaw', email: 'yokoono@thebeatles.com')
27
27
  @dummy_class.name.should == 'Yaw'
28
28
  @dummy_class.email.should == 'yokoono@thebeatles.com'
29
- @dummy_class.saved.should be_true
29
+ @dummy_class.saved?.should be_true
30
30
  end
31
31
 
32
32
  it '#persisted? should be false' do
data/spec/spec_helper.rb CHANGED
@@ -1,8 +1,27 @@
1
- require 'coveralls'
2
- Coveralls.wear!
1
+ #require 'coveralls'
2
+ #Coveralls.wear!
3
+
4
+ require File.expand_path("../../spec/dummy/config/environment", __FILE__)
3
5
 
4
6
  require 'soulless'
7
+ require 'database_cleaner'
5
8
 
6
9
  # Require supporting ruby files with custom matchers and macros, etc,
7
10
  # in spec/support/ and its subdirectories.
8
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| puts f; require f }
11
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
12
+
13
+ RSpec.configure do |config|
14
+ DatabaseCleaner.strategy = :transaction
15
+
16
+ config.before :suite do
17
+ DatabaseCleaner.clean_with :truncation
18
+ end
19
+
20
+ config.before :each do
21
+ DatabaseCleaner.start
22
+ end
23
+
24
+ config.after :each do
25
+ DatabaseCleaner.clean
26
+ end
27
+ end
@@ -0,0 +1,30 @@
1
+ require File.dirname(__FILE__) + '/dummy_class'
2
+
3
+ class DummyAssociation
4
+ include Soulless.model
5
+
6
+ attribute :saved, Boolean, default: false
7
+
8
+ has_one :spouse do
9
+ attribute :name, String
10
+
11
+ validates :name, presence: true
12
+ end
13
+
14
+ has_many :friends do
15
+ attribute :name, String
16
+
17
+ validates :name, presence: true
18
+ end
19
+
20
+ has_one :dummy_clone, DummyClass
21
+
22
+ has_many :dummy_clones, DummyClass
23
+
24
+ validates_associated :spouse, :friends
25
+
26
+ private
27
+ def persist!
28
+ self.saved = true
29
+ end
30
+ end
@@ -0,0 +1,8 @@
1
+ en:
2
+ soulless:
3
+ errors:
4
+ models:
5
+ dummy_association/dummy_clone:
6
+ attributes:
7
+ name:
8
+ blank: this is a test
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe Soulless::Validations::UniquenessValidator do
4
+ it 'should validate uniqueness on model' do
5
+ DummyModel.create!(name: 'Anthony')
6
+ model = DummyModel.new(name: 'Anthony')
7
+ model.valid?.should be_false
8
+ model.errors[:name].should include('has already been taken')
9
+ end
10
+
11
+ it 'should validate uniqueness on form' do
12
+ DummyModel.create!(name: 'Anthony')
13
+ form = DummyForm.new(name: 'Anthony')
14
+ form.valid?.should be_false
15
+ form.errors[:name].should include('has already been taken')
16
+ end
17
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: soulless
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anthony Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-30 00:00:00.000000000 Z
11
+ date: 2013-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -56,16 +56,30 @@ dependencies:
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
60
67
  - !ruby/object:Gem::Version
61
- version: '1.3'
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: database_cleaner
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
- - - ~>
80
+ - - '>='
67
81
  - !ruby/object:Gem::Version
68
- version: '1.3'
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: rake
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -80,7 +94,21 @@ dependencies:
80
94
  - - '>='
81
95
  - !ruby/object:Gem::Version
82
96
  version: '0'
83
- description: Models without a soul.
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: Rails models without a database (and Rails).
84
112
  email:
85
113
  - anthony@sticksnleaves.com
86
114
  executables: []
@@ -94,12 +122,71 @@ files:
94
122
  - README.md
95
123
  - Rakefile
96
124
  - lib/soulless.rb
125
+ - lib/soulless/associations.rb
126
+ - lib/soulless/locale/en.yml
97
127
  - lib/soulless/model.rb
128
+ - lib/soulless/validations.rb
129
+ - lib/soulless/validations/associated_validator.rb
130
+ - lib/soulless/validations/uniqueness_validator.rb
98
131
  - lib/soulless/version.rb
99
132
  - soulless.gemspec
133
+ - spec/associated_validator_spec.rb
134
+ - spec/associations_spec.rb
135
+ - spec/dummy/.gitignore
136
+ - spec/dummy/README.rdoc
137
+ - spec/dummy/Rakefile
138
+ - spec/dummy/app/assets/images/.keep
139
+ - spec/dummy/app/assets/javascripts/application.js
140
+ - spec/dummy/app/assets/stylesheets/application.css
141
+ - spec/dummy/app/controllers/application_controller.rb
142
+ - spec/dummy/app/controllers/concerns/.keep
143
+ - spec/dummy/app/forms/dummy_form.rb
144
+ - spec/dummy/app/helpers/application_helper.rb
145
+ - spec/dummy/app/mailers/.keep
146
+ - spec/dummy/app/models/.keep
147
+ - spec/dummy/app/models/concerns/.keep
148
+ - spec/dummy/app/models/dummy_model.rb
149
+ - spec/dummy/app/views/layouts/application.html.erb
150
+ - spec/dummy/bin/bundle
151
+ - spec/dummy/bin/rails
152
+ - spec/dummy/bin/rake
153
+ - spec/dummy/config.ru
154
+ - spec/dummy/config/application.rb
155
+ - spec/dummy/config/boot.rb
156
+ - spec/dummy/config/database.yml
157
+ - spec/dummy/config/environment.rb
158
+ - spec/dummy/config/environments/development.rb
159
+ - spec/dummy/config/environments/production.rb
160
+ - spec/dummy/config/environments/test.rb
161
+ - spec/dummy/config/initializers/backtrace_silencers.rb
162
+ - spec/dummy/config/initializers/filter_parameter_logging.rb
163
+ - spec/dummy/config/initializers/inflections.rb
164
+ - spec/dummy/config/initializers/mime_types.rb
165
+ - spec/dummy/config/initializers/secret_token.rb
166
+ - spec/dummy/config/initializers/session_store.rb
167
+ - spec/dummy/config/initializers/wrap_parameters.rb
168
+ - spec/dummy/config/locales/en.yml
169
+ - spec/dummy/config/routes.rb
170
+ - spec/dummy/db/migrate/20131106221200_create_dummy_models.rb
171
+ - spec/dummy/db/schema.rb
172
+ - spec/dummy/db/seeds.rb
173
+ - spec/dummy/db/test.sqlite3
174
+ - spec/dummy/lib/assets/.keep
175
+ - spec/dummy/lib/tasks/.keep
176
+ - spec/dummy/log/.keep
177
+ - spec/dummy/public/404.html
178
+ - spec/dummy/public/422.html
179
+ - spec/dummy/public/500.html
180
+ - spec/dummy/public/favicon.ico
181
+ - spec/dummy/public/robots.txt
182
+ - spec/dummy/vendor/assets/javascripts/.keep
183
+ - spec/dummy/vendor/assets/stylesheets/.keep
100
184
  - spec/soulless_spec.rb
101
185
  - spec/spec_helper.rb
186
+ - spec/support/dummy_association.rb
102
187
  - spec/support/dummy_class.rb
188
+ - spec/support/en.yml
189
+ - spec/uniqueness_validator_spec.rb
103
190
  homepage: ''
104
191
  licenses:
105
192
  - MIT
@@ -125,6 +212,60 @@ signing_key:
125
212
  specification_version: 4
126
213
  summary: Create Rails style models without the database.
127
214
  test_files:
215
+ - spec/associated_validator_spec.rb
216
+ - spec/associations_spec.rb
217
+ - spec/dummy/.gitignore
218
+ - spec/dummy/README.rdoc
219
+ - spec/dummy/Rakefile
220
+ - spec/dummy/app/assets/images/.keep
221
+ - spec/dummy/app/assets/javascripts/application.js
222
+ - spec/dummy/app/assets/stylesheets/application.css
223
+ - spec/dummy/app/controllers/application_controller.rb
224
+ - spec/dummy/app/controllers/concerns/.keep
225
+ - spec/dummy/app/forms/dummy_form.rb
226
+ - spec/dummy/app/helpers/application_helper.rb
227
+ - spec/dummy/app/mailers/.keep
228
+ - spec/dummy/app/models/.keep
229
+ - spec/dummy/app/models/concerns/.keep
230
+ - spec/dummy/app/models/dummy_model.rb
231
+ - spec/dummy/app/views/layouts/application.html.erb
232
+ - spec/dummy/bin/bundle
233
+ - spec/dummy/bin/rails
234
+ - spec/dummy/bin/rake
235
+ - spec/dummy/config.ru
236
+ - spec/dummy/config/application.rb
237
+ - spec/dummy/config/boot.rb
238
+ - spec/dummy/config/database.yml
239
+ - spec/dummy/config/environment.rb
240
+ - spec/dummy/config/environments/development.rb
241
+ - spec/dummy/config/environments/production.rb
242
+ - spec/dummy/config/environments/test.rb
243
+ - spec/dummy/config/initializers/backtrace_silencers.rb
244
+ - spec/dummy/config/initializers/filter_parameter_logging.rb
245
+ - spec/dummy/config/initializers/inflections.rb
246
+ - spec/dummy/config/initializers/mime_types.rb
247
+ - spec/dummy/config/initializers/secret_token.rb
248
+ - spec/dummy/config/initializers/session_store.rb
249
+ - spec/dummy/config/initializers/wrap_parameters.rb
250
+ - spec/dummy/config/locales/en.yml
251
+ - spec/dummy/config/routes.rb
252
+ - spec/dummy/db/migrate/20131106221200_create_dummy_models.rb
253
+ - spec/dummy/db/schema.rb
254
+ - spec/dummy/db/seeds.rb
255
+ - spec/dummy/db/test.sqlite3
256
+ - spec/dummy/lib/assets/.keep
257
+ - spec/dummy/lib/tasks/.keep
258
+ - spec/dummy/log/.keep
259
+ - spec/dummy/public/404.html
260
+ - spec/dummy/public/422.html
261
+ - spec/dummy/public/500.html
262
+ - spec/dummy/public/favicon.ico
263
+ - spec/dummy/public/robots.txt
264
+ - spec/dummy/vendor/assets/javascripts/.keep
265
+ - spec/dummy/vendor/assets/stylesheets/.keep
128
266
  - spec/soulless_spec.rb
129
267
  - spec/spec_helper.rb
268
+ - spec/support/dummy_association.rb
130
269
  - spec/support/dummy_class.rb
270
+ - spec/support/en.yml
271
+ - spec/uniqueness_validator_spec.rb