ryo.rb 0.4.5 → 0.4.7
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/.bundle/config +2 -0
- data/.github/workflows/specs.yml +2 -2
- data/.gitignore +1 -0
- data/.projectile +6 -0
- data/LICENSE +15 -0
- data/README.md +17 -2
- data/lib/ryo/version.rb +1 -1
- data/lib/ryo.rb +8 -0
- data/spec/ryo_basic_object_spec.rb +15 -0
- data/spec/ryo_object_spec.rb +15 -0
- data/spec/ryo_reflect_spec.rb +1 -1
- metadata +6 -8
- data/.yardoc-template/default/fulldoc/html/css/0x1eef.css +0 -15
- data/.yardoc-template/default/layout/html/setup.rb +0 -5
- data/.yardoc-template/default/module/setup.rb +0 -7
- data/LICENSE.txt +0 -22
- data/Rakefile +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0dab9ce575cc86bc7fc740dc72d1a1c416a22d36ed8806b86e1c7f60c0b46f5b
|
4
|
+
data.tar.gz: 403f51fb967e4c745461a61092984f78de8fac139465da0442cd30dea66c807d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dcac875bbd985395ffa37b1b3c48e9f52ebd11d36514faf75e18134530fc2599fbac437114d3d9c2530a66aec810cc7de8904355467a9854d9a9b4f80f2c63f6
|
7
|
+
data.tar.gz: bbb67ac56137b8989b8c94f82b20c887d3914d7218170ded3688e8f53251d2ef1808af4a143e469c374951031a1ab40b3f8ed6cf0ce084ee72f078ad2022446f
|
data/.bundle/config
ADDED
data/.github/workflows/specs.yml
CHANGED
@@ -12,7 +12,7 @@ jobs:
|
|
12
12
|
fail-fast: false
|
13
13
|
matrix:
|
14
14
|
os: [ubuntu-latest]
|
15
|
-
ruby: [3.1, 3.2]
|
15
|
+
ruby: [3.1, 3.2, 3.3]
|
16
16
|
runs-on: ${{ matrix.os }}
|
17
17
|
steps:
|
18
18
|
- uses: actions/checkout@v2
|
@@ -20,4 +20,4 @@ jobs:
|
|
20
20
|
with:
|
21
21
|
ruby-version: ${{ matrix.ruby }}
|
22
22
|
- run: bundle install
|
23
|
-
- run:
|
23
|
+
- run: bundle exec rspec
|
data/.gitignore
CHANGED
data/LICENSE
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
Copyright (C) 2023 by 0x1eef <0x1eef@protonmail.com>
|
2
|
+
|
3
|
+
Permission to use, copy, modify, and/or distribute this
|
4
|
+
software for any purpose with or without fee is hereby
|
5
|
+
granted.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS
|
8
|
+
ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
9
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
|
10
|
+
EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
11
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
|
12
|
+
RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
13
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
14
|
+
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
15
|
+
OF THIS SOFTWARE.
|
data/README.md
CHANGED
@@ -349,12 +349,25 @@ p point.y # => 10
|
|
349
349
|
|
350
350
|
## <a id='install'>Install</a>
|
351
351
|
|
352
|
+
**Git**
|
353
|
+
|
352
354
|
Ryo is distributed as a RubyGem through its git repositories. <br>
|
353
355
|
[GitHub](https://github.com/0x1eef/ryo.rb),
|
354
356
|
and
|
355
357
|
[GitLab](https://gitlab.com/0x1eef/ryo.rb)
|
356
358
|
are available as sources.
|
357
359
|
|
360
|
+
```ruby
|
361
|
+
# Gemfile
|
362
|
+
gem "ryo.rb", github: "0x1eef/ryo.rb", tag: "v0.4.7"
|
363
|
+
```
|
364
|
+
|
365
|
+
**Rubygems.org**
|
366
|
+
|
367
|
+
Ryo can also be installed via rubygems.org.
|
368
|
+
|
369
|
+
gem install ryo.rb
|
370
|
+
|
358
371
|
## Thanks
|
359
372
|
|
360
373
|
Thanks to
|
@@ -363,5 +376,7 @@ for the helpful discussions and advice.
|
|
363
376
|
|
364
377
|
## License
|
365
378
|
|
366
|
-
|
367
|
-
|
379
|
+
[BSD Zero Clause](https://choosealicense.com/licenses/0bsd/).
|
380
|
+
<br>
|
381
|
+
See [LICENSE](./LICENSE).
|
382
|
+
|
data/lib/ryo/version.rb
CHANGED
data/lib/ryo.rb
CHANGED
@@ -152,6 +152,14 @@ module Ryo
|
|
152
152
|
Ryo.inspect_object(self)
|
153
153
|
end
|
154
154
|
|
155
|
+
##
|
156
|
+
# @return [Hash]
|
157
|
+
# Returns the hash table used by a Ryo object.
|
158
|
+
def to_h
|
159
|
+
Ryo.table_of(self, recursive: true)
|
160
|
+
end
|
161
|
+
alias_method :to_hash, :to_h
|
162
|
+
|
155
163
|
##
|
156
164
|
# @private
|
157
165
|
def pretty_print(q)
|
@@ -57,4 +57,19 @@ RSpec.describe Ryo::BasicObject do
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
end
|
60
|
+
|
61
|
+
describe "#to_h" do
|
62
|
+
subject(:h) { car.to_h }
|
63
|
+
let(:car) { Ryo.from(name: "ford", wheels: {quantity: 4}) }
|
64
|
+
it { expect(h).to be_instance_of(Hash) }
|
65
|
+
it { expect(h["wheels"]).to be_instance_of(Hash) }
|
66
|
+
it { expect(h).to eq({"name" => "ford", "wheels" => {"quantity" => 4}}) }
|
67
|
+
|
68
|
+
context "when given to Hash#merge" do
|
69
|
+
let(:car) { Ryo(name: "ford") }
|
70
|
+
subject { {}.merge(car) }
|
71
|
+
it { is_expected.to be_instance_of(Hash) }
|
72
|
+
it { is_expected.to eq({"name" => "ford"})}
|
73
|
+
end
|
74
|
+
end
|
60
75
|
end
|
data/spec/ryo_object_spec.rb
CHANGED
@@ -53,6 +53,21 @@ RSpec.describe "Ryo objects" do
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
+
describe "#to_h" do
|
57
|
+
subject(:h) { car.to_h }
|
58
|
+
let(:car) { Ryo.from(name: "ford", wheels: {quantity: 4}) }
|
59
|
+
it { expect(h).to be_instance_of(Hash) }
|
60
|
+
it { expect(h["wheels"]).to be_instance_of(Hash) }
|
61
|
+
it { expect(h).to eq({"name" => "ford", "wheels" => {"quantity" => 4}}) }
|
62
|
+
|
63
|
+
context "when given to Hash#merge" do
|
64
|
+
let(:car) { Ryo(name: "ford") }
|
65
|
+
subject { {}.merge(car) }
|
66
|
+
it { is_expected.to be_instance_of(Hash) }
|
67
|
+
it { is_expected.to eq({"name" => "ford"})}
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
56
71
|
describe "when a property overshadows a method" do
|
57
72
|
let(:car) do
|
58
73
|
Ryo(tap: "property")
|
data/spec/ryo_reflect_spec.rb
CHANGED
@@ -148,7 +148,7 @@ RSpec.describe Ryo::Reflect do
|
|
148
148
|
context "without recursion" do
|
149
149
|
let(:recursive) { false }
|
150
150
|
context "when given a Ryo object" do
|
151
|
-
let(:ryo) { Ryo(x: 1, y:1) }
|
151
|
+
let(:ryo) { Ryo(x: 1, y: 1) }
|
152
152
|
it { is_expected.to be_instance_of(Hash) }
|
153
153
|
it { is_expected.to eq("x" => 1, "y" => 1) }
|
154
154
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ryo.rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- '0x1eef'
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: yard
|
@@ -101,18 +101,16 @@ executables: []
|
|
101
101
|
extensions: []
|
102
102
|
extra_rdoc_files: []
|
103
103
|
files:
|
104
|
+
- ".bundle/config"
|
104
105
|
- ".github/workflows/specs.yml"
|
105
106
|
- ".gitignore"
|
106
107
|
- ".gitlab-ci.yml"
|
108
|
+
- ".projectile"
|
107
109
|
- ".rubocop.yml"
|
108
|
-
- ".yardoc-template/default/fulldoc/html/css/0x1eef.css"
|
109
|
-
- ".yardoc-template/default/layout/html/setup.rb"
|
110
|
-
- ".yardoc-template/default/module/setup.rb"
|
111
110
|
- ".yardopts"
|
112
111
|
- Gemfile
|
113
|
-
- LICENSE
|
112
|
+
- LICENSE
|
114
113
|
- README.md
|
115
|
-
- Rakefile
|
116
114
|
- lib/ryo.rb
|
117
115
|
- lib/ryo/basic_object.rb
|
118
116
|
- lib/ryo/builder.rb
|
@@ -166,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
166
164
|
- !ruby/object:Gem::Version
|
167
165
|
version: '0'
|
168
166
|
requirements: []
|
169
|
-
rubygems_version: 3.
|
167
|
+
rubygems_version: 3.5.3
|
170
168
|
signing_key:
|
171
169
|
specification_version: 4
|
172
170
|
summary: Ryo implements prototype-based inheritance, in Ruby.
|
data/LICENSE.txt
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
MIT License
|
2
|
-
|
3
|
-
Copyright 2022
|
4
|
-
0x1eef
|
5
|
-
|
6
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
-
of this software and associated documentation files (the "Software"), to deal
|
8
|
-
in the Software without restriction, including without limitation the rights
|
9
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
-
copies of the Software, and to permit persons to whom the Software is
|
11
|
-
furnished to do so, subject to the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be included in all
|
14
|
-
copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
-
SOFTWARE.
|
data/Rakefile
DELETED