ryo.rb 0.4.5 → 0.4.6

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
  SHA256:
3
- metadata.gz: 07253d87ed2b75096a5791e0f31d9820bff5c165c66e73544c42fa9350dc5aa6
4
- data.tar.gz: d54bb6a949f1000daac311a9516ddf96a3827f57cd4ede08d7f729c371c57fe9
3
+ metadata.gz: e90c5b42d1b364a6be77786df22b887017d3ce4965822f7152af7bcb1c617748
4
+ data.tar.gz: ec5d807404158d8dd1e9df47ee1fa15fb6be64ae2086942fbe9c1fd834be7331
5
5
  SHA512:
6
- metadata.gz: 4920a2c7caa1c368f7cc3bdbba28b73386434932ea0bf08df87bfdd68db91ce47c7836f8ce6e6fc1e87f62ae02a3c501046fbcb8cf5d85a27fcb1dbdfce36944
7
- data.tar.gz: b34a95a4849be0457e3eabf67e0548c8b73393bf4595eec5a4241531b5666bb2e2d61e2ce55195ba3fb342a03b6e3ddc9c7bd4c0f82412d4263545a0403285a2
6
+ metadata.gz: ef8f408777db206d7fa5e3c7ced8d8a5fdfdaa15ad6e39f25921de20c421f0bef90d1aa1e474cbc6f6ab23d17fa314bd6513d3b9e322732d4adf21fb6c76b9c9
7
+ data.tar.gz: db93fad9aa4eeffdecbba86fa2ec970851eb007d3fecf0602e631584091f28d06dd3997464306267012bf893319f5209813b8cb99024e0281a5048da39f2a0a5
data/.bundle/config ADDED
@@ -0,0 +1,2 @@
1
+ ---
2
+ BUNDLE_PATH: ".gems"
@@ -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: rspec -Ilib -rryo spec/
23
+ - run: bundle exec rspec
data/.gitignore CHANGED
@@ -4,3 +4,4 @@ doc/
4
4
  .yardoc
5
5
  *.lock
6
6
  pkg/
7
+ .gems/
data/.projectile ADDED
@@ -0,0 +1,6 @@
1
+ +.
2
+ +.github
3
+ -.gems
4
+ -.git
5
+ -doc
6
+
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.6"
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
- This project is released under the terms of the MIT license. <br>
367
- See [./LICENSE.txt](./LICENSE.txt) for details.
379
+ [BSD Zero Clause](https://choosealicense.com/licenses/0bsd/).
380
+ <br>
381
+ See [LICENSE](./LICENSE).
382
+
data/lib/ryo/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ryo
4
- VERSION = "0.4.5"
4
+ VERSION = "0.4.6"
5
5
  end
data/lib/ryo.rb CHANGED
@@ -152,6 +152,13 @@ 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
+
155
162
  ##
156
163
  # @private
157
164
  def pretty_print(q)
@@ -57,4 +57,12 @@ 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
+ end
60
68
  end
@@ -53,6 +53,14 @@ 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
+ end
63
+
56
64
  describe "when a property overshadows a method" do
57
65
  let(:car) do
58
66
  Ryo(tap: "property")
@@ -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.5
4
+ version: 0.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - '0x1eef'
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-13 00:00:00.000000000 Z
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.txt
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.4.10
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.
@@ -1,15 +0,0 @@
1
- #main #content #filecontents p, .discussion p, ul.param li, div.note {
2
- max-width: 768px;
3
- }
4
-
5
- #toc {
6
- position: fixed;
7
- right: 25px;
8
- display: none;
9
- }
10
-
11
- @media screen and (min-width: 1280px) {
12
- #toc {
13
- display: block;
14
- }
15
- }
@@ -1,5 +0,0 @@
1
- def stylesheets
2
- s = super
3
- s << "css/0x1eef.css"
4
- s
5
- end
@@ -1,7 +0,0 @@
1
- ##
2
- # Sort methods in ascending order based
3
- # on the line number where a method is
4
- # defined.
5
- def sort_listing(listing)
6
- listing.sort_by { _1.files[1] }
7
- end
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
@@ -1,3 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "bundler/gem_tasks"