findable 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +0 -1
  3. data/README.md +0 -1
  4. data/Rakefile +0 -1
  5. data/findable.gemspec +0 -1
  6. data/lib/findable.rb +0 -1
  7. data/lib/findable/associations.rb +0 -1
  8. data/lib/findable/associations/active_record_ext.rb +0 -1
  9. data/lib/findable/associations/utils.rb +0 -1
  10. data/lib/findable/base.rb +2 -1
  11. data/lib/findable/configuration.rb +0 -1
  12. data/lib/findable/errors.rb +0 -1
  13. data/lib/findable/inspection.rb +18 -0
  14. data/lib/findable/query.rb +0 -1
  15. data/lib/findable/query/connection.rb +0 -1
  16. data/lib/findable/query/lock.rb +0 -1
  17. data/lib/findable/query/namespace.rb +0 -1
  18. data/lib/findable/railtie.rb +0 -1
  19. data/lib/findable/seed.rb +0 -1
  20. data/lib/findable/version.rb +1 -2
  21. data/lib/generators/findable/install_generator.rb +0 -1
  22. data/lib/generators/findable/templates/findable.rb +0 -1
  23. data/lib/generators/findable/templates/seeds.rb +0 -1
  24. data/lib/tasks/findable.rake +0 -1
  25. data/spec/active_model_lint_spec.rb +0 -1
  26. data/spec/findable/associations/active_record_ext_spec.rb +0 -1
  27. data/spec/findable/associations/utils_spec.rb +0 -1
  28. data/spec/findable/associations_spec.rb +0 -1
  29. data/spec/findable/base_spec.rb +62 -1
  30. data/spec/findable/configuration_spec.rb +0 -1
  31. data/spec/findable/errors_spec.rb +0 -1
  32. data/spec/findable/query/connection_spec.rb +0 -1
  33. data/spec/findable/query/namespace_spec.rb +0 -1
  34. data/spec/findable/query_spec.rb +0 -1
  35. data/spec/spec_helper.rb +0 -1
  36. data/spec/support/initialize_database.rb +0 -1
  37. data/spec/support/shared_contexts.rb +0 -1
  38. metadata +3 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5acbf80fe3312739785d49f99f8ac35def1d609b
4
- data.tar.gz: 33e9bdf426eafc58df1082cf2b314a0330dfd40c
3
+ metadata.gz: 33cc41223d03de05c7983ae227f66bb4ee36d833
4
+ data.tar.gz: 2908c96f0a953f76a78d65bd9f12c8c0fb252c6a
5
5
  SHA512:
6
- metadata.gz: 564d8b363811d9fa14463bf91307962c2321a60e77e6de64b97b399625ef9fdc596fa5eacdfad09b5a79aa04adcb1b6941a4aa54cea46f90a0d89d8c93346c14
7
- data.tar.gz: 158f1fdb607ed207d10c801f992e33dc60cbd35f0432472f558dd95d25d3aea8341db334123c61e03afa28e4b5bea5b903ab8b7932eb4e50508971ac43beec7c
6
+ metadata.gz: b1260e9d9d210ef7ebfc40401c4d85b4cc7315407b76b53fc36e7dc73b34af976449a40222c428c96c52f7c2ecb5bd5ff10ebed629024dcb64be38fe1cb820f3
7
+ data.tar.gz: d1740da9cb2b9b14e2ed18b150814502d3c275c253cd2970d6db478a7d74944d25a3bc53a4c4b8cd8060843d046fcda5fea71655d80b0110bc6d77e29464b8af
data/Gemfile CHANGED
@@ -1,4 +1,3 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
-
data/README.md CHANGED
@@ -104,4 +104,3 @@ end
104
104
  3. Commit your changes (`git commit -am 'Add some feature'`)
105
105
  4. Push to the branch (`git push origin my-new-feature`)
106
106
  5. Create a new Pull Request
107
-
data/Rakefile CHANGED
@@ -12,4 +12,3 @@ desc "Console with library"
12
12
  task :console do
13
13
  sh "pry -I lib -r bundler/setup -r findable"
14
14
  end
15
-
@@ -32,4 +32,3 @@ Gem::Specification.new do |spec|
32
32
  spec.add_development_dependency "coveralls"
33
33
  spec.add_development_dependency "simplecov"
34
34
  end
35
-
@@ -10,4 +10,3 @@ require "findable/configuration"
10
10
  require "findable/query"
11
11
  require "findable/base"
12
12
  require "findable/railtie" if defined?(Rails)
13
-
@@ -49,4 +49,3 @@ module Findable
49
49
  end
50
50
  end
51
51
  end
52
-
@@ -63,4 +63,3 @@ module Findable
63
63
  end
64
64
  end
65
65
  end
66
-
@@ -33,4 +33,3 @@ module Findable
33
33
  end
34
34
  end
35
35
  end
36
-
@@ -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
-
@@ -45,4 +45,3 @@ module Findable
45
45
 
46
46
  extend Configuration::Accessible
47
47
  end
48
-
@@ -10,4 +10,3 @@ module Findable
10
10
 
11
11
  class LockTimeout < FindableError; end
12
12
  end
13
-
@@ -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
@@ -76,4 +76,3 @@ module Findable
76
76
  end
77
77
  end
78
78
  end
79
-
@@ -23,4 +23,3 @@ module Findable
23
23
  end
24
24
  end
25
25
  end
26
-
@@ -56,4 +56,3 @@ module Findable
56
56
  end
57
57
  end
58
58
  end
59
-
@@ -31,4 +31,3 @@ module Findable
31
31
  end
32
32
  end
33
33
  end
34
-
@@ -11,4 +11,3 @@ module Findable
11
11
  end
12
12
  end
13
13
  end
14
-
@@ -54,4 +54,3 @@ module Findable
54
54
  end
55
55
  end
56
56
  end
57
-
@@ -1,4 +1,3 @@
1
1
  module Findable
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
4
-
@@ -16,4 +16,3 @@ module Findable
16
16
  end
17
17
  end
18
18
  end
19
-
@@ -8,4 +8,3 @@ Findable.configure do |config|
8
8
  # Seed file of Findable.
9
9
  config.seed_file = Rails.root.join("db", "findable_seeds.rb")
10
10
  end
11
-
@@ -11,4 +11,3 @@ seed_files = nil
11
11
 
12
12
  # Execute
13
13
  Findable::Seed.target_files(seed_files: seed_files).each {|seed| seed.bootstrap! }
14
-
@@ -6,4 +6,3 @@ namespace :findable do
6
6
  end
7
7
  end
8
8
  end
9
-
@@ -69,4 +69,3 @@ describe ActiveModel::Lint::Tests do
69
69
  end
70
70
  end
71
71
  end
72
-
@@ -27,4 +27,3 @@ describe Findable::Associations::ActiveRecordExt do
27
27
  }
28
28
  end
29
29
  end
30
-
@@ -29,4 +29,3 @@ describe Findable::Associations::Utils do
29
29
  }
30
30
  end
31
31
  end
32
-
@@ -31,4 +31,3 @@ describe Findable::Associations do
31
31
  }
32
32
  end
33
33
  end
34
-
@@ -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
@@ -64,4 +64,3 @@ describe Findable::Configuration do
64
64
  end
65
65
  end
66
66
  end
67
-
@@ -14,4 +14,3 @@ describe "Errors" do
14
14
  it { expect(error.message).to match(Regexp.new({id: 1}.inspect)) }
15
15
  end
16
16
  end
17
-
@@ -61,4 +61,3 @@ describe Findable::Query::Connection do
61
61
  end
62
62
  end
63
63
  end
64
-
@@ -49,4 +49,3 @@ describe Findable::Query::Namespace do
49
49
  }
50
50
  end
51
51
  end
52
-
@@ -99,4 +99,3 @@ describe Findable::Query do
99
99
  end
100
100
  end
101
101
  end
102
-
@@ -27,4 +27,3 @@ RSpec.configure do |config|
27
27
  config.order = :random
28
28
  config.after(:each) { Findable.config.reset }
29
29
  end
30
-
@@ -104,4 +104,3 @@ Store.create(id: 1, name: "store 1", company_id: 1)
104
104
  Email.create!(id: 1, address: "findable@example.com", store_id: 1, user_id: 1)
105
105
  Picture.create!(id: 1, name: "picture 1", user_id: 1)
106
106
  Picture.create!(id: 2, name: "picture 2", user_id: 1)
107
-
@@ -13,4 +13,3 @@ shared_context "ReadOnlyModel" do
13
13
  let(:name) { CategoryData.first[:name] }
14
14
  let(:invalid_name) { "invalid" }
15
15
  end
16
-
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.3
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-06-25 00:00:00.000000000 Z
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