lazier 3.5.0 → 3.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.DS_Store +0 -0
- data/CHANGELOG.md +4 -0
- data/doc/Lazier.html +1 -1
- data/doc/Lazier/Boolean.html +1 -1
- data/doc/Lazier/Configuration.html +1 -1
- data/doc/Lazier/DateTime.html +1 -1
- data/doc/Lazier/DateTime/ClassMethods.html +1 -1
- data/doc/Lazier/Exceptions.html +1 -1
- data/doc/Lazier/Exceptions/Debug.html +1 -1
- data/doc/Lazier/Exceptions/MissingTranslation.html +1 -1
- data/doc/Lazier/Hash.html +69 -36
- data/doc/Lazier/I18n.html +1 -1
- data/doc/Lazier/Localizer.html +1 -1
- data/doc/Lazier/Math.html +1 -1
- data/doc/Lazier/Math/ClassMethods.html +1 -1
- data/doc/Lazier/Object.html +1 -1
- data/doc/Lazier/Pathname.html +1 -1
- data/doc/Lazier/Settings.html +1 -1
- data/doc/Lazier/String.html +1 -1
- data/doc/Lazier/TimeZone.html +1 -1
- data/doc/Lazier/TimeZone/ClassMethods.html +1 -1
- data/doc/Lazier/Version.html +2 -2
- data/doc/_index.html +1 -1
- data/doc/file.README.html +1 -1
- data/doc/index.html +1 -1
- data/doc/top-level-namespace.html +1 -1
- data/lib/lazier/hash.rb +15 -4
- data/lib/lazier/version.rb +1 -1
- data/spec/lazier/configuration_spec.rb +3 -3
- data/spec/lazier/datetime_spec.rb +59 -59
- data/spec/lazier/hash_spec.rb +28 -27
- data/spec/lazier/i18n_spec.rb +21 -21
- data/spec/lazier/object_spec.rb +7 -7
- data/spec/lazier/pathname_spec.rb +2 -2
- data/spec/lazier/settings_spec.rb +43 -43
- data/spec/lazier/string_spec.rb +11 -11
- metadata +4 -3
data/spec/lazier/object_spec.rb
CHANGED
@@ -187,10 +187,10 @@ describe Lazier::Object do
|
|
187
187
|
end
|
188
188
|
|
189
189
|
it "should grant access" do
|
190
|
-
|
190
|
+
subject = {a: "b"}
|
191
191
|
|
192
|
-
expect(
|
193
|
-
|
192
|
+
expect(subject ).to receive(:ensure_access).with("ACCESS")
|
193
|
+
subject .ensure_hash("ACCESS")
|
194
194
|
end
|
195
195
|
end
|
196
196
|
|
@@ -329,10 +329,10 @@ describe Lazier::Object do
|
|
329
329
|
|
330
330
|
describe "#for_debug" do
|
331
331
|
it "should return the correct representation for an object" do
|
332
|
-
|
333
|
-
expect(
|
334
|
-
expect(
|
335
|
-
expect(
|
332
|
+
subject = {a: "b"}
|
333
|
+
expect(subject.for_debug(:json, false)).to eq(subject .to_json)
|
334
|
+
expect(subject.for_debug(:pretty_json, false)).to eq(::JSON.pretty_generate(subject ))
|
335
|
+
expect(subject.for_debug(:yaml, false)).to eq(subject .to_yaml)
|
336
336
|
end
|
337
337
|
|
338
338
|
it "should raise an exception if requested" do
|
@@ -7,7 +7,7 @@
|
|
7
7
|
require "spec_helper"
|
8
8
|
|
9
9
|
describe Lazier::Pathname do
|
10
|
-
|
10
|
+
subject { ::Pathname.new($0) }
|
11
11
|
|
12
12
|
before(:all) do
|
13
13
|
::Lazier.load!
|
@@ -15,7 +15,7 @@ describe Lazier::Pathname do
|
|
15
15
|
|
16
16
|
describe "#components" do
|
17
17
|
it "should return the components of the path" do
|
18
|
-
expect([""] +
|
18
|
+
expect([""] + subject.components).to eq(subject.to_s.split("/"))
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -7,9 +7,9 @@
|
|
7
7
|
require "spec_helper"
|
8
8
|
|
9
9
|
describe Lazier::Settings do
|
10
|
-
let(:
|
11
|
-
let(:
|
12
|
-
let(:
|
10
|
+
let(:subject) { ::Lazier::Settings.instance }
|
11
|
+
let(:number_subject) { 123456.654321 }
|
12
|
+
let(:date_subject) { DateTime.civil(2005, 6, 7, 8, 9, 10, DateTime.rationalize_offset(25200)) }
|
13
13
|
|
14
14
|
before(:all) do
|
15
15
|
Lazier.load!
|
@@ -45,86 +45,86 @@ describe Lazier::Settings do
|
|
45
45
|
|
46
46
|
describe "#setup_format_number" do
|
47
47
|
it "should save format numbering options for usage" do
|
48
|
-
|
49
|
-
expect(
|
48
|
+
subject.setup_format_number(2)
|
49
|
+
expect(number_subject.format_number).to eq("123,456.65")
|
50
50
|
|
51
|
-
|
52
|
-
expect(
|
51
|
+
subject.setup_format_number(3, "A")
|
52
|
+
expect(number_subject.format_number).to eq("123,456A654")
|
53
53
|
|
54
|
-
|
55
|
-
expect(
|
54
|
+
subject.setup_format_number(4, "A", "B")
|
55
|
+
expect(number_subject.format_number).to eq("123,456A6543 B")
|
56
56
|
|
57
|
-
|
58
|
-
expect(
|
57
|
+
subject.setup_format_number(5, "A", "B", "C")
|
58
|
+
expect(number_subject.format_number).to eq("123C456A65432 B")
|
59
59
|
|
60
|
-
|
61
|
-
expect(
|
60
|
+
subject.setup_format_number
|
61
|
+
expect(number_subject.format_number).to eq("123,456.65")
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
65
|
describe "#setup_boolean_names" do
|
66
66
|
it "should save names for boolean values" do
|
67
|
-
|
67
|
+
subject.setup_boolean_names("TRUE1")
|
68
68
|
expect([true.format_boolean, false.format_boolean]).to eq(["TRUE1", "No"])
|
69
69
|
|
70
|
-
|
70
|
+
subject.setup_boolean_names(nil, "FALSE1")
|
71
71
|
expect([true.format_boolean, false.format_boolean]).to eq(["Yes", "FALSE1"])
|
72
72
|
|
73
|
-
|
73
|
+
subject.setup_boolean_names("TRUE2", "FALSE2")
|
74
74
|
expect([true.format_boolean, false.format_boolean]).to eq(["TRUE2", "FALSE2"])
|
75
75
|
|
76
|
-
|
76
|
+
subject.setup_boolean_names
|
77
77
|
expect([true.format_boolean, false.format_boolean]).to eq(["Yes", "No"])
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
81
|
describe "#setup_date_formats" do
|
82
82
|
it "should save formats for date formatting" do
|
83
|
-
|
83
|
+
subject.setup_date_formats(nil, true)
|
84
84
|
|
85
|
-
|
86
|
-
expect(
|
87
|
-
expect(
|
85
|
+
subject.setup_date_formats({c1: "%Y"})
|
86
|
+
expect(date_subject.lstrftime(:ct_date)).to eq(date_subject.strftime("%Y-%m-%d"))
|
87
|
+
expect(date_subject.lstrftime("c1")).to eq(date_subject.year.to_s)
|
88
88
|
|
89
|
-
|
90
|
-
expect(
|
91
|
-
expect(
|
89
|
+
subject.setup_date_formats({c1: "%Y"}, true)
|
90
|
+
expect(date_subject.lstrftime("ct_date")).to eq("ct_date")
|
91
|
+
expect(date_subject.lstrftime(:c1)).to eq(date_subject.year.to_s)
|
92
92
|
|
93
|
-
|
94
|
-
expect(
|
95
|
-
expect(
|
93
|
+
subject.setup_date_formats
|
94
|
+
expect(date_subject.lstrftime(:ct_date)).to eq(date_subject.strftime("%Y-%m-%d"))
|
95
|
+
expect(date_subject.lstrftime("c1")).to eq(date_subject.year.to_s)
|
96
96
|
|
97
|
-
|
98
|
-
expect(
|
99
|
-
expect(
|
97
|
+
subject.setup_date_formats(nil, true)
|
98
|
+
expect(date_subject.lstrftime("ct_date")).to eq(date_subject.strftime("%Y-%m-%d"))
|
99
|
+
expect(date_subject.lstrftime(:c1)).to eq("c1")
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
103
103
|
describe "#setup_date_names" do
|
104
104
|
it "should save names for days and months" do
|
105
|
-
|
106
|
-
|
107
|
-
|
105
|
+
subject.i18n = :en
|
106
|
+
subject.setup_date_names
|
107
|
+
subject.setup_date_formats({sdn: "%B %b %A %a"})
|
108
108
|
|
109
109
|
long_months = 12.times.map {|i| (i + 1).to_s * 2}
|
110
110
|
short_months = 12.times.map {|i| (i + 1).to_s}
|
111
111
|
long_days = 7.times.map {|i| (i + 1).to_s * 2}
|
112
112
|
short_days = 7.times.map {|i| (i + 1).to_s}
|
113
113
|
|
114
|
-
|
115
|
-
expect(
|
114
|
+
subject.setup_date_names(long_months)
|
115
|
+
expect(date_subject.lstrftime(:sdn)).to eq("66 Jun Tuesday Tue")
|
116
116
|
|
117
|
-
|
118
|
-
expect(
|
117
|
+
subject.setup_date_names(long_months, short_months)
|
118
|
+
expect(date_subject.lstrftime("sdn")).to eq("66 6 Tuesday Tue")
|
119
119
|
|
120
|
-
|
121
|
-
expect(
|
120
|
+
subject.setup_date_names(long_months, short_months, long_days)
|
121
|
+
expect(date_subject.lstrftime(:sdn)).to eq("66 6 33 Tue")
|
122
122
|
|
123
|
-
|
124
|
-
expect(
|
123
|
+
subject.setup_date_names(long_months, short_months, long_days, short_days)
|
124
|
+
expect(date_subject.lstrftime("sdn")).to eq("66 6 33 3")
|
125
125
|
|
126
|
-
|
127
|
-
expect(
|
126
|
+
subject.setup_date_names
|
127
|
+
expect(date_subject.lstrftime(:sdn)).to eq("June Jun Tuesday Tue")
|
128
128
|
end
|
129
129
|
end
|
130
130
|
end
|
data/spec/lazier/string_spec.rb
CHANGED
@@ -7,10 +7,10 @@
|
|
7
7
|
require "spec_helper"
|
8
8
|
|
9
9
|
describe Lazier::String do
|
10
|
-
|
11
|
-
let(:
|
12
|
-
let(:
|
13
|
-
let(:
|
10
|
+
subject { "abc òùà èé >" }
|
11
|
+
let(:translated_subject) { "abc oua ee >" }
|
12
|
+
let(:untitleized_subject) { "abc-òùà-èé->" }
|
13
|
+
let(:amp_subject) { "abc òùà èé >" }
|
14
14
|
|
15
15
|
before(:all) do
|
16
16
|
::Lazier.load!
|
@@ -18,7 +18,7 @@ describe Lazier::String do
|
|
18
18
|
|
19
19
|
describe "#remove_accents" do
|
20
20
|
it "should translate accents" do
|
21
|
-
expect(
|
21
|
+
expect(subject.remove_accents).to eq(translated_subject)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -38,22 +38,22 @@ describe Lazier::String do
|
|
38
38
|
|
39
39
|
describe "#untitleize" do
|
40
40
|
it "should convert spaces to dashes" do
|
41
|
-
expect(
|
41
|
+
expect(subject.untitleize).to eq(untitleized_subject)
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
45
|
describe "#replace_ampersands" do
|
46
46
|
it "should remove HTML ampersands" do
|
47
|
-
expect(
|
47
|
+
expect(subject.replace_ampersands).to eq(amp_subject)
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
51
|
describe "#value" do
|
52
52
|
it "should return the string itself" do
|
53
|
-
expect(
|
54
|
-
expect(
|
55
|
-
expect(
|
56
|
-
expect(
|
53
|
+
expect(subject.value).to eq(subject)
|
54
|
+
expect(translated_subject.value).to eq(translated_subject)
|
55
|
+
expect(untitleized_subject.value).to eq(untitleized_subject)
|
56
|
+
expect(amp_subject.value).to eq(amp_subject)
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lazier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.5.
|
4
|
+
version: 3.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shogun
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -87,6 +87,7 @@ executables: []
|
|
87
87
|
extensions: []
|
88
88
|
extra_rdoc_files: []
|
89
89
|
files:
|
90
|
+
- ".DS_Store"
|
90
91
|
- ".gitignore"
|
91
92
|
- ".travis-gemfile"
|
92
93
|
- ".travis.yml"
|
@@ -180,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
180
181
|
version: '0'
|
181
182
|
requirements: []
|
182
183
|
rubyforge_project: lazier
|
183
|
-
rubygems_version: 2.2.
|
184
|
+
rubygems_version: 2.2.2
|
184
185
|
signing_key:
|
185
186
|
specification_version: 4
|
186
187
|
summary: Several Ruby object enhancements.
|