ryo.rb 0.5.3 → 0.5.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/env ruby
1
2
  # frozen_string_literal: true
2
3
 
3
4
  require_relative "setup"
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/env ruby
1
2
  # frozen_string_literal: true
2
3
 
3
4
  require_relative "setup"
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/env ruby
1
2
  # frozen_string_literal: true
2
3
 
3
4
  require_relative "setup"
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/env ruby
1
2
  # frozen_string_literal: true
2
3
 
3
4
  require_relative "setup"
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/env ruby
1
2
  # frozen_string_literal: true
2
3
 
3
4
  require_relative "setup"
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/env ruby
1
2
  require_relative "setup"
2
3
  require "ryo"
3
4
 
@@ -29,7 +29,7 @@ RSpec.describe Ryo::Enumerable do
29
29
  end
30
30
 
31
31
  context "when verifying the map operation returns a new object" do
32
- subject { Ryo.kernel(:equal?).bind_call(point_b, point_c) }
32
+ subject { Module.instance_method(:equal?).bind_call(point_b, point_c) }
33
33
  it { is_expected.to be(false) }
34
34
  end
35
35
  end
@@ -5,22 +5,40 @@ require "ryo/json"
5
5
  require "fileutils"
6
6
 
7
7
  RSpec.describe Ryo::JSON do
8
- describe ".from_json_file" do
9
- subject(:ryo) { described_class.from_json(path:, object:) }
10
- before { File.binwrite path, JSON.dump(x: 20, y: 40) }
11
- after { FileUtils.rm(path) }
12
- let(:path) { File.join(__dir__, "test.json") }
8
+ describe ".from_json" do
9
+ context "with a path" do
10
+ subject(:ryo) { described_class.from_json(path:, object:) }
11
+ before { File.binwrite path, JSON.dump(x: 20, y: 40) }
12
+ after { FileUtils.rm(path) }
13
+ let(:path) { File.join(__dir__, "test.json") }
13
14
 
14
- context "with Ryo::Object" do
15
- let(:object) { Ryo::Object }
16
- it { is_expected.to be_instance_of(Ryo::Object) }
17
- it { is_expected.to eq("x" => 20, "y" => 40) }
15
+ context "with Ryo::Object" do
16
+ let(:object) { Ryo::Object }
17
+ it { is_expected.to be_instance_of(Ryo::Object) }
18
+ it { is_expected.to eq("x" => 20, "y" => 40) }
19
+ end
20
+
21
+ context "with Ryo::BasicObject" do
22
+ let(:object) { Ryo::BasicObject }
23
+ it { expect(Ryo::BasicObject === ryo).to be(true) }
24
+ it { is_expected.to eq("x" => 20, "y" => 40) }
25
+ end
18
26
  end
19
27
 
20
- context "with Ryo::BasicObject" do
21
- let(:object) { Ryo::BasicObject }
22
- it { expect(Ryo::BasicObject === ryo).to be(true) }
23
- it { is_expected.to eq("x" => 20, "y" => 40) }
28
+ context "with a string" do
29
+ subject(:ryo) { described_class.from_json(string: "{\"x\": 20, \"y\": 40}", object:) }
30
+
31
+ context "with Ryo::Object" do
32
+ let(:object) { Ryo::Object }
33
+ it { is_expected.to be_instance_of(Ryo::Object) }
34
+ it { is_expected.to eq("x" => 20, "y" => 40) }
35
+ end
36
+
37
+ context "with Ryo::BasicObject" do
38
+ let(:object) { Ryo::BasicObject }
39
+ it { expect(Ryo::BasicObject === ryo).to be(true) }
40
+ it { is_expected.to eq("x" => 20, "y" => 40) }
41
+ end
24
42
  end
25
43
  end
26
44
  end
@@ -170,6 +170,14 @@ RSpec.describe Ryo::Reflect do
170
170
  it { expect(table["point"]["point"]).to be_instance_of(Hash) }
171
171
  it { is_expected.to eq("point" => {"point" => {"x" => 1, "y" => 1}}) }
172
172
  end
173
+
174
+ context "when a Ryo object references an Array" do
175
+ let(:ryo) { Ryo(points: [Ryo(x: 1, y: 1)]) }
176
+ it { expect(table).to be_instance_of(Hash) }
177
+ it { expect(table["points"]).to be_instance_of(Array) }
178
+ it { expect(table["points"][0]).to be_instance_of(Hash) }
179
+ it { is_expected.to eq("points" => [{"x" => 1, "y" => 1}]) }
180
+ end
173
181
  end
174
182
  end
175
183
  end
data/spec/ryo_spec.rb CHANGED
@@ -113,7 +113,7 @@ RSpec.describe Ryo do
113
113
  end
114
114
 
115
115
  context "when verifying the source and duplicate are distinct objects" do
116
- subject { Ryo.kernel(:equal?).bind_call(point_c, dup) }
116
+ subject { Module.instance_method(:equal?).bind_call(point_c, dup) }
117
117
  it { is_expected.to eq(false) }
118
118
  end
119
119
 
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "setup"
4
+ require "ryo/yaml"
5
+ require "fileutils"
6
+
7
+ RSpec.describe Ryo::YAML do
8
+ describe ".from_yaml" do
9
+ context "with a path" do
10
+ subject(:ryo) { described_class.from_yaml(path:, object:) }
11
+ before { File.binwrite path, YAML.dump(x: 20, y: 40) }
12
+ after { FileUtils.rm(path) }
13
+ let(:path) { File.join(__dir__, "test.yaml") }
14
+
15
+ context "with Ryo::Object" do
16
+ let(:object) { Ryo::Object }
17
+ it { is_expected.to be_instance_of(Ryo::Object) }
18
+ it { is_expected.to eq("x" => 20, "y" => 40) }
19
+ end
20
+
21
+ context "with Ryo::BasicObject" do
22
+ let(:object) { Ryo::BasicObject }
23
+ it { expect(Ryo::BasicObject === ryo).to be(true) }
24
+ it { is_expected.to eq("x" => 20, "y" => 40) }
25
+ end
26
+ end
27
+
28
+ context "with a string" do
29
+ subject(:ryo) { described_class.from_yaml(string: "---\nx: 20\ny: 40\n", object:) }
30
+
31
+ context "with Ryo::Object" do
32
+ let(:object) { Ryo::Object }
33
+ it { is_expected.to be_instance_of(Ryo::Object) }
34
+ it { is_expected.to eq("x" => 20, "y" => 40) }
35
+ end
36
+
37
+ context "with Ryo::BasicObject" do
38
+ let(:object) { Ryo::BasicObject }
39
+ it { expect(Ryo::BasicObject === ryo).to be(true) }
40
+ it { is_expected.to eq("x" => 20, "y" => 40) }
41
+ end
42
+ end
43
+ end
44
+ 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.5.3
4
+ version: 0.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - '0x1eef'
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-13 00:00:00.000000000 Z
11
+ date: 2024-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yard
@@ -104,13 +104,13 @@ files:
104
104
  - ".bundle/config"
105
105
  - ".github/workflows/specs.yml"
106
106
  - ".gitignore"
107
- - ".gitlab-ci.yml"
108
107
  - ".projectile"
109
108
  - ".rubocop.yml"
110
109
  - ".yardopts"
111
110
  - Gemfile
112
111
  - LICENSE
113
112
  - README.md
113
+ - Rakefile.rb
114
114
  - lib/ryo.rb
115
115
  - lib/ryo/basic_object.rb
116
116
  - lib/ryo/builder.rb
@@ -121,7 +121,9 @@ files:
121
121
  - lib/ryo/memo.rb
122
122
  - lib/ryo/object.rb
123
123
  - lib/ryo/reflect.rb
124
+ - lib/ryo/utils.rb
124
125
  - lib/ryo/version.rb
126
+ - lib/ryo/yaml.rb
125
127
  - ryo.rb.gemspec
126
128
  - share/ryo.rb/examples/1.0_prototypes_point_object.rb
127
129
  - share/ryo.rb/examples/1.1_prototypes_ryo_fn.rb
@@ -146,6 +148,7 @@ files:
146
148
  - spec/ryo_prototypes_spec.rb
147
149
  - spec/ryo_reflect_spec.rb
148
150
  - spec/ryo_spec.rb
151
+ - spec/ryo_yaml_spec.rb
149
152
  - spec/setup.rb
150
153
  homepage: https://github.com/0x1eef/ryo.rb#readme
151
154
  licenses:
@@ -159,14 +162,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
159
162
  requirements:
160
163
  - - ">="
161
164
  - !ruby/object:Gem::Version
162
- version: '0'
165
+ version: '3.2'
163
166
  required_rubygems_version: !ruby/object:Gem::Requirement
164
167
  requirements:
165
168
  - - ">="
166
169
  - !ruby/object:Gem::Version
167
170
  version: '0'
168
171
  requirements: []
169
- rubygems_version: 3.5.9
172
+ rubygems_version: 3.5.13
170
173
  signing_key:
171
174
  specification_version: 4
172
175
  summary: Ryo implements prototype-based inheritance, in Ruby
data/.gitlab-ci.yml DELETED
@@ -1,9 +0,0 @@
1
- stages:
2
- - test
3
-
4
- test-ruby32:
5
- stage: test
6
- image: ruby:3.2.1
7
- script:
8
- - bundle install
9
- - bundle exec rspec spec/