pcbr 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pcbr.rb +4 -8
- data/pcbr.gemspec +9 -7
- data/spec/_spec.rb +12 -5
- metadata +13 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94c525ae292660782aa466569e23c274024e1220
|
4
|
+
data.tar.gz: 409faba010ccd426ad3f5cab17aa0f9470f680b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4caa489706874b4ff8bf10d9a535485f083b5e8566d5ee97317541fc3d3f2193ffd8e557e23f50140482d0fa3200e9d5557cc7ec2719e11d5f683a8be01f77e7
|
7
|
+
data.tar.gz: 6390f836a93fc357aa7c184d6df9fbf1ac007077ebb4fc08d0312600798407abbd9136cb3d98da8ddcf5f506852e62dd85d531f33a1ac27e4358f5484f199a7e
|
data/lib/pcbr.rb
CHANGED
@@ -1,8 +1,4 @@
|
|
1
|
-
require "deep_dup"
|
2
|
-
|
3
1
|
module PCBR
|
4
|
-
VERSION = "0.3.0"
|
5
|
-
|
6
2
|
class Error < RuntimeError
|
7
3
|
# def initialize body
|
8
4
|
# super "#{Module.nesting[1]} error: #{body}"
|
@@ -30,11 +26,11 @@ module PCBR
|
|
30
26
|
|
31
27
|
def store key, vector = nil
|
32
28
|
raise Error.new "duplicating key" if @table.assoc key
|
33
|
-
key =
|
34
|
-
vector = if vector
|
35
|
-
DeepDup.deep_dup vector
|
36
|
-
else
|
29
|
+
key = [NilClass, FalseClass, TrueClass, Numeric, Symbol, Method].any?{ |c| key.is_a? c } ? key : key.dup
|
30
|
+
vector = if vector.nil?
|
37
31
|
Array key
|
32
|
+
else
|
33
|
+
vector
|
38
34
|
end
|
39
35
|
score = 0
|
40
36
|
@table.each do |item|
|
data/pcbr.gemspec
CHANGED
@@ -1,17 +1,19 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "pcbr"
|
3
|
-
spec.version =
|
3
|
+
spec.version = "0.4.0"
|
4
|
+
spec.summary = "Pair Comparison Based Rating"
|
5
|
+
|
4
6
|
spec.author = "Victor Maslov"
|
5
7
|
spec.email = "nakilon@gmail.com"
|
6
|
-
spec.summary = "Pair Comparison Based Rating"
|
7
|
-
spec.description = "Making ratings is fun. After applying my method several times I've decided to gemify it."
|
8
|
-
spec.homepage = "https://github.com/Nakilon/pcbr"
|
9
8
|
spec.license = "MIT"
|
9
|
+
spec.homepage = "https://github.com/Nakilon/pcbr"
|
10
|
+
spec.description = <<-EOF
|
11
|
+
Making ratings is fun. After applying my method several times I've decided to gemify it.
|
12
|
+
This is one of the first gems I made so it's far for being nicely done.
|
13
|
+
EOF
|
10
14
|
|
11
|
-
spec.files = `git ls-files -z`.split("\x0")
|
12
15
|
spec.test_files = ["spec/"]
|
13
|
-
|
14
|
-
spec.add_dependency "deep_dup"
|
16
|
+
spec.files = `git ls-files -z`.split(?\0) - spec.test_files
|
15
17
|
|
16
18
|
spec.add_development_dependency "bundler"
|
17
19
|
spec.add_development_dependency "rspec", "~> 3.3.0"
|
data/spec/_spec.rb
CHANGED
@@ -83,16 +83,23 @@ describe "basic specs" do
|
|
83
83
|
expect{ rating.store 0 }.to raise_error PCBR::Error
|
84
84
|
end
|
85
85
|
|
86
|
-
example "keys
|
86
|
+
example "keys are dupped" do
|
87
87
|
rating = PCBR.new
|
88
88
|
a = [[1]]
|
89
89
|
v = [0]
|
90
90
|
rating.store a, v
|
91
91
|
a[0][0] = 2
|
92
|
-
rating.store [[
|
93
|
-
|
94
|
-
|
95
|
-
|
92
|
+
rating.store [[1]], [1]
|
93
|
+
expect(rating.sorted).to eq [[[1]], [[2]]]
|
94
|
+
end
|
95
|
+
|
96
|
+
example "keys are dupped but not deeply" do
|
97
|
+
rating = PCBR.new
|
98
|
+
a = [[1]]
|
99
|
+
v = [0]
|
100
|
+
rating.store a, v
|
101
|
+
a[0][0] = 2
|
102
|
+
expect{ rating.store [[2]], [1] }.to raise_error PCBR::Error
|
96
103
|
end
|
97
104
|
|
98
105
|
end
|
metadata
CHANGED
@@ -1,65 +1,52 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pcbr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor Maslov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: deep_dup
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - '>='
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - '>='
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: bundler
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
30
16
|
requirements:
|
31
|
-
- -
|
17
|
+
- - ">="
|
32
18
|
- !ruby/object:Gem::Version
|
33
19
|
version: '0'
|
34
20
|
type: :development
|
35
21
|
prerelease: false
|
36
22
|
version_requirements: !ruby/object:Gem::Requirement
|
37
23
|
requirements:
|
38
|
-
- -
|
24
|
+
- - ">="
|
39
25
|
- !ruby/object:Gem::Version
|
40
26
|
version: '0'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: rspec
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
44
30
|
requirements:
|
45
|
-
- - ~>
|
31
|
+
- - "~>"
|
46
32
|
- !ruby/object:Gem::Version
|
47
33
|
version: 3.3.0
|
48
34
|
type: :development
|
49
35
|
prerelease: false
|
50
36
|
version_requirements: !ruby/object:Gem::Requirement
|
51
37
|
requirements:
|
52
|
-
- - ~>
|
38
|
+
- - "~>"
|
53
39
|
- !ruby/object:Gem::Version
|
54
40
|
version: 3.3.0
|
55
|
-
description:
|
56
|
-
|
41
|
+
description: |2
|
42
|
+
Making ratings is fun. After applying my method several times I've decided to gemify it.
|
43
|
+
This is one of the first gems I made so it's far for being nicely done.
|
57
44
|
email: nakilon@gmail.com
|
58
45
|
executables: []
|
59
46
|
extensions: []
|
60
47
|
extra_rdoc_files: []
|
61
48
|
files:
|
62
|
-
- .rspec
|
49
|
+
- ".rspec"
|
63
50
|
- Gemfile
|
64
51
|
- README.md
|
65
52
|
- Rakefile
|
@@ -76,17 +63,17 @@ require_paths:
|
|
76
63
|
- lib
|
77
64
|
required_ruby_version: !ruby/object:Gem::Requirement
|
78
65
|
requirements:
|
79
|
-
- -
|
66
|
+
- - ">="
|
80
67
|
- !ruby/object:Gem::Version
|
81
68
|
version: 2.0.0
|
82
69
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
70
|
requirements:
|
84
|
-
- -
|
71
|
+
- - ">="
|
85
72
|
- !ruby/object:Gem::Version
|
86
73
|
version: '0'
|
87
74
|
requirements: []
|
88
75
|
rubyforge_project:
|
89
|
-
rubygems_version: 2.
|
76
|
+
rubygems_version: 2.5.2
|
90
77
|
signing_key:
|
91
78
|
specification_version: 4
|
92
79
|
summary: Pair Comparison Based Rating
|