pcbr 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/lib/pcbr.rb +4 -8
  3. data/pcbr.gemspec +9 -7
  4. data/spec/_spec.rb +12 -5
  5. metadata +13 -26
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2ce39501eee28e4881d896c138a0049899912b8a
4
- data.tar.gz: 68060e95d3921de4b105fd48227fc776d93ff744
3
+ metadata.gz: 94c525ae292660782aa466569e23c274024e1220
4
+ data.tar.gz: 409faba010ccd426ad3f5cab17aa0f9470f680b7
5
5
  SHA512:
6
- metadata.gz: b7c3edd47fd4012722dffd750833187b5951943543aca19b3b507409f787f5ec60ea1e08adb337967770a9d4494ec8e0cc7d18337a0ae68230f0b42f226101be
7
- data.tar.gz: 93051d2392065a23d4cb2918c79771e11cb08a1c6df7a13489f6bc58fe2284beb5410b850eec86251f94eed3f28e015664c3bf9d93ea1e073965fcafd160003a
6
+ metadata.gz: 4caa489706874b4ff8bf10d9a535485f083b5e8566d5ee97317541fc3d3f2193ffd8e557e23f50140482d0fa3200e9d5557cc7ec2719e11d5f683a8be01f77e7
7
+ data.tar.gz: 6390f836a93fc357aa7c184d6df9fbf1ac007077ebb4fc08d0312600798407abbd9136cb3d98da8ddcf5f506852e62dd85d531f33a1ac27e4358f5484f199a7e
@@ -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 = DeepDup.deep_dup 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|
@@ -1,17 +1,19 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "pcbr"
3
- spec.version = (require_relative "lib/pcbr"; PCBR::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"
@@ -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 and vectors are dupped" do
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 [[2]], [1] # expect no PCBR::Error
93
- v[0] = 3
94
- rating.store [[3]], [2]
95
- expect(rating.sorted).to eq [[[3]], [[2]], [[1]]]
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.3.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: 2017-12-06 00:00:00.000000000 Z
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: Making ratings is fun. After applying my method several times I've decided
56
- to gemify it.
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.0.14.1
76
+ rubygems_version: 2.5.2
90
77
  signing_key:
91
78
  specification_version: 4
92
79
  summary: Pair Comparison Based Rating