skn_utils 1.4.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 +7 -0
- data/.gitignore +15 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/LICENSE.txt +22 -0
- data/README.md +221 -0
- data/Rakefile +6 -0
- data/lib/skn_utils.rb +11 -0
- data/lib/skn_utils/attribute_helpers.rb +159 -0
- data/lib/skn_utils/generic_bean.rb +19 -0
- data/lib/skn_utils/nested_result_base.rb +233 -0
- data/lib/skn_utils/page_controls.rb +20 -0
- data/lib/skn_utils/result_bean.rb +17 -0
- data/lib/skn_utils/result_bean_with_errors.rb +43 -0
- data/lib/skn_utils/version.rb +3 -0
- data/skn_utils.gemspec +50 -0
- data/spec/lib/skn_utils/generic_bean_spec.rb +94 -0
- data/spec/lib/skn_utils/page_controls_spec.rb +123 -0
- data/spec/lib/skn_utils/result_bean_spec.rb +92 -0
- data/spec/lib/skn_utils/result_bean_with_errors_spec.rb +178 -0
- data/spec/spec_helper.rb +39 -0
- data/spec/support/shared_example_marshalable_ruby_pojo.rb +55 -0
- data/spec/support/shared_example_ruby_pojo.rb +65 -0
- metadata +156 -0
@@ -0,0 +1,65 @@
|
|
1
|
+
##
|
2
|
+
# <root>/spec/support/shared_example_ruby_pojo.rb
|
3
|
+
#
|
4
|
+
# refs: result_bean, result_with_errors
|
5
|
+
#
|
6
|
+
|
7
|
+
RSpec.shared_examples "ruby pojo" do
|
8
|
+
it "provides getters" do
|
9
|
+
expect(@obj.one).to eql("one")
|
10
|
+
expect(@obj.two).to eql("two")
|
11
|
+
end
|
12
|
+
it "provides setters" do
|
13
|
+
@obj.one = "1"
|
14
|
+
@obj.two = "2"
|
15
|
+
expect(@obj.two).to eql("2")
|
16
|
+
expect(@obj.one).to eql("1")
|
17
|
+
end
|
18
|
+
it "#clear_attribute sets given attribute to nil." do
|
19
|
+
expect(@obj.two).to eql("two")
|
20
|
+
expect(@obj.clear_two).to be_nil
|
21
|
+
end
|
22
|
+
it "#attribute? returns true or false based on contents of attribute." do
|
23
|
+
expect(@obj.two?).to be true
|
24
|
+
@obj.two = false
|
25
|
+
expect(@obj.two?).to be false
|
26
|
+
@obj.clear_two
|
27
|
+
expect(@obj.two?).to be false
|
28
|
+
expect(@obj.three?).to be true
|
29
|
+
@obj.clear_three
|
30
|
+
expect(@obj.three?).to be false
|
31
|
+
end
|
32
|
+
it "#attribute? returns false when attribute is not defined or unknown" do
|
33
|
+
expect(@obj.address?).to be false
|
34
|
+
end
|
35
|
+
it "raises an 'NoMethodError' error when attribute that does not exist is accessed " do
|
36
|
+
expect { @obj.address }.to raise_error NoMethodError
|
37
|
+
end
|
38
|
+
it "Nests objects if multi-level hash is given " do
|
39
|
+
obj = SknUtils::ResultBeanWithErrors.new({one: "one", two: "two", three: {four: 4, five: 5}})
|
40
|
+
expect(object.three).to be_kind_of(SknUtils::NestedResultBase)
|
41
|
+
expect(object.three.five).to eq(5)
|
42
|
+
end
|
43
|
+
it "#attributes method returns a hash of all attributes and their values." do
|
44
|
+
expect(object.attributes).to be_a(Hash)
|
45
|
+
expect(object.attributes[:one]).to eql("one")
|
46
|
+
expect(object.attributes[:three]).to be_a(Hash)
|
47
|
+
end
|
48
|
+
|
49
|
+
context "transformations are enabled with " do
|
50
|
+
it "#attributes method returns a hash of all attributes and their values." do
|
51
|
+
expect(object.attributes).to be_a(Hash)
|
52
|
+
expect(object.attributes[:one]).to be_eql("one")
|
53
|
+
expect(object.attributes[:three]).to be_a(Hash)
|
54
|
+
end
|
55
|
+
it "#to_json method returns a serialized version of this object." do
|
56
|
+
expect(object.to_json).to include(":\"")
|
57
|
+
end
|
58
|
+
it "#to_xml method returns a serialized version of this object." do
|
59
|
+
expect(object.to_xml).to include("xml version")
|
60
|
+
end
|
61
|
+
it "#to_hash method returns a serialized version of this object." do
|
62
|
+
expect(object.to_hash).to be_a(Hash)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
metadata
ADDED
@@ -0,0 +1,156 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: skn_utils
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.4.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- James Scott Jr
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-04-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activemodel
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.7'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: "Creates an PORO Object with instance variables and associated getters
|
84
|
+
and setters for each input key, during runtime.\n \nIf a key's value is also a hash,
|
85
|
+
it too can optionally become an Object.\n \nIf a key's value is a Array of Hashes,
|
86
|
+
each element of the Array can optionally become an Object.\n \nThis nesting action
|
87
|
+
is controlled by the value of the options key ':depth'. Options key :depth defaults
|
88
|
+
\nto :multi, and has options of :single, :multi, or :multi_with_arrays\n \nThe
|
89
|
+
ability of the resulting Object to be Marshalled(dump/load) can be preserved by
|
90
|
+
merging configuration options\ninto the input params key ':enable_serialization'
|
91
|
+
set to true. It defaults to false for speed purposes\n\nReview the RSpec tests,
|
92
|
+
and or review the README for more details.\n"
|
93
|
+
email: skoona@gmail.com
|
94
|
+
executables: []
|
95
|
+
extensions: []
|
96
|
+
extra_rdoc_files: []
|
97
|
+
files:
|
98
|
+
- ".gitignore"
|
99
|
+
- ".rspec"
|
100
|
+
- Gemfile
|
101
|
+
- LICENSE
|
102
|
+
- LICENSE.txt
|
103
|
+
- README.md
|
104
|
+
- Rakefile
|
105
|
+
- lib/skn_utils.rb
|
106
|
+
- lib/skn_utils/attribute_helpers.rb
|
107
|
+
- lib/skn_utils/generic_bean.rb
|
108
|
+
- lib/skn_utils/nested_result_base.rb
|
109
|
+
- lib/skn_utils/page_controls.rb
|
110
|
+
- lib/skn_utils/result_bean.rb
|
111
|
+
- lib/skn_utils/result_bean_with_errors.rb
|
112
|
+
- lib/skn_utils/version.rb
|
113
|
+
- skn_utils.gemspec
|
114
|
+
- spec/lib/skn_utils/generic_bean_spec.rb
|
115
|
+
- spec/lib/skn_utils/page_controls_spec.rb
|
116
|
+
- spec/lib/skn_utils/result_bean_spec.rb
|
117
|
+
- spec/lib/skn_utils/result_bean_with_errors_spec.rb
|
118
|
+
- spec/spec_helper.rb
|
119
|
+
- spec/support/shared_example_marshalable_ruby_pojo.rb
|
120
|
+
- spec/support/shared_example_ruby_pojo.rb
|
121
|
+
homepage: https://github.com/skoona/skn_utils
|
122
|
+
licenses:
|
123
|
+
- MIT
|
124
|
+
metadata: {}
|
125
|
+
post_install_message: Thanks for installing SknUtils, keep watch more utilities will
|
126
|
+
be added!
|
127
|
+
rdoc_options: []
|
128
|
+
require_paths:
|
129
|
+
- lib
|
130
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
135
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
requirements: []
|
141
|
+
rubyforge_project:
|
142
|
+
rubygems_version: 2.4.3
|
143
|
+
signing_key:
|
144
|
+
specification_version: 4
|
145
|
+
summary: Ruby convenience utilities, the first being a ResultBean. ResultBean is
|
146
|
+
a PORO (Plain Old Ruby Object) which inherits from NestedResultBean class (inlcuded).
|
147
|
+
This class is intantiated via a hash at Ruby/Rails Runtime, allows access to vars
|
148
|
+
via dot or hash notation, and is serializable via to_xml, to_hash, and to_json.
|
149
|
+
test_files:
|
150
|
+
- spec/lib/skn_utils/generic_bean_spec.rb
|
151
|
+
- spec/lib/skn_utils/page_controls_spec.rb
|
152
|
+
- spec/lib/skn_utils/result_bean_spec.rb
|
153
|
+
- spec/lib/skn_utils/result_bean_with_errors_spec.rb
|
154
|
+
- spec/spec_helper.rb
|
155
|
+
- spec/support/shared_example_marshalable_ruby_pojo.rb
|
156
|
+
- spec/support/shared_example_ruby_pojo.rb
|