soulless 0.6.0 → 1.0.0
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.
- checksums.yaml +4 -4
- data/.gitignore +12 -18
- data/.rspec +1 -1
- data/.travis.yml +7 -12
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +17 -13
- data/LICENSE.txt +17 -18
- data/README.md +8 -181
- data/Rakefile +4 -8
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/docker-compose.yml +11 -0
- data/lib/soulless/attributes.rb +33 -0
- data/lib/soulless/callbacks.rb +13 -0
- data/lib/soulless/dirty.rb +10 -8
- data/lib/soulless/inheritance.rb +120 -124
- data/lib/soulless/model.rb +24 -63
- data/lib/soulless/validations/uniqueness_validator.rb +7 -8
- data/lib/soulless/validations.rb +1 -2
- data/lib/soulless/version.rb +1 -1
- data/lib/soulless.rb +5 -23
- data/soulless.gemspec +12 -13
- metadata +30 -173
- data/lib/soulless/accessors.rb +0 -51
- data/lib/soulless/associations.rb +0 -35
- data/lib/soulless/locale/en.yml +0 -30
- data/lib/soulless/railtie.rb +0 -7
- data/lib/soulless/validations/associated_validator.rb +0 -17
- data/spec/associated_validator_spec.rb +0 -31
- data/spec/associations_spec.rb +0 -65
- data/spec/dirty_spec.rb +0 -54
- data/spec/dummy/.gitignore +0 -17
- data/spec/dummy/README.rdoc +0 -28
- data/spec/dummy/Rakefile +0 -6
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +0 -16
- data/spec/dummy/app/assets/stylesheets/application.css +0 -13
- data/spec/dummy/app/controllers/application_controller.rb +0 -5
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/forms/dummy_form.rb +0 -7
- data/spec/dummy/app/helpers/application_helper.rb +0 -2
- data/spec/dummy/app/mailers/.keep +0 -0
- data/spec/dummy/app/models/.keep +0 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/models/dummy_model.rb +0 -6
- data/spec/dummy/app/views/layouts/application.html.erb +0 -14
- data/spec/dummy/bin/bundle +0 -3
- data/spec/dummy/bin/rails +0 -4
- data/spec/dummy/bin/rake +0 -4
- data/spec/dummy/config/application.rb +0 -28
- data/spec/dummy/config/boot.rb +0 -6
- data/spec/dummy/config/database.yml +0 -25
- data/spec/dummy/config/environment.rb +0 -5
- data/spec/dummy/config/environments/development.rb +0 -29
- data/spec/dummy/config/environments/production.rb +0 -80
- data/spec/dummy/config/environments/test.rb +0 -36
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/spec/dummy/config/initializers/inflections.rb +0 -16
- data/spec/dummy/config/initializers/mime_types.rb +0 -5
- data/spec/dummy/config/initializers/secret_token.rb +0 -12
- data/spec/dummy/config/initializers/session_store.rb +0 -3
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/spec/dummy/config/locales/en.yml +0 -23
- data/spec/dummy/config/routes.rb +0 -56
- data/spec/dummy/config.ru +0 -4
- data/spec/dummy/db/migrate/20131106221200_create_dummy_models.rb +0 -11
- data/spec/dummy/db/schema.rb +0 -24
- data/spec/dummy/db/seeds.rb +0 -7
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/lib/tasks/.keep +0 -0
- data/spec/dummy/log/.keep +0 -0
- data/spec/dummy/public/404.html +0 -58
- data/spec/dummy/public/422.html +0 -58
- data/spec/dummy/public/500.html +0 -57
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/robots.txt +0 -5
- data/spec/dummy/vendor/assets/javascripts/.keep +0 -0
- data/spec/dummy/vendor/assets/stylesheets/.keep +0 -0
- data/spec/inheritance_spec.rb +0 -51
- data/spec/soulless_spec.rb +0 -61
- data/spec/spec_helper.rb +0 -38
- data/spec/support/dummy_association.rb +0 -30
- data/spec/support/dummy_class.rb +0 -20
- data/spec/support/dummy_model_inheritance.rb +0 -10
- data/spec/support/dummy_soulless_inheritance.rb +0 -10
- data/spec/support/en.yml +0 -8
- data/spec/uniqueness_validator_spec.rb +0 -17
data/spec/dummy/public/500.html
DELETED
@@ -1,57 +0,0 @@
|
|
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
|
File without changes
|
File without changes
|
data/spec/inheritance_spec.rb
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Soulless::Inheritance do
|
4
|
-
describe DummyModelInheritance do
|
5
|
-
before(:each) do
|
6
|
-
@dummy_inheritance = DummyModelInheritance.new
|
7
|
-
end
|
8
|
-
|
9
|
-
it 'should inherit the name attribute' do
|
10
|
-
@dummy_inheritance.attributes.keys.should include(:name)
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'should inherit the default value for the name attribute' do
|
14
|
-
@dummy_inheritance.attributes[:name].should == 'Anthony'
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'should not inhert the email attribute when added as exclude option' do
|
18
|
-
@dummy_inheritance.attributes.keys.should_not include(:email)
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'should validate presence of name' do
|
22
|
-
@dummy_inheritance.name = nil
|
23
|
-
@dummy_inheritance.valid?
|
24
|
-
@dummy_inheritance.errors[:name].should include("can't be blank")
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'should not validate email' do
|
28
|
-
@dummy_inheritance.class.validators.each do |validator|
|
29
|
-
validator.attributes.should_not include(:email)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe DummySoullessInheritance do
|
35
|
-
before(:each) do
|
36
|
-
@dummy_inheritance = DummySoullessInheritance.new
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'should inherit the name attribute' do
|
40
|
-
@dummy_inheritance.attributes.keys.should include(:name)
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'should inherit the default value for the name attribute' do
|
44
|
-
@dummy_inheritance.attributes[:name].should == 'Anthony'
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'should not inhert the email attribute when added as exclude option' do
|
48
|
-
@dummy_inheritance.attributes.keys.should_not include(:email)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
data/spec/soulless_spec.rb
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Soulless do
|
4
|
-
before(:each) do
|
5
|
-
@dummy_class = DummyClass.new
|
6
|
-
end
|
7
|
-
|
8
|
-
it 'should validate name' do
|
9
|
-
@dummy_class.name = nil
|
10
|
-
@dummy_class.valid?.should == false
|
11
|
-
expect(@dummy_class.errors[:name]).to_not be_empty
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'should call #persist! when #save is called' do
|
15
|
-
@dummy_class.save
|
16
|
-
expect(@dummy_class.saved).to eq(true)
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'should call #persist! when #update_attributes is called' do
|
20
|
-
@dummy_class.update_attributes(name: 'Biff')
|
21
|
-
expect(@dummy_class.saved).to eq(true)
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'should not call #persist! if attributes are invalid' do
|
25
|
-
@dummy_class.name = nil
|
26
|
-
expect(@dummy_class.save).to eq(false)
|
27
|
-
expect(@dummy_class.saved).to eq(false)
|
28
|
-
end
|
29
|
-
|
30
|
-
it '#update_attributes should not save' do
|
31
|
-
@dummy_class.assign_attributes(name: 'Yaw', email: 'yokoono@thebeatles.com')
|
32
|
-
expect(@dummy_class.saved?).to eq(false)
|
33
|
-
end
|
34
|
-
|
35
|
-
it '#assign_attributes should merge new values' do
|
36
|
-
@dummy_class.email = 'yokoono@thebeatles.com'
|
37
|
-
@dummy_class.assign_attributes(name: 'Yaw')
|
38
|
-
expect(@dummy_class.name).to eq('Yaw')
|
39
|
-
expect(@dummy_class.email).to eq('yokoono@thebeatles.com')
|
40
|
-
end
|
41
|
-
|
42
|
-
it '#assign_attributes should deep merge new values' do
|
43
|
-
@dummy_class = DummyAssociation.new(spouse: { name: 'Megan' })
|
44
|
-
@dummy_class.assign_attributes(spouse: { name: 'Mary Jane Watson' })
|
45
|
-
expect(@dummy_class.spouse.name).to eq('Mary Jane Watson')
|
46
|
-
end
|
47
|
-
|
48
|
-
it '#update_attributes should save' do
|
49
|
-
@dummy_class.update_attributes(name: 'Yaw', email: 'yokoono@thebeatles.com')
|
50
|
-
expect(@dummy_class.saved?).to eq(true)
|
51
|
-
end
|
52
|
-
|
53
|
-
it '#persisted? should be false' do
|
54
|
-
expect(@dummy_class.persisted?).to eq(false)
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'should call the before_validation callback' do
|
58
|
-
@dummy_class.save
|
59
|
-
expect(@dummy_class.validation_callback).to eq(true)
|
60
|
-
end
|
61
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
require 'coveralls'
|
2
|
-
Coveralls.wear!
|
3
|
-
|
4
|
-
require File.expand_path("../../spec/dummy/config/environment", __FILE__)
|
5
|
-
|
6
|
-
require 'soulless'
|
7
|
-
require 'database_cleaner'
|
8
|
-
|
9
|
-
# Require supporting ruby files with custom matchers and macros, etc,
|
10
|
-
# in spec/support/ and its subdirectories.
|
11
|
-
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
12
|
-
|
13
|
-
RSpec.configure do |config|
|
14
|
-
config.mock_with :rspec do |mocks|
|
15
|
-
# Enable only the newer, non-monkey-patching expect syntax.
|
16
|
-
# For more details, see:
|
17
|
-
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
18
|
-
mocks.syntax = :should
|
19
|
-
|
20
|
-
# Prevents you from mocking or stubbing a method that does not exist on
|
21
|
-
# a real object. This is generally recommended.
|
22
|
-
mocks.verify_partial_doubles = true
|
23
|
-
end
|
24
|
-
|
25
|
-
DatabaseCleaner.strategy = :transaction
|
26
|
-
|
27
|
-
config.before :suite do
|
28
|
-
DatabaseCleaner.clean_with :truncation
|
29
|
-
end
|
30
|
-
|
31
|
-
config.before :each do
|
32
|
-
DatabaseCleaner.start
|
33
|
-
end
|
34
|
-
|
35
|
-
config.after :each do
|
36
|
-
DatabaseCleaner.clean
|
37
|
-
end
|
38
|
-
end
|
@@ -1,30 +0,0 @@
|
|
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
|
data/spec/support/dummy_class.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
class DummyClass
|
2
|
-
include Soulless.model
|
3
|
-
|
4
|
-
attribute :name, String, default: 'Anthony'
|
5
|
-
attribute :email, String
|
6
|
-
attribute :validation_callback, Boolean
|
7
|
-
attribute :save_callback, Boolean
|
8
|
-
attribute :saved, Boolean, default: false
|
9
|
-
|
10
|
-
validates :name, presence: true
|
11
|
-
|
12
|
-
before_validation lambda { self.validation_callback = true }
|
13
|
-
|
14
|
-
before_save lambda { self.save_callback = true }
|
15
|
-
|
16
|
-
private
|
17
|
-
def persist!
|
18
|
-
self.saved = true
|
19
|
-
end
|
20
|
-
end
|
data/spec/support/en.yml
DELETED
@@ -1,17 +0,0 @@
|
|
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
|
-
expect(model.valid?).to eq(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
|
-
expect(form.valid?).to eq(false)
|
15
|
-
form.errors[:name].should include('has already been taken')
|
16
|
-
end
|
17
|
-
end
|