celsius 0.4.0 → 0.4.1
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/.travis.yml +6 -0
- data/Gemfile +2 -0
- data/README.md +1 -1
- data/lib/celsius/hash.rb +14 -0
- data/lib/celsius/version.rb +1 -1
- data/spec/celsius/hash_spec.rb +12 -0
- data/spec/spec_helper.rb +7 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c5d32b578f85a2e0fc6375d76348d545ec103fb
|
4
|
+
data.tar.gz: 8808342fa762eda0cf8dba9eea427945fd8a0255
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4910cc3d48e6ad488cebedaf7cf9a4b5c9b57c12ada486d62b4ced776643fad6cdafab6018b464d5b06e01808130d2bfe91f6d264e6b45cfaaa7e4f3c6d189db
|
7
|
+
data.tar.gz: 74827774d03aa7a2bbe810cf6735fd37f2e67da69531a035245c3f93980951ad911f4fa2adeb7115aa28254c05d5e96bf6f2d9c024fb678f45a26489d73ced0e
|
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Celsius [](https://codeclimate.com/github/ubpb/celsius)
|
1
|
+
# Celsius [](https://travis-ci.org/ubpb/celsius) [](https://codeclimate.com/github/ubpb/celsius) [](https://codeclimate.com/github/ubpb/celsius)
|
2
2
|
|
3
3
|
TODO: Write a gem description
|
4
4
|
|
data/lib/celsius/hash.rb
CHANGED
@@ -31,4 +31,18 @@ module Celsius::Hash
|
|
31
31
|
results.empty? ? nil : results
|
32
32
|
end
|
33
33
|
end
|
34
|
+
|
35
|
+
def self.smart_store(hash, key, value)
|
36
|
+
if hash[key]
|
37
|
+
unless hash[key].is_a?(Array)
|
38
|
+
hash[key] = [hash[key]]
|
39
|
+
end
|
40
|
+
|
41
|
+
hash[key].push(value)
|
42
|
+
else
|
43
|
+
hash[key] = value
|
44
|
+
end
|
45
|
+
|
46
|
+
hash
|
47
|
+
end
|
34
48
|
end
|
data/lib/celsius/version.rb
CHANGED
data/spec/celsius/hash_spec.rb
CHANGED
@@ -57,4 +57,16 @@ describe Celsius::Hash do
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
end
|
60
|
+
|
61
|
+
describe ".smart_store" do
|
62
|
+
it "stores a value with the given key" do
|
63
|
+
expect(described_class.smart_store({}, :key, "value")).to eq({key: "value"})
|
64
|
+
end
|
65
|
+
|
66
|
+
context "if the key allready exists" do
|
67
|
+
it "converts the value to an array and pushes the value to it" do
|
68
|
+
expect(described_class.smart_store({key: "foo"}, :key, "bar")).to eq({key: ["foo", "bar"]})
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
60
72
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: celsius
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Sievers
|
@@ -94,6 +94,7 @@ extra_rdoc_files: []
|
|
94
94
|
files:
|
95
95
|
- ".gitignore"
|
96
96
|
- ".rspec"
|
97
|
+
- ".travis.yml"
|
97
98
|
- Gemfile
|
98
99
|
- LICENSE.txt
|
99
100
|
- README.md
|
@@ -141,7 +142,7 @@ rubyforge_project:
|
|
141
142
|
rubygems_version: 2.4.5
|
142
143
|
signing_key:
|
143
144
|
specification_version: 4
|
144
|
-
summary: celsius-0.4.
|
145
|
+
summary: celsius-0.4.1
|
145
146
|
test_files:
|
146
147
|
- spec/assets/locales/de.yml
|
147
148
|
- spec/assets/locales/en.yml
|