baudelaire 0.1.0 → 0.1.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/Gemfile.lock +26 -18
- data/README.md +13 -0
- data/lib/baudelaire/model_extension.rb +14 -2
- data/lib/baudelaire/version.rb +1 -1
- data/spec/baudelaire/model_extension_spec.rb +8 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d440186770a571a22ed9591322a9be539af04fea
|
4
|
+
data.tar.gz: dbe373fccb619757350bff7df50bad7a56051f98
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: acfff6e407a97710caacf3f72dc6aab6f8919440b9f575795508b408e3c2eceaf207e158a7d19924275ad6f3433cd825653b931ac120e5e4ed49e18fd1a2463d
|
7
|
+
data.tar.gz: 6eb95a261a1d149bfdd711af350eac0d52da6b72250ffcaf426dd7f7fcf5663542abd9bab9abd6aebdc6437af2866d0a34795f74bd6b4eacc88c8733a21a1045
|
data/Gemfile.lock
CHANGED
@@ -1,28 +1,31 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
baudelaire (0.1.
|
4
|
+
baudelaire (0.1.1)
|
5
5
|
activerecord
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: http://rubygems.org/
|
9
9
|
specs:
|
10
|
-
activemodel (
|
11
|
-
activesupport (=
|
12
|
-
builder (~> 3.
|
13
|
-
activerecord (
|
14
|
-
activemodel (=
|
15
|
-
activesupport (=
|
16
|
-
arel (~>
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
10
|
+
activemodel (4.2.4)
|
11
|
+
activesupport (= 4.2.4)
|
12
|
+
builder (~> 3.1)
|
13
|
+
activerecord (4.2.4)
|
14
|
+
activemodel (= 4.2.4)
|
15
|
+
activesupport (= 4.2.4)
|
16
|
+
arel (~> 6.0)
|
17
|
+
activesupport (4.2.4)
|
18
|
+
i18n (~> 0.7)
|
19
|
+
json (~> 1.7, >= 1.7.7)
|
20
|
+
minitest (~> 5.1)
|
21
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
22
|
+
tzinfo (~> 1.1)
|
23
|
+
arel (6.0.3)
|
24
|
+
builder (3.2.2)
|
23
25
|
diff-lcs (1.2.5)
|
24
|
-
i18n (0.
|
25
|
-
|
26
|
+
i18n (0.7.0)
|
27
|
+
json (1.8.3)
|
28
|
+
minitest (5.8.4)
|
26
29
|
rake (10.3.2)
|
27
30
|
rspec (2.14.1)
|
28
31
|
rspec-core (~> 2.14.0)
|
@@ -32,8 +35,10 @@ GEM
|
|
32
35
|
rspec-expectations (2.14.5)
|
33
36
|
diff-lcs (>= 1.1.3, < 2.0)
|
34
37
|
rspec-mocks (2.14.6)
|
35
|
-
sqlite3 (1.3.
|
36
|
-
|
38
|
+
sqlite3 (1.3.11)
|
39
|
+
thread_safe (0.3.5)
|
40
|
+
tzinfo (1.2.2)
|
41
|
+
thread_safe (~> 0.1)
|
37
42
|
|
38
43
|
PLATFORMS
|
39
44
|
ruby
|
@@ -43,3 +48,6 @@ DEPENDENCIES
|
|
43
48
|
rake
|
44
49
|
rspec
|
45
50
|
sqlite3
|
51
|
+
|
52
|
+
BUNDLED WITH
|
53
|
+
1.10.6
|
data/README.md
CHANGED
@@ -37,6 +37,18 @@ Then you will be able to do something like:
|
|
37
37
|
tv_show.kind = 'drama'
|
38
38
|
tv_show.kind # will return :drama
|
39
39
|
|
40
|
+
Then you will be able to do something like:
|
41
|
+
|
42
|
+
tv_show = TvShow.new
|
43
|
+
tv_show.kind = 'drama'
|
44
|
+
tv_show.kind # will return :drama
|
45
|
+
|
46
|
+
Also, from version 0.1.1, empty strings are exposed as nils:
|
47
|
+
|
48
|
+
tv_show = TvShow.new
|
49
|
+
tv_show.kind = ''
|
50
|
+
tv_show.kind # will return nil
|
51
|
+
|
40
52
|
TODO
|
41
53
|
----
|
42
54
|
|
@@ -45,4 +57,5 @@ Do you have something in mind? Issue a PR! Bonus points for testing :)
|
|
45
57
|
Changelog
|
46
58
|
---------
|
47
59
|
|
60
|
+
* v.0.1.1 Now, empty strings are exposed as nils
|
48
61
|
* v.0.1.0 Basic feature: getters and setters for symbolized attributes
|
@@ -14,11 +14,23 @@ module Baudelaire
|
|
14
14
|
|
15
15
|
define_method(:"#{field}") do
|
16
16
|
value = self[field]
|
17
|
-
|
18
|
-
value
|
17
|
+
|
18
|
+
if is_symbolizable?(value)
|
19
|
+
value = value.to_sym
|
20
|
+
else
|
21
|
+
nil
|
22
|
+
end
|
19
23
|
end
|
20
24
|
end
|
21
25
|
end
|
22
26
|
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def is_symbolizable?(value)
|
31
|
+
return false if value == :""
|
32
|
+
|
33
|
+
!value.nil?
|
34
|
+
end
|
23
35
|
end
|
24
36
|
end
|
data/lib/baudelaire/version.rb
CHANGED
@@ -44,6 +44,14 @@ describe :symbolize do
|
|
44
44
|
it "should return the symbolized string" do
|
45
45
|
@tv_show.kind.should == :drama
|
46
46
|
end
|
47
|
+
|
48
|
+
context "which is empty" do
|
49
|
+
before { @tv_show.kind = '' }
|
50
|
+
|
51
|
+
it "should return nil" do
|
52
|
+
@tv_show.kind.should be_nil
|
53
|
+
end
|
54
|
+
end
|
47
55
|
end
|
48
56
|
|
49
57
|
context "when being a symbol" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: baudelaire
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Albert Bellonch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
109
|
version: '0'
|
110
110
|
requirements: []
|
111
111
|
rubyforge_project: baudelaire
|
112
|
-
rubygems_version: 2.
|
112
|
+
rubygems_version: 2.4.5.1
|
113
113
|
signing_key:
|
114
114
|
specification_version: 4
|
115
115
|
summary: A string symbolizer
|