findable 0.1.3 → 0.1.4
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/Gemfile +0 -1
- data/README.md +0 -1
- data/Rakefile +0 -1
- data/findable.gemspec +0 -1
- data/lib/findable.rb +0 -1
- data/lib/findable/associations.rb +0 -1
- data/lib/findable/associations/active_record_ext.rb +0 -1
- data/lib/findable/associations/utils.rb +0 -1
- data/lib/findable/base.rb +2 -1
- data/lib/findable/configuration.rb +0 -1
- data/lib/findable/errors.rb +0 -1
- data/lib/findable/inspection.rb +18 -0
- data/lib/findable/query.rb +0 -1
- data/lib/findable/query/connection.rb +0 -1
- data/lib/findable/query/lock.rb +0 -1
- data/lib/findable/query/namespace.rb +0 -1
- data/lib/findable/railtie.rb +0 -1
- data/lib/findable/seed.rb +0 -1
- data/lib/findable/version.rb +1 -2
- data/lib/generators/findable/install_generator.rb +0 -1
- data/lib/generators/findable/templates/findable.rb +0 -1
- data/lib/generators/findable/templates/seeds.rb +0 -1
- data/lib/tasks/findable.rake +0 -1
- data/spec/active_model_lint_spec.rb +0 -1
- data/spec/findable/associations/active_record_ext_spec.rb +0 -1
- data/spec/findable/associations/utils_spec.rb +0 -1
- data/spec/findable/associations_spec.rb +0 -1
- data/spec/findable/base_spec.rb +62 -1
- data/spec/findable/configuration_spec.rb +0 -1
- data/spec/findable/errors_spec.rb +0 -1
- data/spec/findable/query/connection_spec.rb +0 -1
- data/spec/findable/query/namespace_spec.rb +0 -1
- data/spec/findable/query_spec.rb +0 -1
- data/spec/spec_helper.rb +0 -1
- data/spec/support/initialize_database.rb +0 -1
- data/spec/support/shared_contexts.rb +0 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33cc41223d03de05c7983ae227f66bb4ee36d833
|
4
|
+
data.tar.gz: 2908c96f0a953f76a78d65bd9f12c8c0fb252c6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1260e9d9d210ef7ebfc40401c4d85b4cc7315407b76b53fc36e7dc73b34af976449a40222c428c96c52f7c2ecb5bd5ff10ebed629024dcb64be38fe1cb820f3
|
7
|
+
data.tar.gz: d1740da9cb2b9b14e2ed18b150814502d3c275c253cd2970d6db478a7d74944d25a3bc53a4c4b8cd8060843d046fcda5fea71655d80b0110bc6d77e29464b8af
|
data/Gemfile
CHANGED
data/README.md
CHANGED
data/Rakefile
CHANGED
data/findable.gemspec
CHANGED
data/lib/findable.rb
CHANGED
data/lib/findable/base.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "findable/associations"
|
2
|
+
require "findable/inspection"
|
2
3
|
|
3
4
|
module Findable
|
4
5
|
class Base
|
@@ -6,6 +7,7 @@ module Findable
|
|
6
7
|
include ActiveModel::AttributeMethods
|
7
8
|
|
8
9
|
include Associations
|
10
|
+
include Inspection
|
9
11
|
|
10
12
|
attribute_method_suffix "="
|
11
13
|
attribute_method_suffix "?"
|
@@ -191,4 +193,3 @@ module Findable
|
|
191
193
|
end
|
192
194
|
end
|
193
195
|
end
|
194
|
-
|
data/lib/findable/errors.rb
CHANGED
@@ -0,0 +1,18 @@
|
|
1
|
+
module Findable
|
2
|
+
module Inspection
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
module ClassMethods
|
6
|
+
def inspect
|
7
|
+
"#{self}(#{column_names.map(&:inspect).join(', ')})"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def inspect
|
12
|
+
_attributes = self.class.column_names.each_with_object([]) {|name, obj|
|
13
|
+
obj << "#{name}: #{public_send(name).inspect}"
|
14
|
+
}.join(",\s")
|
15
|
+
"#<#{self.class} #{_attributes}>"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/findable/query.rb
CHANGED
data/lib/findable/query/lock.rb
CHANGED
data/lib/findable/railtie.rb
CHANGED
data/lib/findable/seed.rb
CHANGED
data/lib/findable/version.rb
CHANGED
data/lib/tasks/findable.rake
CHANGED
data/spec/findable/base_spec.rb
CHANGED
@@ -71,5 +71,66 @@ describe Findable::Base do
|
|
71
71
|
}
|
72
72
|
it { expect(model).to respond_to(:create!) }
|
73
73
|
end
|
74
|
-
end
|
75
74
|
|
75
|
+
# Query APIs
|
76
|
+
describe ".exists?" do
|
77
|
+
let!(:persisted_object) { model.create(name: name) }
|
78
|
+
|
79
|
+
it { expect(model.exists?(persisted_object)).to be_truthy }
|
80
|
+
it { expect(model.exists?(persisted_object.id)).to be_truthy }
|
81
|
+
it { expect(model.exists?(nil)).to be_falsey }
|
82
|
+
end
|
83
|
+
|
84
|
+
describe ".insert" do
|
85
|
+
let(:new_object) { model.new(name: name) }
|
86
|
+
|
87
|
+
it {
|
88
|
+
expect {
|
89
|
+
model.insert(new_object)
|
90
|
+
}.to change { model.query.count }.by(1)
|
91
|
+
}
|
92
|
+
end
|
93
|
+
|
94
|
+
describe ".delete" do
|
95
|
+
let!(:persisted_object) { model.create(name: name) }
|
96
|
+
|
97
|
+
it {
|
98
|
+
expect {
|
99
|
+
model.delete(persisted_object)
|
100
|
+
}.to change { model.query.count }.by(-1)
|
101
|
+
}
|
102
|
+
end
|
103
|
+
|
104
|
+
# Instance methods
|
105
|
+
describe "#id=" do
|
106
|
+
it {
|
107
|
+
instance.id = id
|
108
|
+
expect(instance.attributes[:id]).to eq(id)
|
109
|
+
}
|
110
|
+
end
|
111
|
+
|
112
|
+
describe "#hash" do
|
113
|
+
let!(:persisted_object) { model.create(name: name) }
|
114
|
+
it { expect(persisted_object.hash).to eq(persisted_object.id.hash) }
|
115
|
+
end
|
116
|
+
|
117
|
+
describe "#delete" do
|
118
|
+
let!(:persisted_object) { model.create(name: name) }
|
119
|
+
it {
|
120
|
+
expect {
|
121
|
+
persisted_object.delete
|
122
|
+
}.to change { model.query.count }.by(-1)
|
123
|
+
}
|
124
|
+
end
|
125
|
+
|
126
|
+
# Private instance methods
|
127
|
+
describe "#attribute=" do
|
128
|
+
before { instance.send(:attribute=, :example, "value") }
|
129
|
+
it { expect(instance.attributes[:example]).to eq("value") }
|
130
|
+
end
|
131
|
+
|
132
|
+
describe "#attribute?" do
|
133
|
+
before { instance.send(:attribute=, :example, "value") }
|
134
|
+
it { expect(instance.send(:attribute?, :example)).to be_truthy }
|
135
|
+
end
|
136
|
+
end
|
data/spec/findable/query_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: findable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- i2bskn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -201,6 +201,7 @@ files:
|
|
201
201
|
- lib/findable/base.rb
|
202
202
|
- lib/findable/configuration.rb
|
203
203
|
- lib/findable/errors.rb
|
204
|
+
- lib/findable/inspection.rb
|
204
205
|
- lib/findable/query.rb
|
205
206
|
- lib/findable/query/connection.rb
|
206
207
|
- lib/findable/query/lock.rb
|