poro_plus 1.1.5 → 1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CODE_OF_CONDUCT.md +73 -0
- data/Gemfile.lock +17 -12
- data/README.md +22 -2
- data/lib/poro_plus.rb +2 -0
- data/lib/poro_plus/version.rb +2 -2
- data/spec/lib/poro_plus/poro_plus_spec.rb +15 -4
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c86fd436ed317e15fb8b3fe9ab82bb173ba5a363bfa3f410aee4ec2b1c3fc740
|
4
|
+
data.tar.gz: 7d9ee0359f5ca0f459468fbc2b4e67a1643a8f360087d5523321feb957155484
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3e96c1f9c383c8f1744758516c6c94fb6d283ff1cae6532817a2f82f63f8a61d406b0dd8ec83d7726910d6d1db4aa92bd49da2e178faeaca1779d2bcc0636d5
|
7
|
+
data.tar.gz: b21a96599a55c5f75a6ecf433d44eb9b2b46fdcf860f40faed96d2c5c729b570360d7fc3c708a368ad74e5ba2f4cf60906924aa5fa94ea7b6963a5b5c6cd7dda
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
9
|
+
level of experience, education, socio-economic status, nationality, personal
|
10
|
+
appearance, race, religion, or sexual identity and orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at coraline@idolhands.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
72
|
+
|
73
|
+
[homepage]: https://www.contributor-covenant.org
|
data/Gemfile.lock
CHANGED
@@ -1,21 +1,26 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
poro_plus (1.
|
4
|
+
poro_plus (1.2)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
diff-lcs (1.
|
10
|
-
rake (
|
11
|
-
rspec (
|
12
|
-
rspec-core (~>
|
13
|
-
rspec-expectations (~>
|
14
|
-
rspec-mocks (~>
|
15
|
-
rspec-core (
|
16
|
-
|
17
|
-
|
18
|
-
|
9
|
+
diff-lcs (1.3)
|
10
|
+
rake (12.3.1)
|
11
|
+
rspec (3.8.0)
|
12
|
+
rspec-core (~> 3.8.0)
|
13
|
+
rspec-expectations (~> 3.8.0)
|
14
|
+
rspec-mocks (~> 3.8.0)
|
15
|
+
rspec-core (3.8.0)
|
16
|
+
rspec-support (~> 3.8.0)
|
17
|
+
rspec-expectations (3.8.1)
|
18
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
19
|
+
rspec-support (~> 3.8.0)
|
20
|
+
rspec-mocks (3.8.0)
|
21
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
22
|
+
rspec-support (~> 3.8.0)
|
23
|
+
rspec-support (3.8.0)
|
19
24
|
|
20
25
|
PLATFORMS
|
21
26
|
ruby
|
@@ -27,4 +32,4 @@ DEPENDENCIES
|
|
27
32
|
rspec
|
28
33
|
|
29
34
|
BUNDLED WITH
|
30
|
-
1.
|
35
|
+
1.16.1
|
data/README.md
CHANGED
@@ -21,7 +21,7 @@ Simply include PoroPlus into your Ruby class:
|
|
21
21
|
|
22
22
|
class MyThing
|
23
23
|
include PoroPlus
|
24
|
-
|
24
|
+
attr_reader :foo, :bar, :tres
|
25
25
|
end
|
26
26
|
|
27
27
|
Then you can:
|
@@ -32,9 +32,29 @@ Then you can:
|
|
32
32
|
> thing_1.to_hash
|
33
33
|
=> {:foo=>"Raven", :bar=>"Writing Desk", :tres=>nil}
|
34
34
|
|
35
|
-
>
|
35
|
+
> thing_1.to_json(:skip_nils => true)
|
36
36
|
=> "{\"foo\":\"Raven\",\"bar\":\"Writing Desk\"}"
|
37
37
|
|
38
|
+
If you want the JSON to include methods that return values:
|
39
|
+
|
40
|
+
class MyThing
|
41
|
+
include PoroPlus
|
42
|
+
attr_reader :foo, :bar, :tres
|
43
|
+
|
44
|
+
def tres
|
45
|
+
"tres leches con #{self.bar}"
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
Then, passing a nil to create a placeholder for that JSON attribute, you can:
|
51
|
+
|
52
|
+
> thing_2 = MyThing.new(:foo => 'Taco', :bar => 'cinnammon', :tres => nil) # nil placeholder
|
53
|
+
=> #<MyThing:0x007ff4866ea398 @foo="Taco", @bar="cinnammon", @tres=nil>
|
54
|
+
|
55
|
+
> thing_2.to_json(:skip_nils => true)
|
56
|
+
=> "{\"foo\":\"Taco\",\"bar\":\"cinnammon\",\"tres\":\"tres leches con cinnammon\"}"
|
57
|
+
|
38
58
|
## Contributing
|
39
59
|
|
40
60
|
1. Fork it
|
data/lib/poro_plus.rb
CHANGED
@@ -8,7 +8,9 @@ module PoroPlus
|
|
8
8
|
|
9
9
|
def to_hash(args={})
|
10
10
|
instance_variables.inject({}) do |h, iv|
|
11
|
+
key = sanitized_key(iv)
|
11
12
|
value = instance_variable_get(iv)
|
13
|
+
value ||= self.public_send(key) if self.respond_to?(key)
|
12
14
|
return h if value.nil? && args[:skip_nils]
|
13
15
|
h[sanitized_key(iv)] = value
|
14
16
|
h
|
data/lib/poro_plus/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module PoroPlus
|
2
|
-
VERSION='1.
|
3
|
-
end
|
2
|
+
VERSION='1.2'
|
3
|
+
end
|
@@ -6,6 +6,11 @@ describe PoroPlus do
|
|
6
6
|
include PoroPlus
|
7
7
|
attr_accessor :foo
|
8
8
|
attr_accessor :bar
|
9
|
+
attr_reader :baz
|
10
|
+
|
11
|
+
def baz
|
12
|
+
foo + bar
|
13
|
+
end
|
9
14
|
end
|
10
15
|
|
11
16
|
describe '#sanitized_key' do
|
@@ -23,7 +28,7 @@ describe PoroPlus do
|
|
23
28
|
thing.to_hash[:bar].should == 2
|
24
29
|
end
|
25
30
|
|
26
|
-
it 'nil-values are not skipped normally' do
|
31
|
+
it 'nil-values are not skipped normally' do
|
27
32
|
thing = Thing.new(foo: 1, bar: nil)
|
28
33
|
thing.to_hash[:foo].should == 1
|
29
34
|
thing.to_hash[:bar].should be_nil
|
@@ -31,11 +36,11 @@ describe PoroPlus do
|
|
31
36
|
|
32
37
|
it 'skips nil-value instance variables if so configured with skip_nils flag' do
|
33
38
|
thing = Thing.new(foo: 1, bar: nil)
|
34
|
-
thing.to_hash(:skip_nils => true).keys.include?(:bar).should
|
39
|
+
thing.to_hash(:skip_nils => true).keys.include?(:bar).should be_falsey
|
35
40
|
end
|
36
41
|
|
37
42
|
end
|
38
|
-
|
43
|
+
|
39
44
|
describe '#to_json' do
|
40
45
|
it "converts its instance variables to json string" do
|
41
46
|
thing = Thing.new(foo: 1, bar: 2)
|
@@ -54,5 +59,11 @@ describe PoroPlus do
|
|
54
59
|
|
55
60
|
end
|
56
61
|
|
57
|
-
|
62
|
+
context "with overriding methods" do
|
63
|
+
it "replaces a nil initialized value with a method call" do
|
64
|
+
thing = Thing.new(foo: 1, bar: 2, baz: nil)
|
65
|
+
thing.to_json.should == "{\"foo\":1,\"bar\":2,\"baz\":3}"
|
66
|
+
end
|
67
|
+
end
|
58
68
|
|
69
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: poro_plus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: '1.2'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Coraline Ada Ehmke
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -60,6 +60,7 @@ extensions: []
|
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
62
|
- ".gitignore"
|
63
|
+
- CODE_OF_CONDUCT.md
|
63
64
|
- Gemfile
|
64
65
|
- Gemfile.lock
|
65
66
|
- LICENSE.txt
|
@@ -90,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
91
|
version: '0'
|
91
92
|
requirements: []
|
92
93
|
rubyforge_project:
|
93
|
-
rubygems_version: 2.
|
94
|
+
rubygems_version: 2.7.6
|
94
95
|
signing_key:
|
95
96
|
specification_version: 4
|
96
97
|
summary: Simple methods to make Plain Old Ruby Objects (POROs) more fun.
|