lazier 4.0.0 → 4.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis-gemfile +1 -2
- data/Gemfile +1 -2
- data/doc/Lazier/Boolean.html +1 -1
- data/doc/Lazier/Configuration.html +1 -1
- data/doc/Lazier/DateTime/ClassMethods.html +1 -1
- data/doc/Lazier/DateTime.html +1 -1
- data/doc/Lazier/Exceptions/Debug.html +1 -1
- data/doc/Lazier/Exceptions/MissingTranslation.html +1 -1
- data/doc/Lazier/Exceptions/TranslationExceptionHandler.html +1 -1
- data/doc/Lazier/Exceptions.html +1 -1
- data/doc/Lazier/Hash.html +1 -1
- data/doc/Lazier/I18n.html +34 -24
- data/doc/Lazier/Math/ClassMethods.html +1 -1
- data/doc/Lazier/Math.html +1 -1
- data/doc/Lazier/Object.html +1 -1
- data/doc/Lazier/Pathname.html +1 -1
- data/doc/Lazier/Settings.html +172 -34
- data/doc/Lazier/String.html +1 -1
- data/doc/Lazier/TimeZone/ClassMethods.html +1 -1
- data/doc/Lazier/TimeZone.html +1 -1
- data/doc/Lazier/Version.html +2 -2
- data/doc/Lazier.html +83 -75
- 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/lazier.gemspec +1 -1
- data/lib/lazier/i18n.rb +1 -0
- data/lib/lazier/settings.rb +15 -2
- data/lib/lazier/version.rb +1 -1
- data/lib/lazier.rb +40 -32
- data/spec/lazier/boolean_spec.rb +1 -1
- data/spec/lazier/datetime_spec.rb +1 -1
- data/spec/lazier/hash_spec.rb +2 -2
- data/spec/lazier/i18n_spec.rb +17 -11
- data/spec/lazier/math_spec.rb +1 -1
- data/spec/lazier/object_spec.rb +1 -1
- data/spec/lazier/pathname_spec.rb +1 -1
- data/spec/lazier/settings_spec.rb +1 -1
- data/spec/lazier/string_spec.rb +1 -1
- data/spec/lazier/timezone_spec.rb +1 -1
- metadata +4 -4
data/doc/Lazier.html
CHANGED
@@ -523,13 +523,13 @@ otherwise the duration alone as a number.</p>
|
|
523
523
|
<pre class="lines">
|
524
524
|
|
525
525
|
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
526
|
+
144
|
527
|
+
145
|
528
|
+
146
|
529
|
+
147</pre>
|
530
530
|
</td>
|
531
531
|
<td>
|
532
|
-
<pre class="code"><span class="info file"># File 'lib/lazier.rb', line
|
532
|
+
<pre class="code"><span class="info file"># File 'lib/lazier.rb', line 144</span>
|
533
533
|
|
534
534
|
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_benchmark'>benchmark</span><span class='lparen'>(</span><span class='label'>message:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>precision:</span> <span class='int'>0</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
535
535
|
<span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='const'>Benchmark</span><span class='period'>.</span><span class='id identifier rubyid_ms'>ms</span><span class='lparen'>(</span><span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
@@ -636,18 +636,18 @@ Otherwise the class of the object will returned.</p>
|
|
636
636
|
<pre class="lines">
|
637
637
|
|
638
638
|
|
639
|
-
122
|
640
|
-
123
|
641
|
-
124
|
642
|
-
125
|
643
|
-
126
|
644
639
|
127
|
645
640
|
128
|
646
641
|
129
|
647
|
-
130
|
642
|
+
130
|
643
|
+
131
|
644
|
+
132
|
645
|
+
133
|
646
|
+
134
|
647
|
+
135</pre>
|
648
648
|
</td>
|
649
649
|
<td>
|
650
|
-
<pre class="code"><span class="info file"># File 'lib/lazier.rb', line
|
650
|
+
<pre class="code"><span class="info file"># File 'lib/lazier.rb', line 127</span>
|
651
651
|
|
652
652
|
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_find_class'>find_class</span><span class='lparen'>(</span><span class='id identifier rubyid_cls'>cls</span><span class='comma'>,</span> <span class='id identifier rubyid_scope'>scope</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>::@</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_only_in_scope'>only_in_scope</span> <span class='op'>=</span> <span class='kw'>false</span><span class='rparen'>)</span>
|
653
653
|
<span class='kw'>if</span> <span class='lbracket'>[</span><span class='op'>::</span><span class='const'>String</span><span class='comma'>,</span> <span class='op'>::</span><span class='const'>Symbol</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_cls'>cls</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='rparen'>)</span>
|
@@ -733,21 +733,21 @@ Otherwise the class of the object will returned.</p>
|
|
733
733
|
<pre class="lines">
|
734
734
|
|
735
735
|
|
736
|
-
53
|
737
736
|
54
|
738
737
|
55
|
739
738
|
56
|
740
739
|
57
|
741
740
|
58
|
742
741
|
59
|
743
|
-
60
|
742
|
+
60
|
743
|
+
61</pre>
|
744
744
|
</td>
|
745
745
|
<td>
|
746
|
-
<pre class="code"><span class="info file"># File 'lib/lazier.rb', line
|
746
|
+
<pre class="code"><span class="info file"># File 'lib/lazier.rb', line 54</span>
|
747
747
|
|
748
748
|
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_load!'>load!</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_what'>what</span><span class='rparen'>)</span>
|
749
749
|
<span class='id identifier rubyid_valid_modules'>valid_modules</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='symbol'>:object</span><span class='comma'>,</span> <span class='symbol'>:boolean</span><span class='comma'>,</span> <span class='symbol'>:string</span><span class='comma'>,</span> <span class='symbol'>:hash</span><span class='comma'>,</span> <span class='symbol'>:datetime</span><span class='comma'>,</span> <span class='symbol'>:math</span><span class='comma'>,</span> <span class='symbol'>:pathname</span><span class='rbracket'>]</span>
|
750
|
-
<span class='id identifier rubyid_modules'>modules</span> <span class='op'>=</span> <span class='id identifier rubyid_what'>what</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>?</span> <span class='id identifier rubyid_what'>what</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&</span><span class='symbol'>:
|
750
|
+
<span class='id identifier rubyid_modules'>modules</span> <span class='op'>=</span> <span class='id identifier rubyid_what'>what</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>?</span> <span class='id identifier rubyid_what'>what</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&</span><span class='symbol'>:to_sym</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_valid_modules'>valid_modules</span>
|
751
751
|
<span class='lparen'>(</span><span class='id identifier rubyid_modules'>modules</span> <span class='op'>&</span> <span class='id identifier rubyid_valid_modules'>valid_modules</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_w'>w</span><span class='op'>|</span> <span class='op'>::</span><span class='const'>Lazier</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>load_</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_w'>w</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='rbrace'>}</span>
|
752
752
|
|
753
753
|
<span class='kw'>yield</span> <span class='kw'>if</span> <span class='id identifier rubyid_block_given?'>block_given?</span>
|
@@ -783,8 +783,6 @@ Otherwise the class of the object will returned.</p>
|
|
783
783
|
<pre class="lines">
|
784
784
|
|
785
785
|
|
786
|
-
68
|
787
|
-
69
|
788
786
|
70
|
789
787
|
71
|
790
788
|
72
|
@@ -793,20 +791,20 @@ Otherwise the class of the object will returned.</p>
|
|
793
791
|
75
|
794
792
|
76
|
795
793
|
77
|
796
|
-
78
|
794
|
+
78
|
795
|
+
79</pre>
|
797
796
|
</td>
|
798
797
|
<td>
|
799
|
-
<pre class="code"><span class="info file"># File 'lib/lazier.rb', line
|
798
|
+
<pre class="code"><span class="info file"># File 'lib/lazier.rb', line 70</span>
|
800
799
|
|
801
800
|
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_load_boolean'>load_boolean</span>
|
802
|
-
<span class='
|
803
|
-
<span class='
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
<span class='
|
809
|
-
<span class='id identifier rubyid_include'>include</span> <span class='op'>::</span><span class='const'>Lazier</span><span class='op'>::</span><span class='const'>Boolean</span>
|
801
|
+
<span class='id identifier rubyid_perform_load'>perform_load</span><span class='lparen'>(</span><span class='symbol'>:boolean</span><span class='rparen'>)</span> <span class='kw'>do</span>
|
802
|
+
<span class='lbracket'>[</span><span class='op'>::</span><span class='const'>TrueClass</span><span class='comma'>,</span> <span class='op'>::</span><span class='const'>FalseClass</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_klass'>klass</span><span class='op'>|</span>
|
803
|
+
<span class='id identifier rubyid_klass'>klass</span><span class='period'>.</span><span class='id identifier rubyid_class_eval'>class_eval</span> <span class='kw'>do</span>
|
804
|
+
<span class='id identifier rubyid_include'>include</span> <span class='op'>::</span><span class='const'>Lazier</span><span class='op'>::</span><span class='const'>Object</span>
|
805
|
+
<span class='id identifier rubyid_include'>include</span> <span class='op'>::</span><span class='const'>Lazier</span><span class='op'>::</span><span class='const'>Boolean</span>
|
806
|
+
<span class='kw'>end</span>
|
807
|
+
<span class='kw'>end</span>
|
810
808
|
<span class='kw'>end</span>
|
811
809
|
<span class='kw'>end</span></pre>
|
812
810
|
</td>
|
@@ -839,27 +837,31 @@ Otherwise the class of the object will returned.</p>
|
|
839
837
|
<pre class="lines">
|
840
838
|
|
841
839
|
|
842
|
-
93
|
843
|
-
94
|
844
|
-
95
|
845
|
-
96
|
846
840
|
97
|
847
841
|
98
|
848
842
|
99
|
849
843
|
100
|
850
|
-
101
|
844
|
+
101
|
845
|
+
102
|
846
|
+
103
|
847
|
+
104
|
848
|
+
105
|
849
|
+
106
|
850
|
+
107</pre>
|
851
851
|
</td>
|
852
852
|
<td>
|
853
|
-
<pre class="code"><span class="info file"># File 'lib/lazier.rb', line
|
853
|
+
<pre class="code"><span class="info file"># File 'lib/lazier.rb', line 97</span>
|
854
854
|
|
855
855
|
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_load_datetime'>load_datetime</span>
|
856
856
|
<span class='const'>Lazier</span><span class='period'>.</span><span class='id identifier rubyid_load_object'>load_object</span>
|
857
857
|
|
858
|
-
<span class='
|
859
|
-
<span class='
|
860
|
-
|
858
|
+
<span class='id identifier rubyid_perform_load'>perform_load</span><span class='lparen'>(</span><span class='symbol'>:datetime</span><span class='rparen'>)</span> <span class='kw'>do</span>
|
859
|
+
<span class='lbracket'>[</span><span class='op'>::</span><span class='const'>Time</span><span class='comma'>,</span> <span class='op'>::</span><span class='const'>Date</span><span class='comma'>,</span> <span class='op'>::</span><span class='const'>DateTime</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_c'>c</span><span class='op'>|</span>
|
860
|
+
<span class='id identifier rubyid_c'>c</span><span class='period'>.</span><span class='id identifier rubyid_class_eval'>class_eval</span> <span class='lbrace'>{</span> <span class='id identifier rubyid_include'>include</span> <span class='op'>::</span><span class='const'>Lazier</span><span class='op'>::</span><span class='const'>DateTime</span> <span class='rbrace'>}</span>
|
861
|
+
<span class='kw'>end</span>
|
861
862
|
|
862
|
-
|
863
|
+
<span class='op'>::</span><span class='const'>ActiveSupport</span><span class='op'>::</span><span class='const'>TimeZone</span><span class='period'>.</span><span class='id identifier rubyid_class_eval'>class_eval</span> <span class='lbrace'>{</span> <span class='id identifier rubyid_include'>include</span> <span class='op'>::</span><span class='const'>Lazier</span><span class='op'>::</span><span class='const'>TimeZone</span> <span class='rbrace'>}</span>
|
864
|
+
<span class='kw'>end</span>
|
863
865
|
<span class='kw'>end</span></pre>
|
864
866
|
</td>
|
865
867
|
</tr>
|
@@ -891,19 +893,25 @@ Otherwise the class of the object will returned.</p>
|
|
891
893
|
<pre class="lines">
|
892
894
|
|
893
895
|
|
894
|
-
86
|
895
896
|
87
|
896
897
|
88
|
897
898
|
89
|
898
|
-
90
|
899
|
+
90
|
900
|
+
91
|
901
|
+
92
|
902
|
+
93
|
903
|
+
94</pre>
|
899
904
|
</td>
|
900
905
|
<td>
|
901
|
-
<pre class="code"><span class="info file"># File 'lib/lazier.rb', line
|
906
|
+
<pre class="code"><span class="info file"># File 'lib/lazier.rb', line 87</span>
|
902
907
|
|
903
908
|
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_load_hash'>load_hash</span>
|
904
|
-
<span class='id identifier rubyid_clean_hash_compact'>clean_hash_compact</span>
|
905
909
|
<span class='const'>Lazier</span><span class='period'>.</span><span class='id identifier rubyid_load_object'>load_object</span>
|
906
|
-
|
910
|
+
|
911
|
+
<span class='id identifier rubyid_perform_load'>perform_load</span><span class='lparen'>(</span><span class='symbol'>:hash</span><span class='rparen'>)</span> <span class='kw'>do</span>
|
912
|
+
<span class='id identifier rubyid_clean_hash_compact'>clean_hash_compact</span>
|
913
|
+
<span class='op'>::</span><span class='const'>Hash</span><span class='period'>.</span><span class='id identifier rubyid_class_eval'>class_eval</span> <span class='lbrace'>{</span> <span class='id identifier rubyid_include'>include</span> <span class='op'>::</span><span class='const'>Lazier</span><span class='op'>::</span><span class='const'>Hash</span> <span class='rbrace'>}</span>
|
914
|
+
<span class='kw'>end</span>
|
907
915
|
<span class='kw'>end</span></pre>
|
908
916
|
</td>
|
909
917
|
</tr>
|
@@ -935,17 +943,17 @@ Otherwise the class of the object will returned.</p>
|
|
935
943
|
<pre class="lines">
|
936
944
|
|
937
945
|
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
946
|
+
110
|
947
|
+
111
|
948
|
+
112
|
949
|
+
113</pre>
|
942
950
|
</td>
|
943
951
|
<td>
|
944
|
-
<pre class="code"><span class="info file"># File 'lib/lazier.rb', line
|
952
|
+
<pre class="code"><span class="info file"># File 'lib/lazier.rb', line 110</span>
|
945
953
|
|
946
954
|
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_load_math'>load_math</span>
|
947
955
|
<span class='const'>Lazier</span><span class='period'>.</span><span class='id identifier rubyid_load_object'>load_object</span>
|
948
|
-
<span class='
|
956
|
+
<span class='id identifier rubyid_perform_load'>perform_load</span><span class='lparen'>(</span><span class='symbol'>:math</span><span class='comma'>,</span> <span class='op'>::</span><span class='const'>Math</span><span class='comma'>,</span> <span class='op'>::</span><span class='const'>Lazier</span><span class='op'>::</span><span class='const'>Math</span><span class='rparen'>)</span>
|
949
957
|
<span class='kw'>end</span></pre>
|
950
958
|
</td>
|
951
959
|
</tr>
|
@@ -977,15 +985,17 @@ Otherwise the class of the object will returned.</p>
|
|
977
985
|
<pre class="lines">
|
978
986
|
|
979
987
|
|
980
|
-
63
|
981
988
|
64
|
982
|
-
65
|
989
|
+
65
|
990
|
+
66
|
991
|
+
67</pre>
|
983
992
|
</td>
|
984
993
|
<td>
|
985
|
-
<pre class="code"><span class="info file"># File 'lib/lazier.rb', line
|
994
|
+
<pre class="code"><span class="info file"># File 'lib/lazier.rb', line 64</span>
|
986
995
|
|
987
996
|
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_load_object'>load_object</span>
|
988
|
-
<span class='
|
997
|
+
<span class='const'>Lazier</span><span class='period'>.</span><span class='id identifier rubyid_load_boolean'>load_boolean</span>
|
998
|
+
<span class='id identifier rubyid_perform_load'>perform_load</span><span class='lparen'>(</span><span class='symbol'>:object</span><span class='comma'>,</span> <span class='op'>::</span><span class='const'>Object</span><span class='comma'>,</span> <span class='op'>::</span><span class='const'>Lazier</span><span class='op'>::</span><span class='const'>Object</span><span class='rparen'>)</span>
|
989
999
|
<span class='kw'>end</span></pre>
|
990
1000
|
</td>
|
991
1001
|
</tr>
|
@@ -1017,17 +1027,15 @@ Otherwise the class of the object will returned.</p>
|
|
1017
1027
|
<pre class="lines">
|
1018
1028
|
|
1019
1029
|
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
1023
|
-
113</pre>
|
1030
|
+
116
|
1031
|
+
117
|
1032
|
+
118</pre>
|
1024
1033
|
</td>
|
1025
1034
|
<td>
|
1026
|
-
<pre class="code"><span class="info file"># File 'lib/lazier.rb', line
|
1035
|
+
<pre class="code"><span class="info file"># File 'lib/lazier.rb', line 116</span>
|
1027
1036
|
|
1028
1037
|
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_load_pathname'>load_pathname</span>
|
1029
|
-
<span class='id identifier
|
1030
|
-
<span class='op'>::</span><span class='const'>Pathname</span><span class='period'>.</span><span class='id identifier rubyid_class_eval'>class_eval</span> <span class='lbrace'>{</span> <span class='id identifier rubyid_include'>include</span> <span class='op'>::</span><span class='const'>Lazier</span><span class='op'>::</span><span class='const'>Pathname</span> <span class='rbrace'>}</span>
|
1038
|
+
<span class='id identifier rubyid_perform_load'>perform_load</span><span class='lparen'>(</span><span class='symbol'>:pathname</span><span class='comma'>,</span> <span class='op'>::</span><span class='const'>Pathname</span><span class='comma'>,</span> <span class='op'>::</span><span class='const'>Lazier</span><span class='op'>::</span><span class='const'>Pathname</span><span class='rparen'>)</span>
|
1031
1039
|
<span class='kw'>end</span></pre>
|
1032
1040
|
</td>
|
1033
1041
|
</tr>
|
@@ -1059,15 +1067,15 @@ Otherwise the class of the object will returned.</p>
|
|
1059
1067
|
<pre class="lines">
|
1060
1068
|
|
1061
1069
|
|
1062
|
-
81
|
1063
1070
|
82
|
1064
|
-
83
|
1071
|
+
83
|
1072
|
+
84</pre>
|
1065
1073
|
</td>
|
1066
1074
|
<td>
|
1067
|
-
<pre class="code"><span class="info file"># File 'lib/lazier.rb', line
|
1075
|
+
<pre class="code"><span class="info file"># File 'lib/lazier.rb', line 82</span>
|
1068
1076
|
|
1069
1077
|
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_load_string'>load_string</span>
|
1070
|
-
<span class='
|
1078
|
+
<span class='id identifier rubyid_perform_load'>perform_load</span><span class='lparen'>(</span><span class='symbol'>:string</span><span class='comma'>,</span> <span class='op'>::</span><span class='const'>String</span><span class='comma'>,</span> <span class='op'>::</span><span class='const'>Lazier</span><span class='op'>::</span><span class='const'>String</span><span class='rparen'>)</span>
|
1071
1079
|
<span class='kw'>end</span></pre>
|
1072
1080
|
</td>
|
1073
1081
|
</tr>
|
@@ -1129,20 +1137,20 @@ Otherwise the class of the object will returned.</p>
|
|
1129
1137
|
<pre class="lines">
|
1130
1138
|
|
1131
1139
|
|
1132
|
-
148
|
1133
|
-
149
|
1134
|
-
150
|
1135
|
-
151
|
1136
|
-
152
|
1137
1140
|
153
|
1138
1141
|
154
|
1139
1142
|
155
|
1140
1143
|
156
|
1141
1144
|
157
|
1142
|
-
158
|
1145
|
+
158
|
1146
|
+
159
|
1147
|
+
160
|
1148
|
+
161
|
1149
|
+
162
|
1150
|
+
163</pre>
|
1143
1151
|
</td>
|
1144
1152
|
<td>
|
1145
|
-
<pre class="code"><span class="info file"># File 'lib/lazier.rb', line
|
1153
|
+
<pre class="code"><span class="info file"># File 'lib/lazier.rb', line 153</span>
|
1146
1154
|
|
1147
1155
|
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_platform'>platform</span><span class='lparen'>(</span><span class='id identifier rubyid_force'>force</span> <span class='op'>=</span> <span class='kw'>false</span><span class='rparen'>)</span>
|
1148
1156
|
<span class='ivar'>@platform</span> <span class='op'>=</span> <span class='kw'>nil</span> <span class='kw'>if</span> <span class='id identifier rubyid_force'>force</span>
|
@@ -1202,12 +1210,12 @@ Otherwise the class of the object will returned.</p>
|
|
1202
1210
|
<pre class="lines">
|
1203
1211
|
|
1204
1212
|
|
1205
|
-
36
|
1206
1213
|
37
|
1207
|
-
38
|
1214
|
+
38
|
1215
|
+
39</pre>
|
1208
1216
|
</td>
|
1209
1217
|
<td>
|
1210
|
-
<pre class="code"><span class="info file"># File 'lib/lazier.rb', line
|
1218
|
+
<pre class="code"><span class="info file"># File 'lib/lazier.rb', line 37</span>
|
1211
1219
|
|
1212
1220
|
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_settings'>settings</span>
|
1213
1221
|
<span class='op'>::</span><span class='const'>Lazier</span><span class='op'>::</span><span class='const'>Settings</span><span class='period'>.</span><span class='id identifier rubyid_instance'>instance</span>
|
@@ -1222,7 +1230,7 @@ Otherwise the class of the object will returned.</p>
|
|
1222
1230
|
</div>
|
1223
1231
|
|
1224
1232
|
<div id="footer">
|
1225
|
-
Generated on
|
1233
|
+
Generated on Fri Jun 6 11:15:48 2014 by
|
1226
1234
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
1227
1235
|
0.8.7.4 (ruby-2.1.2).
|
1228
1236
|
</div>
|
data/doc/_index.html
CHANGED
@@ -333,7 +333,7 @@
|
|
333
333
|
</div>
|
334
334
|
|
335
335
|
<div id="footer">
|
336
|
-
Generated on
|
336
|
+
Generated on Fri Jun 6 11:15:47 2014 by
|
337
337
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
338
338
|
0.8.7.4 (ruby-2.1.2).
|
339
339
|
</div>
|
data/doc/file.README.html
CHANGED
@@ -110,7 +110,7 @@ See documentation for more informations.</p>
|
|
110
110
|
</div></div>
|
111
111
|
|
112
112
|
<div id="footer">
|
113
|
-
Generated on
|
113
|
+
Generated on Fri Jun 6 11:15:47 2014 by
|
114
114
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
115
115
|
0.8.7.4 (ruby-2.1.2).
|
116
116
|
</div>
|
data/doc/index.html
CHANGED
@@ -110,7 +110,7 @@ See documentation for more informations.</p>
|
|
110
110
|
</div></div>
|
111
111
|
|
112
112
|
<div id="footer">
|
113
|
-
Generated on
|
113
|
+
Generated on Fri Jun 6 11:15:47 2014 by
|
114
114
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
115
115
|
0.8.7.4 (ruby-2.1.2).
|
116
116
|
</div>
|
@@ -103,7 +103,7 @@
|
|
103
103
|
</div>
|
104
104
|
|
105
105
|
<div id="footer">
|
106
|
-
Generated on
|
106
|
+
Generated on Fri Jun 6 11:15:47 2014 by
|
107
107
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
108
108
|
0.8.7.4 (ruby-2.1.2).
|
109
109
|
</div>
|
data/lazier.gemspec
CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |gem|
|
|
26
26
|
gem.required_ruby_version = ">= 2.1"
|
27
27
|
|
28
28
|
gem.add_dependency("activesupport", "~> 4.1")
|
29
|
-
gem.add_dependency("hashie", "~>
|
29
|
+
gem.add_dependency("hashie", "~> 3.0")
|
30
30
|
|
31
31
|
if RUBY_ENGINE != "jruby"
|
32
32
|
gem.add_dependency("oj", "~> 2.9")
|
data/lib/lazier/i18n.rb
CHANGED
@@ -39,6 +39,7 @@ module Lazier
|
|
39
39
|
# @param root [Symbol] The root level of the translation.
|
40
40
|
# @param path [String] The path where the translations are stored.
|
41
41
|
def initialize(locale = nil, root: :lazier, path: nil)
|
42
|
+
Lazier.load_object
|
42
43
|
path ||= Lazier::ROOT + "/locales"
|
43
44
|
@root = root.to_sym
|
44
45
|
@path = File.absolute_path(path.to_s)
|
data/lib/lazier/settings.rb
CHANGED
@@ -30,6 +30,7 @@ module Lazier
|
|
30
30
|
|
31
31
|
# Initializes a new settings object.
|
32
32
|
def initialize
|
33
|
+
Lazier.load_datetime
|
33
34
|
@i18n = Lazier::I18n.instance
|
34
35
|
setup
|
35
36
|
end
|
@@ -94,14 +95,26 @@ module Lazier
|
|
94
95
|
# @param short_days [Array] The abbreviated string representation of days.
|
95
96
|
# @return [Hash] The new representations.
|
96
97
|
def setup_date_names(long_months: nil, short_months: nil, long_days: nil, short_days: nil)
|
97
|
-
definitions =
|
98
|
+
definitions = prepare_definitions
|
98
99
|
|
99
100
|
@date_names = {
|
100
101
|
long_months: long_months.ensure(definitions.long_months),
|
101
102
|
short_months: short_months.ensure(definitions.short_months),
|
102
103
|
long_days: long_days.ensure(definitions.long_days),
|
103
104
|
short_days: short_days.ensure(definitions.short_days)
|
104
|
-
}
|
105
|
+
}
|
106
|
+
|
107
|
+
@date_names.extend(Lazier::Hash)
|
108
|
+
@date_names = @date_names.ensure_access(:dotted, :indifferent)
|
109
|
+
end
|
110
|
+
|
111
|
+
private
|
112
|
+
|
113
|
+
# :nodoc:
|
114
|
+
def prepare_definitions
|
115
|
+
definitions = i18n.translate("date")
|
116
|
+
definitions.extend(Lazier::Hash)
|
117
|
+
definitions.ensure_access(:dotted)
|
105
118
|
end
|
106
119
|
end
|
107
120
|
end
|
data/lib/lazier/version.rb
CHANGED
data/lib/lazier.rb
CHANGED
@@ -10,6 +10,7 @@ require "active_support"
|
|
10
10
|
require "active_support/core_ext"
|
11
11
|
require "i18n"
|
12
12
|
require "hashie"
|
13
|
+
require "pathname"
|
13
14
|
|
14
15
|
require "lazier/version" unless defined?(Lazier::Version)
|
15
16
|
require "lazier/exceptions"
|
@@ -52,7 +53,7 @@ module Lazier
|
|
52
53
|
# @return [Settings] The settings for the extensions.
|
53
54
|
def self.load!(*what)
|
54
55
|
valid_modules = [:object, :boolean, :string, :hash, :datetime, :math, :pathname]
|
55
|
-
modules = what.present? ? what.flatten.uniq.compact.map(&:
|
56
|
+
modules = what.present? ? what.flatten.uniq.compact.map(&:to_sym) : valid_modules
|
56
57
|
(modules & valid_modules).each { |w| ::Lazier.send("load_#{w}") }
|
57
58
|
|
58
59
|
yield if block_given?
|
@@ -61,55 +62,59 @@ module Lazier
|
|
61
62
|
|
62
63
|
# Loads Object extensions.
|
63
64
|
def self.load_object
|
64
|
-
|
65
|
+
Lazier.load_boolean
|
66
|
+
perform_load(:object, ::Object, ::Lazier::Object)
|
65
67
|
end
|
66
68
|
|
67
69
|
# Loads Boolean extensions.
|
68
70
|
def self.load_boolean
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
include ::Lazier::Boolean
|
71
|
+
perform_load(:boolean) do
|
72
|
+
[::TrueClass, ::FalseClass].each do |klass|
|
73
|
+
klass.class_eval do
|
74
|
+
include ::Lazier::Object
|
75
|
+
include ::Lazier::Boolean
|
76
|
+
end
|
77
|
+
end
|
77
78
|
end
|
78
79
|
end
|
79
80
|
|
80
81
|
# Loads String extensions.
|
81
82
|
def self.load_string
|
82
|
-
::String
|
83
|
+
perform_load(:string, ::String, ::Lazier::String)
|
83
84
|
end
|
84
85
|
|
85
86
|
# Loads Hash extensions.
|
86
87
|
def self.load_hash
|
87
|
-
clean_hash_compact
|
88
88
|
Lazier.load_object
|
89
|
-
|
89
|
+
|
90
|
+
perform_load(:hash) do
|
91
|
+
clean_hash_compact
|
92
|
+
::Hash.class_eval { include ::Lazier::Hash }
|
93
|
+
end
|
90
94
|
end
|
91
95
|
|
92
96
|
# Loads DateTime extensions.
|
93
97
|
def self.load_datetime
|
94
98
|
Lazier.load_object
|
95
99
|
|
96
|
-
|
97
|
-
|
98
|
-
|
100
|
+
perform_load(:datetime) do
|
101
|
+
[::Time, ::Date, ::DateTime].each do |c|
|
102
|
+
c.class_eval { include ::Lazier::DateTime }
|
103
|
+
end
|
99
104
|
|
100
|
-
|
105
|
+
::ActiveSupport::TimeZone.class_eval { include ::Lazier::TimeZone }
|
106
|
+
end
|
101
107
|
end
|
102
108
|
|
103
109
|
# Loads Math extensions.
|
104
110
|
def self.load_math
|
105
111
|
Lazier.load_object
|
106
|
-
::Math
|
112
|
+
perform_load(:math, ::Math, ::Lazier::Math)
|
107
113
|
end
|
108
114
|
|
109
115
|
# Loads Pathname extensions.
|
110
116
|
def self.load_pathname
|
111
|
-
|
112
|
-
::Pathname.class_eval { include ::Lazier::Pathname }
|
117
|
+
perform_load(:pathname, ::Pathname, ::Lazier::Pathname)
|
113
118
|
end
|
114
119
|
|
115
120
|
# Finds a class to instantiate.
|
@@ -159,27 +164,30 @@ module Lazier
|
|
159
164
|
|
160
165
|
private
|
161
166
|
|
162
|
-
#
|
167
|
+
# :nodoc:
|
163
168
|
def self.clean_hash_compact
|
164
169
|
::Hash.class_eval do
|
165
|
-
|
166
|
-
|
167
|
-
remove_method(:compact!)
|
168
|
-
rescue
|
169
|
-
nil
|
170
|
-
end
|
170
|
+
remove_method(:compact) if {}.respond_to?(:compact)
|
171
|
+
remove_method(:compact!) if {}.respond_to?(:compact!)
|
171
172
|
end
|
172
173
|
end
|
173
174
|
|
174
|
-
#
|
175
|
-
#
|
176
|
-
# @param cls [String] The class to search.
|
177
|
-
# @param scope [String] Scope to find the class. `%CLASS%`, `%`, `$`, `?` and `@` will be substituted with the class name.
|
178
|
-
# @return [Class] The instantiated class.
|
175
|
+
# :nodoc:
|
179
176
|
def self.search_class(cls, scope = nil)
|
180
177
|
cls = scope.gsub(/%CLASS%|[@%$?]/, cls)
|
181
178
|
cls.constantize
|
182
179
|
rescue
|
183
180
|
nil
|
184
181
|
end
|
182
|
+
|
183
|
+
# :nodoc:
|
184
|
+
# TODO@PI: On 4.1, make loaded accessible publicly and add a Lazier.loaded? method.
|
185
|
+
def self.perform_load(mod, target = nil, extension = nil, &block)
|
186
|
+
@loaded ||= []
|
187
|
+
|
188
|
+
unless @loaded.include?(mod)
|
189
|
+
block_given? ? block.call : target.class_eval { include extension }
|
190
|
+
@loaded << mod
|
191
|
+
end
|
192
|
+
end
|
185
193
|
end
|
data/spec/lazier/boolean_spec.rb
CHANGED