skn_utils 1.4.7 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 20f1dd68efa7015aad1fc76fb65f498293e45762
4
- data.tar.gz: 15816e12ebd909d68b5bce157800124b441315a4
3
+ metadata.gz: 0d94d1060b87e0556db8298ed9fb89dda65fa4df
4
+ data.tar.gz: 2ede0cc2dbc2af963436c44c5b181eaa60025fab
5
5
  SHA512:
6
- metadata.gz: 35d8c158a0efd00a2982e6a3cf1754caf6aab827cd77ead895b8a7c8a98722b97d22688a2fdcd9adb51be08a0004288519235e974dda7e805861f883575af6ca
7
- data.tar.gz: bebbecbd967577964006782b769ded1c695226ca87faa97f3ba7eeed6484b98b6379532f461957d1e1f62b5a837012cb6d337bedc325f9b352afa88f4788df2b
6
+ metadata.gz: ad1f469f0eb889515f60bc78afcac37a54a041fec3e778e9e7079908be5e32eb4cc34eacc137b5e7061470a5318b3a87ddf0623b3491379f7ff53bd754b1fb83
7
+ data.tar.gz: 107f849d651e07346ca26f035f91869d44de26c526fa375d97a07fd0c201bb776dd3c4ed3373cce96a5568607db183202bf5112939f3e660e3be75455b5cca4b
data/README.md CHANGED
@@ -221,3 +221,8 @@ $ bundle exec pry
221
221
  3. Commit your changes (`git commit -am 'Add some feature'`)
222
222
  4. Push to the branch (`git push origin my-new-feature`)
223
223
  5. Create a new Pull Request
224
+
225
+
226
+ ## License
227
+
228
+ MIT. See `LICENSE`.
data/README.rdoc CHANGED
@@ -173,13 +173,11 @@ runtime prereqs: gem 'active_model', '~> 3.0'
173
173
 
174
174
  Add this line to your application's Gemfile:
175
175
 
176
- ```ruby
177
- gem 'skn_utils'
178
- ```
176
+ gem 'skn_utils'
179
177
 
180
178
  And then execute:
181
179
 
182
- $ bundle
180
+ $ bundle install
183
181
 
184
182
  Or install it yourself as:
185
183
 
@@ -200,18 +198,18 @@ Or install it yourself as:
200
198
 
201
199
  Start with building gem first.
202
200
  ```bash
203
- $ cd skn_utils
204
- $ bundle exec pry
205
- [1] pry(main)> require 'active_model'
206
- [2] pry(main)> require 'skn_utils'
207
- [3] pry(main)> rb = SknUtils::ResultBean.new({sample: [{one: "one", two: "two"},{one: 1, two: 2}] })
208
- [4] pry(main)> pg = SknUtils::PageControls.new({sample: [{one: "one", two: "two"},{one: 1, two: 2}] })
209
- [5] pry(main)> pg.sample.first.one # Tip :multi_with_arrays
210
- [6] pry(main)> rb.sample.first.one # Tip :multi without arrays you will get a NoMethodError
211
- [7] pry(main)> rb.sample.first[:one]
212
-
213
- [n] pry(main)> exit
214
- * Done
201
+ $ cd skn_utils
202
+ $ bundle exec pry
203
+ [1] pry(main)> require 'active_model'
204
+ [2] pry(main)> require 'skn_utils'
205
+ [3] pry(main)> rb = SknUtils::ResultBean.new({sample: [{one: "one", two: "two"},{one: 1, two: 2}] })
206
+ [4] pry(main)> pg = SknUtils::PageControls.new({sample: [{one: "one", two: "two"},{one: 1, two: 2}] })
207
+ [5] pry(main)> pg.sample.first.one # Tip :multi_with_arrays
208
+ [6] pry(main)> rb.sample.first.one # Tip :multi without arrays you will get a NoMethodError
209
+ [7] pry(main)> rb.sample.first[:one]
210
+ ...
211
+ [n] pry(main)> exit
212
+ * Done
215
213
  ```
216
214
 
217
215
  == Contributing
@@ -221,3 +219,8 @@ $ bundle exec pry
221
219
  3. Commit your changes (`git commit -am 'Add some feature'`)
222
220
  4. Push to the branch (`git push origin my-new-feature`)
223
221
  5. Create a new Pull Request
222
+
223
+
224
+ == License
225
+
226
+ MIT. See `LICENSE`.
@@ -70,14 +70,25 @@ module SknUtils
70
70
  ##
71
71
  # DO NOT ADD METHODS BELOW THIS LINE, unless you want them to be private
72
72
  ##
73
- private
74
73
 
74
+ # Support the regular respond_to? method by
75
+ # answering for any attr that method missing actually handle
75
76
  #:nodoc:
77
+ def respond_to_missing?(method, incl_private=false)
78
+ instance_variable_names.include?("@#{method.to_s}")
79
+ end
80
+
81
+ private
82
+
83
+ # Deals with the true presence of a attribute and then its non-blank and empty value
84
+ # - attribute must exist and have a non-blank value to cause this method to return true
85
+ #:nodoc:
76
86
  def attribute?(attr)
77
- if attr.is_a? Symbol
78
- send(attr).present?
87
+ return false unless instance_variable_names.include?("@#{attr.to_s}")
88
+ if attr.is_a? Symbol
89
+ ![ "", " ", nil, [],[""], [" "], {} ].include?( send(attr) )
79
90
  else
80
- send(attr.to_sym).present?
91
+ ![ "", " ", nil, [],[""], [" "], {} ].include?( send(attr.to_sym) )
81
92
  end
82
93
  end
83
94
 
@@ -234,5 +234,7 @@ module SknUtils
234
234
  end
235
235
  formatted_key
236
236
  end
237
+
238
+
237
239
  end
238
240
  end
@@ -1,3 +1,3 @@
1
1
  module SknUtils
2
- VERSION = "1.4.7"
2
+ VERSION = "1.5.0"
3
3
  end
@@ -38,8 +38,8 @@ RSpec.describe SknUtils::GenericBean, "Generic Marshal'able Bean class " do
38
38
  expect { obj1.three }.to raise_error NoMethodError
39
39
  expect { obj2.one }.to raise_error NoMethodError
40
40
  end
41
- it "Does not support - respond_to - methods, because it has no accessor methods" do
42
- expect(object).not_to respond_to(:one)
41
+ it "Supports - respond_to? - method, because it has accessors or method_missing coverage" do
42
+ expect(object).to respond_to(:one)
43
43
  expect(object.one).to eql "one"
44
44
  end
45
45
  it "nest objects if multi-level hash is given" do
@@ -49,9 +49,10 @@ RSpec.describe SknUtils::PageControls, "PageControls Marshal'able Bean class " d
49
49
  it "Supports predicates(?)" do
50
50
  expect(object.one?).to be true
51
51
  expect(object.three.five?).to be true
52
+ expect(object.fourtyfive?).to be false
52
53
  end
53
- it "Does not support - respond_to - methods, because it has no accessor methods" do
54
- expect(object).not_to respond_to(:one)
54
+ it "Supports - respond_to? - method, because it has accessor or method_missing coverage" do
55
+ expect(object).to respond_to(:one)
55
56
  expect(object.one).to eql "one"
56
57
  end
57
58
  it "nest objects if multi-level hash is given" do
@@ -19,10 +19,10 @@ RSpec.shared_examples "marshalable ruby pojo" do
19
19
  expect(@obj.two).to be_eql("two")
20
20
  expect(@obj.clear_two).to be_nil
21
21
  end
22
- it "#attribute? returns true or false based on contents of attribute." do
22
+ it "#attribute? returns true or false based on true presence and non-blank contents of attribute." do
23
23
  expect(@obj.two?).to be true
24
24
  @obj.two = false
25
- expect(@obj.two?).to be false
25
+ expect(@obj.two?).to be true
26
26
  @obj.clear_two
27
27
  expect(@obj.two?).to be false
28
28
  expect(@obj.three?).to be true
@@ -19,10 +19,10 @@ RSpec.shared_examples "ruby pojo" do
19
19
  expect(@obj.two).to eql("two")
20
20
  expect(@obj.clear_two).to be_nil
21
21
  end
22
- it "#attribute? returns true or false based on contents of attribute." do
22
+ it "#attribute? returns true or false based on true presence and non-blank contents of attribute." do
23
23
  expect(@obj.two?).to be true
24
24
  @obj.two = false
25
- expect(@obj.two?).to be false
25
+ expect(@obj.two?).to be true
26
26
  @obj.clear_two
27
27
  expect(@obj.two?).to be false
28
28
  expect(@obj.three?).to be true
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skn_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.7
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Scott Jr
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-09 00:00:00.000000000 Z
11
+ date: 2015-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -138,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
138
  version: '0'
139
139
  requirements: []
140
140
  rubyforge_project:
141
- rubygems_version: 2.4.6
141
+ rubygems_version: 2.4.3
142
142
  signing_key:
143
143
  specification_version: 3
144
144
  summary: Ruby convenience utilities, the first being a ResultBean. ResultBean is