hexlet-pairs 1.0.0 → 1.1.0
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/.rubocop.yml +1 -0
- data/Gemfile +5 -1
- data/Gemfile.lock +15 -5
- data/Makefile +1 -1
- data/README.md +7 -1
- data/{pairs.gemspec → hexlet-pairs.gemspec} +4 -4
- data/lib/pairs.rb +45 -0
- data/lib/pairs/version.rb +3 -0
- metadata +9 -9
- data/lib/hexlet/pairs.rb +0 -49
- data/lib/hexlet/pairs/version.rb +0 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d58a66470664baf485f14c47b86ff9d62836d93d835fb72c5bc80e1916d8e45f
|
|
4
|
+
data.tar.gz: 901b42c7381ebfe5604b3ff6248b78fd21d297fb9bc690be0f00f42d8b907985
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 692063d31463062f9ecb5a3104b381e76c87c38494b06bcc61628cc3bd8a08f979d9038508047cebd0971e39d6a56f1c2e9e98f244575144fd0f473140871188
|
|
7
|
+
data.tar.gz: fda972636e9b3603d2d890fa873eb81cc1ed0e3e324834eae34e527634f2c76b25cc404bed1a0dd0672fabd5bec8641e55f4a21de27eb59087911fed454e230c
|
data/.rubocop.yml
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
hexlet-pairs (1.1.0)
|
|
5
|
+
|
|
1
6
|
GEM
|
|
2
7
|
remote: https://rubygems.org/
|
|
3
8
|
specs:
|
|
4
9
|
ast (2.4.2)
|
|
5
10
|
diff-lcs (1.4.4)
|
|
6
11
|
parallel (1.20.1)
|
|
7
|
-
parser (3.0.
|
|
12
|
+
parser (3.0.1.0)
|
|
8
13
|
ast (~> 2.4.1)
|
|
9
14
|
rainbow (3.0.0)
|
|
10
15
|
regexp_parser (2.1.1)
|
|
11
|
-
rexml (3.2.
|
|
16
|
+
rexml (3.2.5)
|
|
12
17
|
rspec (3.10.0)
|
|
13
18
|
rspec-core (~> 3.10.0)
|
|
14
19
|
rspec-expectations (~> 3.10.0)
|
|
@@ -22,7 +27,7 @@ GEM
|
|
|
22
27
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
23
28
|
rspec-support (~> 3.10.0)
|
|
24
29
|
rspec-support (3.10.2)
|
|
25
|
-
rubocop (1.
|
|
30
|
+
rubocop (1.12.1)
|
|
26
31
|
parallel (~> 1.10)
|
|
27
32
|
parser (>= 3.0.0.0)
|
|
28
33
|
rainbow (>= 2.2.2, < 4.0)
|
|
@@ -33,6 +38,9 @@ GEM
|
|
|
33
38
|
unicode-display_width (>= 1.4.0, < 3.0)
|
|
34
39
|
rubocop-ast (1.4.1)
|
|
35
40
|
parser (>= 2.7.1.5)
|
|
41
|
+
rubocop-rspec (2.2.0)
|
|
42
|
+
rubocop (~> 1.0)
|
|
43
|
+
rubocop-ast (>= 1.1.0)
|
|
36
44
|
ruby-progressbar (1.11.0)
|
|
37
45
|
unicode-display_width (2.0.0)
|
|
38
46
|
|
|
@@ -40,8 +48,10 @@ PLATFORMS
|
|
|
40
48
|
ruby
|
|
41
49
|
|
|
42
50
|
DEPENDENCIES
|
|
51
|
+
hexlet-pairs!
|
|
43
52
|
rspec (~> 3.10)
|
|
44
|
-
rubocop (~> 1.1)
|
|
53
|
+
rubocop (~> 1.12.1)
|
|
54
|
+
rubocop-rspec (~> 2.2.0)
|
|
45
55
|
|
|
46
56
|
BUNDLED WITH
|
|
47
|
-
2.
|
|
57
|
+
2.2.15
|
data/Makefile
CHANGED
data/README.md
CHANGED
|
@@ -2,10 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://github.com/hexlet-components/ruby-pairs/actions)
|
|
4
4
|
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
gem install hexlet-pairs
|
|
9
|
+
```
|
|
10
|
+
|
|
5
11
|
## Usage example
|
|
6
12
|
|
|
7
13
|
```ruby
|
|
8
|
-
require '
|
|
14
|
+
require 'pairs'
|
|
9
15
|
|
|
10
16
|
pair = Pairs.cons(3, 5)
|
|
11
17
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
require_relative 'lib/
|
|
1
|
+
require_relative 'lib/pairs/version'
|
|
2
2
|
|
|
3
3
|
Gem::Specification.new do |spec|
|
|
4
4
|
spec.name = "hexlet-pairs"
|
|
5
|
-
spec.version =
|
|
5
|
+
spec.version = Pairs::VERSION
|
|
6
6
|
spec.authors = ["Hexlet"]
|
|
7
7
|
spec.email = ["info@hexlet.io"]
|
|
8
8
|
|
|
@@ -16,10 +16,10 @@ Gem::Specification.new do |spec|
|
|
|
16
16
|
spec.metadata["source_code_uri"] = "https://github.com/hexlet-components/ruby-pairs"
|
|
17
17
|
spec.metadata["changelog_uri"] = "https://github.com/hexlet-components/ruby-pairs"
|
|
18
18
|
|
|
19
|
-
# Specify which files should be added to the gem when it is released.
|
|
20
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
21
19
|
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
|
22
20
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
23
21
|
end
|
|
22
|
+
# spec.bindir = "exe"
|
|
23
|
+
# spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
24
24
|
spec.require_paths = ["lib"]
|
|
25
25
|
end
|
data/lib/pairs.rb
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
module Pairs
|
|
2
|
+
def self.cons(left, right)
|
|
3
|
+
lambda { |message|
|
|
4
|
+
case message
|
|
5
|
+
when 'car'
|
|
6
|
+
left
|
|
7
|
+
when 'cdr'
|
|
8
|
+
right
|
|
9
|
+
else
|
|
10
|
+
raise "Unknown message #{message}"
|
|
11
|
+
end
|
|
12
|
+
}
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.check_pair(pair)
|
|
16
|
+
return if pair?(pair)
|
|
17
|
+
|
|
18
|
+
raise NoMethodError, pair.to_s
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def self.car(pair)
|
|
22
|
+
check_pair(pair)
|
|
23
|
+
pair.call('car')
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def self.cdr(pair)
|
|
27
|
+
pair.call('cdr')
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def self.pair?(pair)
|
|
31
|
+
pair.instance_of? Proc
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def self.to_string(pair)
|
|
35
|
+
rec = lambda { |pair_inner|
|
|
36
|
+
return pair_inner.to_s unless pair?(pair_inner)
|
|
37
|
+
|
|
38
|
+
left = car(pair_inner)
|
|
39
|
+
right = cdr(pair_inner)
|
|
40
|
+
"(#{rec.call(left)}, #{rec.call(right)})"
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
rec.call(pair)
|
|
44
|
+
end
|
|
45
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: hexlet-pairs
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Hexlet
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-
|
|
11
|
+
date: 2021-04-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: A SICP'ish Functional Pairs implemented in Ruby.
|
|
14
14
|
email:
|
|
@@ -24,9 +24,9 @@ files:
|
|
|
24
24
|
- Gemfile.lock
|
|
25
25
|
- Makefile
|
|
26
26
|
- README.md
|
|
27
|
-
-
|
|
28
|
-
- lib/
|
|
29
|
-
- pairs.
|
|
27
|
+
- hexlet-pairs.gemspec
|
|
28
|
+
- lib/pairs.rb
|
|
29
|
+
- lib/pairs/version.rb
|
|
30
30
|
homepage: https://github.com/hexlet-components/ruby-pairs
|
|
31
31
|
licenses:
|
|
32
32
|
- MIT
|
|
@@ -34,7 +34,7 @@ metadata:
|
|
|
34
34
|
homepage_uri: https://github.com/hexlet-components/ruby-pairs
|
|
35
35
|
source_code_uri: https://github.com/hexlet-components/ruby-pairs
|
|
36
36
|
changelog_uri: https://github.com/hexlet-components/ruby-pairs
|
|
37
|
-
post_install_message:
|
|
37
|
+
post_install_message:
|
|
38
38
|
rdoc_options: []
|
|
39
39
|
require_paths:
|
|
40
40
|
- lib
|
|
@@ -49,8 +49,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
49
49
|
- !ruby/object:Gem::Version
|
|
50
50
|
version: '0'
|
|
51
51
|
requirements: []
|
|
52
|
-
rubygems_version: 3.0.
|
|
53
|
-
signing_key:
|
|
52
|
+
rubygems_version: 3.0.8
|
|
53
|
+
signing_key:
|
|
54
54
|
specification_version: 4
|
|
55
55
|
summary: Hexlet Ruby Pairs
|
|
56
56
|
test_files: []
|
data/lib/hexlet/pairs.rb
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
require "hexlet/pairs/version"
|
|
2
|
-
|
|
3
|
-
module Hexlet
|
|
4
|
-
module Pairs
|
|
5
|
-
def self.cons(left, right)
|
|
6
|
-
lambda { |message|
|
|
7
|
-
case message
|
|
8
|
-
when 'car'
|
|
9
|
-
left
|
|
10
|
-
when 'cdr'
|
|
11
|
-
right
|
|
12
|
-
else
|
|
13
|
-
raise "Unknown message #{message}"
|
|
14
|
-
end
|
|
15
|
-
}
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def self.check_pair(pair)
|
|
19
|
-
return if pair?(pair)
|
|
20
|
-
|
|
21
|
-
raise NoMethodError, pair.to_s
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def self.car(pair)
|
|
25
|
-
check_pair(pair)
|
|
26
|
-
pair.call('car')
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def self.cdr(pair)
|
|
30
|
-
pair.call('cdr')
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def self.pair?(pair)
|
|
34
|
-
pair.instance_of? Proc
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def self.to_string(pair)
|
|
38
|
-
rec = lambda { |pair_inner|
|
|
39
|
-
return pair_inner.to_s unless pair?(pair_inner)
|
|
40
|
-
|
|
41
|
-
left = car(pair_inner)
|
|
42
|
-
right = cdr(pair_inner)
|
|
43
|
-
"(#{rec.call(left)}, #{rec.call(right)})"
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
rec.call(pair)
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|