crimp 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a3c9582fb50d4c24f80f495871d85326c8db1034
4
- data.tar.gz: 6965f4d813151e897087fd66aef13dbfa930221d
3
+ metadata.gz: f951279d5308025d1f3184b1a823a1577d13ebad
4
+ data.tar.gz: 9444429cbc53f722f053815ced9db784e29a5374
5
5
  SHA512:
6
- metadata.gz: b32357f31dff6cb09241cd676acbeb9aa027b472090444b6364631a661c3dab052f6c21db401b5e29ed97250b5b22e13ca4645e34e295f8e35e0fadb7ffebcc0
7
- data.tar.gz: 5b374574b25360818eef4946c7c24526be6dfe44d28d4d71f046a11e01c3a771b9f77826f1f910ce7dc4a43e3a136b4b2383dab1a904fdc801d9b680629d4027
6
+ metadata.gz: f91307d9094be916d32b3e95ca5c620db68979ec5d3eb465efaa2e0876df96543d51a43fad76331d20f04baa34ed254ab355587886ad66db7453badff1afcf3b
7
+ data.tar.gz: 092f330b087472fd4ebda5653ccb6ba86857597d205e71d15636562fd2ec2b2626cce2598b733d74acd7a7a637796148526f43d91e0bb569a67aee494ea3c98b
data/Guardfile CHANGED
@@ -1,6 +1,6 @@
1
1
  guard 'rspec' do
2
2
  watch(%r{^spec/.+_spec\.rb$})
3
3
  watch(%r{^lib/.+\.rb$})
4
- watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
5
- watch('spec/spec_helper.rb') { "spec" }
4
+ watch(%r{^spec/support/(.+)\.rb$}) { 'spec' }
5
+ watch('spec/spec_helper.rb') { 'spec' }
6
6
  end
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
- $:.unshift File.join(File.dirname(__FILE__), 'lib')
1
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), 'lib')
2
2
 
3
3
  require 'bundler/gem_tasks'
4
4
  require 'rake/rspec'
5
5
 
6
- task :default => :spec
6
+ task default: :spec
@@ -1,5 +1,5 @@
1
- require "crimp/version"
2
- require "digest"
1
+ require 'crimp/version'
2
+ require 'digest'
3
3
 
4
4
  module Crimp
5
5
  def self.signature(obj)
@@ -36,7 +36,7 @@ module Crimp
36
36
  end
37
37
 
38
38
  def self.parse_array(array)
39
- array.map! { |e| stringify(e) }.sort!
39
+ array.map { |e| stringify(e) }.sort
40
40
  end
41
41
 
42
42
  def self.parse_hash(hash)
@@ -44,6 +44,6 @@ module Crimp
44
44
  end
45
45
 
46
46
  def self.to_string(obj)
47
- "#{obj.to_s}#{obj.class.to_s}"
47
+ "#{obj}#{obj.class}"
48
48
  end
49
49
  end
@@ -1,3 +1,3 @@
1
1
  module Crimp
2
- VERSION = "0.1.1"
2
+ VERSION = '0.1.2'.freeze
3
3
  end
@@ -6,38 +6,38 @@ describe Crimp do
6
6
  context 'given a Hash' do
7
7
  let(:hash) do
8
8
  {
9
- :a => 123,
10
- :b => 1.23,
11
- :c => 'string',
12
- :d => :sym
9
+ a: 123,
10
+ b: 1.23,
11
+ c: 'string',
12
+ d: :sym
13
13
  }
14
14
  end
15
15
  let(:md5) { '1dd744d51279187cc08cabe240f98be2' }
16
16
 
17
- specify { expect(subject.signature hash).to eq md5 }
17
+ specify { expect(subject.signature(hash)).to eq md5 }
18
18
  end
19
19
 
20
20
  context 'given legacy Hash' do
21
21
  let(:hash) do
22
- {:a => {:b => 'b', :c => 'c'}, :d => 'd'}
22
+ { a: { b: 'b', c: 'c' }, d: 'd' }
23
23
  end
24
24
  let(:md5) { '68d07febc4f47f56fa6ef5de063a77b1' }
25
25
 
26
- specify { expect(subject.signature hash).to eq md5 }
26
+ specify { expect(subject.signature(hash)).to eq md5 }
27
27
  end
28
28
 
29
29
  context 'given an Array' do
30
30
  let(:array) { [123, 1.23, 'string', :sym] }
31
31
  let(:md5) { 'cd29980f258eef3faceca4f4da02ec65' }
32
32
 
33
- specify { expect(subject.signature array).to eq md5 }
33
+ specify { expect(subject.signature(array)).to eq md5 }
34
34
  end
35
35
 
36
36
  context 'given legacy Array' do
37
37
  let(:array) { [1, 2, 3, [4, [5, 6]]] }
38
38
  let(:md5) { '4dc4e1161c9315db0bc43c0201b3ec05' }
39
39
 
40
- specify { expect(subject.signature array).to eq md5 }
40
+ specify { expect(subject.signature(array)).to eq md5 }
41
41
  end
42
42
  end
43
43
  end
@@ -1,59 +1,79 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Crimp do
4
- let (:hash) { {:a => {:b => 'b', :c => 'c'}, :d => 'd'} }
5
- let (:hash_unordered) { {:d => 'd', :a => {:c => 'c', :b => 'b'}} }
4
+ let (:hash) { { a: { b: 'b', c: 'c' }, d: 'd' } }
5
+ let (:hash_unordered) { { d: 'd', a: { c: 'c', b: 'b' } } }
6
6
  let (:array) { [1, 2, 3, [4, [5, 6]]] }
7
7
  let (:array_unordered) { [3, 2, 1, [[5, 6], 4]] }
8
8
 
9
- describe ".signature" do
10
- context "given a Hash" do
11
- specify { expect(subject.signature hash).to be_a String }
9
+ describe '.signature' do
10
+ context 'given a Hash' do
11
+ specify { expect(subject.signature(hash)).to be_a String }
12
12
 
13
- it "returns MD5 hash of stringified Hash" do
14
- expect(
15
- subject.signature(hash)
16
- ).to eq(
17
- Digest::MD5.hexdigest(subject.stringify(hash))
18
- )
13
+ it 'returns MD5 hash of stringified Hash' do
14
+ expect(subject.signature(hash)).to eq(Digest::MD5.hexdigest(subject.stringify(hash)))
15
+ end
16
+
17
+ it 'does not modify original hash' do
18
+ original_hash = { d: 'd', a: { c: 'c', b: 'b' } }
19
+ expected_hash = { d: 'd', a: { c: 'c', b: 'b' } }
20
+
21
+ subject.signature(original_hash)
22
+
23
+ expect(original_hash).to eq(expected_hash)
19
24
  end
20
25
  end
21
26
 
22
- context "given an Array" do
23
- specify { expect(subject.signature array).to be_a String }
27
+ context 'given an Array' do
28
+ specify { expect(subject.signature(array)).to be_a String }
29
+
30
+ it 'returns MD5 hash of stringified Array' do
31
+ expect(subject.signature(array)).to eq(Digest::MD5.hexdigest(subject.stringify(array)))
32
+ end
33
+
34
+ it 'does not modify original array' do
35
+ original_array = [5, 4, 2, 6, [5, 7, 2]]
36
+ expected_array = [5, 4, 2, 6, [5, 7, 2]]
37
+
38
+ subject.signature(original_array)
24
39
 
25
- it "returns MD5 hash of stringified Array" do
26
- expect(
27
- subject.signature(array)
28
- ).to eq(
29
- Digest::MD5.hexdigest(subject.stringify(array))
30
- )
40
+ expect(original_array).to eq(expected_array)
31
41
  end
32
42
  end
33
43
  end
34
44
 
35
- describe ".stringify" do
36
- context "given a Hash" do
37
- specify { expect(subject.stringify hash).to be_a String }
45
+ describe '.stringify' do
46
+ context 'given a Hash' do
47
+ specify { expect(subject.stringify(hash)).to be_a String }
38
48
 
39
- it "returns equal strings for differently ordered hashes" do
40
- expect(
41
- subject.stringify(hash)
42
- ).to eq(
43
- subject.stringify(hash_unordered)
44
- )
49
+ it 'returns equal strings for differently ordered hashes' do
50
+ expect(subject.stringify(hash)).to eq(subject.stringify(hash_unordered))
51
+ end
52
+
53
+ it 'does not modify original hash' do
54
+ original_hash = { d: 'd', a: { c: 'c', b: 'b' } }
55
+ expected_hash = { d: 'd', a: { c: 'c', b: 'b' } }
56
+
57
+ subject.signature(original_hash)
58
+
59
+ expect(original_hash).to eq(expected_hash)
45
60
  end
46
61
  end
47
62
 
48
- context "given an Array" do
49
- specify { expect(subject.stringify array).to be_a String }
63
+ context 'given an Array' do
64
+ specify { expect(subject.stringify(array)).to be_a String }
65
+
66
+ it 'returns equal strings for differently ordered arrays' do
67
+ expect(subject.stringify(array)).to eq(subject.stringify(array_unordered))
68
+ end
69
+
70
+ it 'does not modify original array' do
71
+ original_array = [5, 4, 2, 6, [5, 7, 2]]
72
+ expected_array = [5, 4, 2, 6, [5, 7, 2]]
73
+
74
+ subject.signature(original_array)
50
75
 
51
- it "returns equal strings for differently ordered arrays" do
52
- expect(
53
- subject.stringify(array)
54
- ).to eq(
55
- subject.stringify(array_unordered)
56
- )
76
+ expect(original_array).to eq(expected_array)
57
77
  end
58
78
  end
59
79
  end
@@ -1,5 +1,4 @@
1
- $: << File.join(File.dirname(__FILE__),"..", "lib")
1
+ $LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
2
2
 
3
3
  require 'pry'
4
4
  require 'crimp'
5
-
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crimp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - BBC News
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-02 00:00:00.000000000 Z
11
+ date: 2017-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement