ryo.rb 0.5.1 → 0.5.3
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/Gemfile +0 -1
- data/README.md +9 -7
- data/lib/ryo/builder.rb +1 -1
- data/lib/ryo/json.rb +24 -20
- data/lib/ryo/version.rb +1 -1
- data/ryo.rb.gemspec +2 -2
- data/spec/readme_spec.rb +1 -1
- data/spec/ryo_json_spec.rb +1 -1
- data/spec/ryo_object_spec.rb +9 -0
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b39f30dc20ead80a6704d27f1a10b9046ad6fe05d164ec4cb31b6606f225a33
|
4
|
+
data.tar.gz: 03db26bce85e7f1fad10d2b909284c32fc18f13cd999aa718ddd21d867d29a29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95f73de92d97038eb2ef3c70c4fb97e02c84a0ed5fe9a7d73f198f392f4a04ca608170ab2011f537bac9779cb66c7214a1166040268d602aa592a540789e24e8
|
7
|
+
data.tar.gz: 51809089becfa72d4cadf79771cd944f1d31e8d658d03f4d00881c6d7eec6dbd58448cbabe3efada8e386a55c96b5298fb47470f76c125179ecf35ad9d1ddb1b
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -333,11 +333,14 @@ p point.x # => 5
|
|
333
333
|
p point.y # => 10
|
334
334
|
```
|
335
335
|
|
336
|
-
##
|
336
|
+
## Documentation
|
337
337
|
|
338
|
-
|
338
|
+
A complete API reference is available at
|
339
|
+
[0x1eef.github.io/x/ryo.rb](https://0x1eef.github.io/x/ryo.rb)
|
339
340
|
|
340
|
-
|
341
|
+
## Install
|
342
|
+
|
343
|
+
Ryo can be installed via rubygems.org:
|
341
344
|
|
342
345
|
gem install ryo.rb
|
343
346
|
|
@@ -350,11 +353,10 @@ Ryo can be installed via rubygems.org.
|
|
350
353
|
|
351
354
|
Thanks to
|
352
355
|
[@awfulcooking (mooff)](https://github.com/awfulcooking)
|
353
|
-
for the helpful discussions and advice
|
356
|
+
for the helpful discussions, ideas, and advice
|
354
357
|
|
355
358
|
## License
|
356
359
|
|
357
|
-
[BSD Zero Clause](https://choosealicense.com/licenses/0bsd/)
|
360
|
+
[BSD Zero Clause](https://choosealicense.com/licenses/0bsd/)
|
358
361
|
<br>
|
359
|
-
See [LICENSE](./LICENSE)
|
360
|
-
|
362
|
+
See [LICENSE](./LICENSE)
|
data/lib/ryo/builder.rb
CHANGED
@@ -26,7 +26,7 @@ module Ryo::Builder
|
|
26
26
|
# returned in its place.
|
27
27
|
def self.build(buildee, props, prototype = nil)
|
28
28
|
if Ryo.ryo?(props)
|
29
|
-
build(
|
29
|
+
build(buildee, Ryo.table_of(props), prototype || Ryo.prototype_of(props))
|
30
30
|
else
|
31
31
|
ryo = buildee.new
|
32
32
|
Ryo.set_prototype_of(ryo, prototype)
|
data/lib/ryo/json.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
##
|
2
4
|
# The {Ryo::JSON Ryo::JSON} module provides a number of methods
|
3
5
|
# for coercing JSON data into a Ryo object. It must be required
|
@@ -8,33 +10,35 @@ module Ryo::JSON
|
|
8
10
|
extend self
|
9
11
|
|
10
12
|
##
|
13
|
+
# @example
|
14
|
+
# Ryo.from_json(path: "/foo/bar/baz.json")
|
15
|
+
# Ryo.from_json(string: "[]")
|
16
|
+
#
|
11
17
|
# @param [String] path
|
12
|
-
# The path to a JSON file
|
18
|
+
# The path to a JSON file
|
19
|
+
#
|
20
|
+
# @param [String] string
|
21
|
+
# A blob of JSON
|
13
22
|
#
|
14
23
|
# @param [Ryo] object
|
15
|
-
# {Ryo::Object Ryo::Object}, or {Ryo::BasicObject Ryo::BasicObject}
|
16
|
-
# Defaults to {Ryo::Object Ryo::Object}
|
24
|
+
# {Ryo::Object Ryo::Object}, or {Ryo::BasicObject Ryo::BasicObject}
|
25
|
+
# Defaults to {Ryo::Object Ryo::Object}
|
17
26
|
#
|
18
27
|
# @raise [SystemCallError]
|
19
|
-
# Might raise a number of Errno exceptions
|
28
|
+
# Might raise a number of Errno exceptions
|
20
29
|
#
|
21
30
|
# @return [Ryo::Object, Ryo::BasicObject]
|
22
|
-
# Returns a Ryo object
|
23
|
-
def
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
# Defaults to {Ryo::Object Ryo::Object}.
|
34
|
-
#
|
35
|
-
# @return (see Ryo::JSON#from_json_file)
|
36
|
-
def from_json(blob, object: Ryo::Object)
|
37
|
-
object.from JSON.parse(blob)
|
31
|
+
# Returns a Ryo object
|
32
|
+
def from_json(path: nil, string: nil, object: Ryo::Object)
|
33
|
+
if path && string
|
34
|
+
raise ArgumentError, "Provide a path or string but not both"
|
35
|
+
elsif path
|
36
|
+
object.from JSON.parse(File.binread(path))
|
37
|
+
elsif string
|
38
|
+
object.from JSON.parse(string)
|
39
|
+
else
|
40
|
+
raise ArgumentError, "No path or string provided"
|
41
|
+
end
|
38
42
|
end
|
39
43
|
|
40
44
|
Ryo.extend(self)
|
data/lib/ryo/version.rb
CHANGED
data/ryo.rb.gemspec
CHANGED
@@ -10,12 +10,12 @@ Gem::Specification.new do |gem|
|
|
10
10
|
gem.licenses = ["MIT"]
|
11
11
|
gem.files = `git ls-files`.split($/)
|
12
12
|
gem.require_paths = ["lib"]
|
13
|
-
gem.description = "Ryo implements prototype-based inheritance, in Ruby
|
13
|
+
gem.description = "Ryo implements prototype-based inheritance, in Ruby"
|
14
14
|
gem.summary = gem.description
|
15
15
|
gem.add_development_dependency "yard", "~> 0.9"
|
16
16
|
gem.add_development_dependency "redcarpet", "~> 3.5"
|
17
17
|
gem.add_development_dependency "rspec", "~> 3.10"
|
18
18
|
gem.add_development_dependency "rubocop-rspec", "~> 2.12"
|
19
19
|
gem.add_development_dependency "standard", "~> 1.9"
|
20
|
-
gem.add_development_dependency "test-cmd.rb", "~> 0.
|
20
|
+
gem.add_development_dependency "test-cmd.rb", "~> 0.12"
|
21
21
|
end
|
data/spec/readme_spec.rb
CHANGED
data/spec/ryo_json_spec.rb
CHANGED
@@ -6,7 +6,7 @@ require "fileutils"
|
|
6
6
|
|
7
7
|
RSpec.describe Ryo::JSON do
|
8
8
|
describe ".from_json_file" do
|
9
|
-
subject(:ryo) { described_class.
|
9
|
+
subject(:ryo) { described_class.from_json(path:, object:) }
|
10
10
|
before { File.binwrite path, JSON.dump(x: 20, y: 40) }
|
11
11
|
after { FileUtils.rm(path) }
|
12
12
|
let(:path) { File.join(__dir__, "test.json") }
|
data/spec/ryo_object_spec.rb
CHANGED
@@ -5,6 +5,15 @@ require_relative "setup"
|
|
5
5
|
RSpec.describe "Ryo objects" do
|
6
6
|
let(:car) { Ryo(name: "Car") }
|
7
7
|
|
8
|
+
describe "Kernel#Ryo" do
|
9
|
+
context "when given a Ryo object" do
|
10
|
+
subject { Ryo(ryo) }
|
11
|
+
let(:ryo) { Ryo(name: "Car") }
|
12
|
+
|
13
|
+
it { is_expected.to be_instance_of(Ryo::Object) }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
8
17
|
describe "#respond_to?" do
|
9
18
|
context "when a property is defined" do
|
10
19
|
subject { car.respond_to?(:name) }
|
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.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- '0x1eef'
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-06-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: yard
|
@@ -86,15 +86,15 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '0.
|
89
|
+
version: '0.12'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '0.
|
97
|
-
description: Ryo implements prototype-based inheritance, in Ruby
|
96
|
+
version: '0.12'
|
97
|
+
description: Ryo implements prototype-based inheritance, in Ruby
|
98
98
|
email:
|
99
99
|
- 0x1eef@protonmail.com
|
100
100
|
executables: []
|
@@ -166,8 +166,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
166
166
|
- !ruby/object:Gem::Version
|
167
167
|
version: '0'
|
168
168
|
requirements: []
|
169
|
-
rubygems_version: 3.5.
|
169
|
+
rubygems_version: 3.5.9
|
170
170
|
signing_key:
|
171
171
|
specification_version: 4
|
172
|
-
summary: Ryo implements prototype-based inheritance, in Ruby
|
172
|
+
summary: Ryo implements prototype-based inheritance, in Ruby
|
173
173
|
test_files: []
|