ruby-nuggets 0.9.9 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (244) hide show
  1. checksums.yaml +4 -4
  2. metadata +20 -324
  3. data/COPYING +0 -663
  4. data/ChangeLog +0 -7
  5. data/README +0 -62
  6. data/Rakefile +0 -47
  7. data/lib/nuggets.rb +0 -73
  8. data/lib/nuggets/all.rb +0 -36
  9. data/lib/nuggets/all_mixins.rb +0 -34
  10. data/lib/nuggets/ansicolor2css.rb +0 -125
  11. data/lib/nuggets/argv/option.rb +0 -3
  12. data/lib/nuggets/argv/option_mixin.rb +0 -85
  13. data/lib/nuggets/array/boost.rb +0 -5
  14. data/lib/nuggets/array/boost_mixin.rb +0 -78
  15. data/lib/nuggets/array/combination.rb +0 -63
  16. data/lib/nuggets/array/correlation.rb +0 -5
  17. data/lib/nuggets/array/correlation_mixin.rb +0 -64
  18. data/lib/nuggets/array/flatten_once.rb +0 -57
  19. data/lib/nuggets/array/flush.rb +0 -5
  20. data/lib/nuggets/array/flush_mixin.rb +0 -47
  21. data/lib/nuggets/array/format.rb +0 -66
  22. data/lib/nuggets/array/hashify.rb +0 -5
  23. data/lib/nuggets/array/hashify_mixin.rb +0 -48
  24. data/lib/nuggets/array/histogram.rb +0 -5
  25. data/lib/nuggets/array/histogram_mixin.rb +0 -170
  26. data/lib/nuggets/array/in_order.rb +0 -51
  27. data/lib/nuggets/array/limit.rb +0 -5
  28. data/lib/nuggets/array/limit_mixin.rb +0 -57
  29. data/lib/nuggets/array/mean.rb +0 -5
  30. data/lib/nuggets/array/mean_mixin.rb +0 -203
  31. data/lib/nuggets/array/median.rb +0 -5
  32. data/lib/nuggets/array/median_mixin.rb +0 -74
  33. data/lib/nuggets/array/mode.rb +0 -5
  34. data/lib/nuggets/array/mode_mixin.rb +0 -70
  35. data/lib/nuggets/array/monotone.rb +0 -84
  36. data/lib/nuggets/array/only.rb +0 -42
  37. data/lib/nuggets/array/rand.rb +0 -45
  38. data/lib/nuggets/array/regression.rb +0 -5
  39. data/lib/nuggets/array/regression_mixin.rb +0 -150
  40. data/lib/nuggets/array/runiq.rb +0 -5
  41. data/lib/nuggets/array/runiq_mixin.rb +0 -53
  42. data/lib/nuggets/array/shuffle.rb +0 -133
  43. data/lib/nuggets/array/standard_deviation.rb +0 -5
  44. data/lib/nuggets/array/standard_deviation_mixin.rb +0 -51
  45. data/lib/nuggets/array/to_hash.rb +0 -65
  46. data/lib/nuggets/array/variance.rb +0 -5
  47. data/lib/nuggets/array/variance_mixin.rb +0 -82
  48. data/lib/nuggets/cli.rb +0 -8
  49. data/lib/nuggets/content_type.rb +0 -98
  50. data/lib/nuggets/dotted_decimal.rb +0 -60
  51. data/lib/nuggets/enumerable/agrep.rb +0 -80
  52. data/lib/nuggets/enumerable/all_any_extended.rb +0 -67
  53. data/lib/nuggets/enumerable/minmax.rb +0 -103
  54. data/lib/nuggets/env/set.rb +0 -3
  55. data/lib/nuggets/env/set_mixin.rb +0 -68
  56. data/lib/nuggets/env/user_encoding.rb +0 -3
  57. data/lib/nuggets/env/user_encoding_mixin.rb +0 -55
  58. data/lib/nuggets/env/user_home.rb +0 -3
  59. data/lib/nuggets/env/user_home_mixin.rb +0 -57
  60. data/lib/nuggets/file/ext.rb +0 -5
  61. data/lib/nuggets/file/ext_mixin.rb +0 -88
  62. data/lib/nuggets/file/replace.rb +0 -5
  63. data/lib/nuggets/file/replace_mixin.rb +0 -56
  64. data/lib/nuggets/file/sub.rb +0 -5
  65. data/lib/nuggets/file/sub_mixin.rb +0 -96
  66. data/lib/nuggets/file/which.rb +0 -5
  67. data/lib/nuggets/file/which_mixin.rb +0 -73
  68. data/lib/nuggets/hash/at.rb +0 -69
  69. data/lib/nuggets/hash/deep_fetch.rb +0 -5
  70. data/lib/nuggets/hash/deep_fetch_mixin.rb +0 -75
  71. data/lib/nuggets/hash/deep_merge.rb +0 -5
  72. data/lib/nuggets/hash/deep_merge_mixin.rb +0 -54
  73. data/lib/nuggets/hash/idmap.rb +0 -5
  74. data/lib/nuggets/hash/idmap_mixin.rb +0 -42
  75. data/lib/nuggets/hash/in_order.rb +0 -44
  76. data/lib/nuggets/hash/insert.rb +0 -54
  77. data/lib/nuggets/hash/nest.rb +0 -5
  78. data/lib/nuggets/hash/nest_mixin.rb +0 -79
  79. data/lib/nuggets/hash/only.rb +0 -53
  80. data/lib/nuggets/hash/seen.rb +0 -5
  81. data/lib/nuggets/hash/seen_mixin.rb +0 -59
  82. data/lib/nuggets/hash/unroll.rb +0 -5
  83. data/lib/nuggets/hash/unroll_mixin.rb +0 -89
  84. data/lib/nuggets/hash/zip.rb +0 -5
  85. data/lib/nuggets/hash/zip_mixin.rb +0 -160
  86. data/lib/nuggets/i18n.rb +0 -156
  87. data/lib/nuggets/integer/factorial.rb +0 -57
  88. data/lib/nuggets/integer/length.rb +0 -5
  89. data/lib/nuggets/integer/length_mixin.rb +0 -50
  90. data/lib/nuggets/integer/map.rb +0 -5
  91. data/lib/nuggets/integer/map_mixin.rb +0 -43
  92. data/lib/nuggets/integer/to_binary_s.rb +0 -39
  93. data/lib/nuggets/io/agrep.rb +0 -44
  94. data/lib/nuggets/io/interact.rb +0 -5
  95. data/lib/nuggets/io/interact_mixin.rb +0 -160
  96. data/lib/nuggets/io/modes.rb +0 -122
  97. data/lib/nuggets/io/null.rb +0 -5
  98. data/lib/nuggets/io/null_mixin.rb +0 -41
  99. data/lib/nuggets/io/redirect.rb +0 -5
  100. data/lib/nuggets/io/redirect_mixin.rb +0 -51
  101. data/lib/nuggets/lazy_attr.rb +0 -45
  102. data/lib/nuggets/log_parser.rb +0 -71
  103. data/lib/nuggets/log_parser/apache.rb +0 -102
  104. data/lib/nuggets/log_parser/rails.rb +0 -220
  105. data/lib/nuggets/lsi.rb +0 -8
  106. data/lib/nuggets/midos.rb +0 -8
  107. data/lib/nuggets/mysql.rb +0 -8
  108. data/lib/nuggets/net/success.rb +0 -60
  109. data/lib/nuggets/numeric/between.rb +0 -2
  110. data/lib/nuggets/numeric/duration.rb +0 -101
  111. data/lib/nuggets/numeric/limit.rb +0 -63
  112. data/lib/nuggets/numeric/signum.rb +0 -53
  113. data/lib/nuggets/numeric/to_multiple.rb +0 -62
  114. data/lib/nuggets/object/blank.rb +0 -20
  115. data/lib/nuggets/object/blank_mixin.rb +0 -100
  116. data/lib/nuggets/object/boolean.rb +0 -5
  117. data/lib/nuggets/object/boolean_mixin.rb +0 -62
  118. data/lib/nuggets/object/eigenclass.rb +0 -2
  119. data/lib/nuggets/object/ghost_class.rb +0 -2
  120. data/lib/nuggets/object/metaclass.rb +0 -2
  121. data/lib/nuggets/object/msend.rb +0 -5
  122. data/lib/nuggets/object/msend_mixin.rb +0 -44
  123. data/lib/nuggets/object/silence.rb +0 -5
  124. data/lib/nuggets/object/silence_mixin.rb +0 -45
  125. data/lib/nuggets/object/singleton_class.rb +0 -5
  126. data/lib/nuggets/object/singleton_class_mixin.rb +0 -96
  127. data/lib/nuggets/object/uniclass.rb +0 -2
  128. data/lib/nuggets/object/virtual_class.rb +0 -2
  129. data/lib/nuggets/pluggable.rb +0 -92
  130. data/lib/nuggets/proc/bind.rb +0 -5
  131. data/lib/nuggets/proc/bind_mixin.rb +0 -52
  132. data/lib/nuggets/range/quantile.rb +0 -5
  133. data/lib/nuggets/range/quantile_mixin.rb +0 -43
  134. data/lib/nuggets/rdf/compression.rb +0 -6
  135. data/lib/nuggets/rdf/prefix.rb +0 -6
  136. data/lib/nuggets/rdf/turtle.rb +0 -8
  137. data/lib/nuggets/rdf/turtle/reader.rb +0 -6
  138. data/lib/nuggets/rdf/uri.rb +0 -6
  139. data/lib/nuggets/ruby.rb +0 -236
  140. data/lib/nuggets/statistics.rb +0 -12
  141. data/lib/nuggets/statistics_mixins.rb +0 -12
  142. data/lib/nuggets/string/camelscore.rb +0 -5
  143. data/lib/nuggets/string/camelscore_mixin.rb +0 -117
  144. data/lib/nuggets/string/capitalize_first.rb +0 -47
  145. data/lib/nuggets/string/case.rb +0 -82
  146. data/lib/nuggets/string/evaluate.rb +0 -5
  147. data/lib/nuggets/string/evaluate_mixin.rb +0 -48
  148. data/lib/nuggets/string/msub.rb +0 -85
  149. data/lib/nuggets/string/nsub.rb +0 -66
  150. data/lib/nuggets/string/sub_with_md.rb +0 -112
  151. data/lib/nuggets/string/wc.rb +0 -5
  152. data/lib/nuggets/string/wc_mixin.rb +0 -96
  153. data/lib/nuggets/string/word_wrap.rb +0 -77
  154. data/lib/nuggets/string/xor.rb +0 -5
  155. data/lib/nuggets/string/xor_mixin.rb +0 -60
  156. data/lib/nuggets/tempfile/open.rb +0 -58
  157. data/lib/nuggets/uri/content_type.rb +0 -5
  158. data/lib/nuggets/uri/content_type_mixin.rb +0 -48
  159. data/lib/nuggets/uri/exist.rb +0 -5
  160. data/lib/nuggets/uri/exist_mixin.rb +0 -57
  161. data/lib/nuggets/uri/redirect.rb +0 -5
  162. data/lib/nuggets/uri/redirect_mixin.rb +0 -102
  163. data/lib/nuggets/util/ansicolor2css.rb +0 -4
  164. data/lib/nuggets/util/cli.rb +0 -4
  165. data/lib/nuggets/util/content_type.rb +0 -4
  166. data/lib/nuggets/util/dotted_decimal.rb +0 -3
  167. data/lib/nuggets/util/i18n.rb +0 -4
  168. data/lib/nuggets/util/lazy_attr.rb +0 -4
  169. data/lib/nuggets/util/log_parser.rb +0 -4
  170. data/lib/nuggets/util/log_parser/apache.rb +0 -4
  171. data/lib/nuggets/util/log_parser/rails.rb +0 -4
  172. data/lib/nuggets/util/midos.rb +0 -4
  173. data/lib/nuggets/util/mysql.rb +0 -4
  174. data/lib/nuggets/util/pluggable.rb +0 -4
  175. data/lib/nuggets/util/ruby.rb +0 -4
  176. data/lib/nuggets/version.rb +0 -27
  177. data/spec/nuggets/array/boost_spec.rb +0 -50
  178. data/spec/nuggets/array/combination_spec.rb +0 -25
  179. data/spec/nuggets/array/correlation_spec.rb +0 -81
  180. data/spec/nuggets/array/flatten_once_spec.rb +0 -16
  181. data/spec/nuggets/array/flush_spec.rb +0 -43
  182. data/spec/nuggets/array/format_spec.rb +0 -52
  183. data/spec/nuggets/array/hashify_spec.rb +0 -41
  184. data/spec/nuggets/array/histogram_spec.rb +0 -87
  185. data/spec/nuggets/array/in_order_spec.rb +0 -13
  186. data/spec/nuggets/array/limit_spec.rb +0 -62
  187. data/spec/nuggets/array/mean_spec.rb +0 -203
  188. data/spec/nuggets/array/median_spec.rb +0 -77
  189. data/spec/nuggets/array/mode_spec.rb +0 -57
  190. data/spec/nuggets/array/monotone_spec.rb +0 -30
  191. data/spec/nuggets/array/only_spec.rb +0 -26
  192. data/spec/nuggets/array/regression_spec.rb +0 -54
  193. data/spec/nuggets/array/runiq_spec.rb +0 -25
  194. data/spec/nuggets/array/standard_deviation_spec.rb +0 -33
  195. data/spec/nuggets/array/to_hash_spec.rb +0 -28
  196. data/spec/nuggets/array/variance_spec.rb +0 -106
  197. data/spec/nuggets/dotted_decimal_spec.rb +0 -27
  198. data/spec/nuggets/enumerable/all_any_extended_spec.rb +0 -31
  199. data/spec/nuggets/enumerable/minmax_spec.rb +0 -21
  200. data/spec/nuggets/env/set_spec.rb +0 -29
  201. data/spec/nuggets/env/user_encoding_spec.rb +0 -38
  202. data/spec/nuggets/env/user_home_spec.rb +0 -42
  203. data/spec/nuggets/file/ext_spec.rb +0 -38
  204. data/spec/nuggets/file/replace_spec.rb +0 -95
  205. data/spec/nuggets/file/sub_spec.rb +0 -149
  206. data/spec/nuggets/file/which_spec.rb +0 -22
  207. data/spec/nuggets/hash/at_spec.rb +0 -19
  208. data/spec/nuggets/hash/deep_fetch_spec.rb +0 -159
  209. data/spec/nuggets/hash/deep_merge_spec.rb +0 -78
  210. data/spec/nuggets/hash/in_order_spec.rb +0 -12
  211. data/spec/nuggets/hash/insert_spec.rb +0 -13
  212. data/spec/nuggets/hash/nest_spec.rb +0 -102
  213. data/spec/nuggets/hash/only_spec.rb +0 -29
  214. data/spec/nuggets/hash/seen_spec.rb +0 -36
  215. data/spec/nuggets/hash/unroll_spec.rb +0 -68
  216. data/spec/nuggets/i18n_spec.rb +0 -13
  217. data/spec/nuggets/integer/factorial_spec.rb +0 -10
  218. data/spec/nuggets/integer/length_spec.rb +0 -18
  219. data/spec/nuggets/integer/map_spec.rb +0 -19
  220. data/spec/nuggets/integer/to_binary_s_spec.rb +0 -19
  221. data/spec/nuggets/numeric/duration_spec.rb +0 -25
  222. data/spec/nuggets/numeric/limit_spec.rb +0 -16
  223. data/spec/nuggets/numeric/signum_spec.rb +0 -16
  224. data/spec/nuggets/numeric/to_multiple_spec.rb +0 -16
  225. data/spec/nuggets/object/blank_spec.rb +0 -34
  226. data/spec/nuggets/object/boolean_spec.rb +0 -23
  227. data/spec/nuggets/object/msend_spec.rb +0 -25
  228. data/spec/nuggets/object/silence_spec.rb +0 -36
  229. data/spec/nuggets/object/singleton_class_spec.rb +0 -51
  230. data/spec/nuggets/proc/bind_spec.rb +0 -28
  231. data/spec/nuggets/range/quantile_spec.rb +0 -33
  232. data/spec/nuggets/string/camelscore_spec.rb +0 -114
  233. data/spec/nuggets/string/capitalize_first_spec.rb +0 -13
  234. data/spec/nuggets/string/case_spec.rb +0 -31
  235. data/spec/nuggets/string/evaluate_spec.rb +0 -24
  236. data/spec/nuggets/string/msub_spec.rb +0 -20
  237. data/spec/nuggets/string/nsub_spec.rb +0 -13
  238. data/spec/nuggets/string/sub_with_md_spec.rb +0 -25
  239. data/spec/nuggets/string/wc_spec.rb +0 -73
  240. data/spec/nuggets/string/word_wrap_spec.rb +0 -81
  241. data/spec/nuggets/string/xor_spec.rb +0 -57
  242. data/spec/nuggets/uri/content_type_spec.rb +0 -42
  243. data/spec/nuggets/uri/exist_spec.rb +0 -49
  244. data/spec/spec_helper.rb +0 -36
@@ -1,16 +0,0 @@
1
- require 'nuggets/numeric/limit'
2
-
3
- describe Numeric, 'limit' do
4
-
5
- {
6
- 123 => 10,
7
- -123 => 0,
8
- 0 => 0,
9
- 0.001 => 0.001,
10
- 1.23 => 1.23,
11
- -12.3 => 0
12
- }.each { |n, m|
13
- example { n.between(0, 10).should == m }
14
- }
15
-
16
- end
@@ -1,16 +0,0 @@
1
- require 'nuggets/numeric/signum'
2
-
3
- describe Numeric, 'signum' do
4
-
5
- {
6
- 123 => 1,
7
- -123 => -1,
8
- 0 => 0,
9
- 0.001 => 1,
10
- 1.23 => 1,
11
- -12.3 => -1
12
- }.each { |n, s|
13
- example { n.sign.should == s }
14
- }
15
-
16
- end
@@ -1,16 +0,0 @@
1
- require 'nuggets/numeric/to_multiple'
2
-
3
- describe Numeric, 'to_multiple' do
4
-
5
- {
6
- 123 => [ 120, 120, 130],
7
- -123 => [-120, -130, -120],
8
- 0 => [ 0, 0, 0],
9
- 0.001 => [ 0, 0, 10],
10
- 5.67 => [ 10, 0, 10],
11
- -12.3 => [ -10, -20, -10]
12
- }.each { |n, m|
13
- example { [n.round_to(10), n.floor_to(10), n.ceil_to(10)].should == m }
14
- }
15
-
16
- end
@@ -1,34 +0,0 @@
1
- require 'nuggets/object/blank'
2
-
3
- describe_extended Object, Nuggets::Object::BlankMixin do
4
-
5
- it { Array.ancestors.should include(Nuggets::Array::BlankMixin) }
6
- it { Hash.ancestors.should include(Nuggets::Hash::BlankMixin) }
7
-
8
- ['s', ' ', 0, 1, true, [nil]].each { |o|
9
- example { o.should_not be_blank }
10
- }
11
-
12
- ['', nil, false, [], {}].each { |o|
13
- example { o.should be_blank }
14
- }
15
-
16
- ['s', 1, true].each { |o|
17
- example { o.should_not be_void }
18
- example { o.should_not be_vain }
19
- }
20
-
21
- ['', ' ', 0, nil, false, [], [nil], {}].each { |o|
22
- example { o.should be_void }
23
- example { o.should be_vain }
24
- }
25
-
26
- [['', [], [nil], {}], { :x => nil, :y => [], :z => { :zz => nil } }].each { |o|
27
- example { o.should_not be_void }
28
- }
29
-
30
- [['', [], [nil], {}], { :x => nil, :y => [], :z => { :zz => nil } }].each { |o|
31
- example { o.should be_vain }
32
- }
33
-
34
- end
@@ -1,23 +0,0 @@
1
- require 'nuggets/object/boolean'
2
-
3
- describe_extended Object, Nuggets::Object::BooleanMixin do
4
-
5
- [0, 1, -1, nil, '', 'abc', Class, Object.new].each { |o|
6
- example { o.should_not be_boolean }
7
- }
8
-
9
- [true, false].each { |o|
10
- example { o.should be_boolean }
11
- }
12
-
13
- [0, 1, -1, '', 'abc', Class, Object.new, true].each { |o|
14
- example { o.negate.should == false }
15
- example { o.to_bool.should == true }
16
- }
17
-
18
- [nil, false].each { |o|
19
- example { o.negate.should == true }
20
- example { o.to_bool.should == false }
21
- }
22
-
23
- end
@@ -1,25 +0,0 @@
1
- require 'nuggets/object/msend'
2
-
3
- describe_extended Object, Nuggets::Object::MSendMixin do
4
-
5
- example do
6
- o = 'foo bar'
7
- o.msend(:length, :reverse).should == [o.length, o.reverse]
8
- end
9
-
10
- example do
11
- o = 42
12
- o.msend(:to_s, :* => 2).should == [o.to_s, o * 2]
13
- end
14
-
15
- example do
16
- o = 42
17
- o.msend([:to_s, 2], '-@').should == [o.to_s(2), -o]
18
- end
19
-
20
- example do
21
- o = Time.now
22
- o.msend(:year, :month, :day).should == [o.year, o.month, o.day]
23
- end
24
-
25
- end
@@ -1,36 +0,0 @@
1
- require 'nuggets/object/silence'
2
-
3
- describe_extended Object, Nuggets::Object::SilenceMixin do
4
-
5
- before do
6
- @stderr, @old_stderr = '', $stderr
7
- $stderr = StringIO.new(@stderr)
8
-
9
- AConst = :foo
10
- end
11
-
12
- after do
13
- $stderr = @old_stderr
14
- Object.send(:remove_const, :AConst) if Object.const_defined?(:AConst)
15
- end
16
-
17
- example do
18
- AConst = :bar
19
-
20
- AConst.should be_equal(:bar)
21
-
22
- if RUBY_ENGINE == 'rbx'
23
- @stderr.should == ''
24
- else
25
- @stderr.should =~ /warning: already initialized constant AConst/
26
- end
27
- end
28
-
29
- example do
30
- silence { AConst = :baz }
31
-
32
- AConst.should be_equal(:baz)
33
- @stderr.should == ''
34
- end
35
-
36
- end
@@ -1,51 +0,0 @@
1
- require 'nuggets/object/singleton_class'
2
-
3
- describe_extended Object, Nuggets::Object::SingletonClassMixin do
4
-
5
- objects = [Class, Object.new, Class.new, 's', [1, 2], { :a => 'b' }]
6
- objects.unshift(Object) unless RUBY_PLATFORM == 'java' || RUBY_ENGINE == 'rbx'
7
-
8
- objects.each { |o|
9
- example { o.should_not be_a_singleton_class }
10
- example { lambda { o.singleton_object }.should raise_error(TypeError) }
11
-
12
- s = o.singleton_class
13
-
14
- example { s.should be_a_singleton_class }
15
- example { s.singleton_object.should be_equal(o) }
16
- }
17
-
18
- example do
19
- c = Class.new
20
- c.should_not be_a_singleton_class
21
- o = c.new
22
- c.should_not be_a_singleton_class
23
- end
24
-
25
- example do
26
- nil.singleton_class.should == NilClass
27
-
28
- if RUBY_VERSION < '2'
29
- NilClass.should be_a_singleton_class
30
- else
31
- NilClass.should be_a_virtual_class
32
- end
33
-
34
- NilClass.singleton_object.should be_equal(nil)
35
- end
36
-
37
- example do
38
- class A; end
39
- class B < A; end
40
-
41
- a = A.singleton_class
42
- b = B.singleton_class
43
-
44
- a.should be_a_singleton_class
45
- b.should be_a_singleton_class
46
-
47
- a.singleton_object.should be_equal(A)
48
- b.singleton_object.should be_equal(B)
49
- end
50
-
51
- end
@@ -1,28 +0,0 @@
1
- require 'nuggets/proc/bind'
2
-
3
- describe_extended Proc, Nuggets::Proc::BindMixin do
4
-
5
- before :each do
6
- @l = lambda { bla }
7
- end
8
-
9
- example do
10
- lambda { @l.call }.should raise_error(NameError)
11
- end
12
-
13
- example do
14
- module Foo; def self.bla; 'bar'; end; end
15
- @l.bind(Foo).call.should == 'bar'
16
- end
17
-
18
- example do
19
- class Bar; def self.bla; 'baz'; end; end
20
- @l.bind(Bar).call.should == 'baz'
21
- end
22
-
23
- example do
24
- class Baz; def bla; 'foo'; end; end
25
- @l.bind(Baz.new).call.should == 'foo'
26
- end
27
-
28
- end
@@ -1,33 +0,0 @@
1
- require 'nuggets/range/quantile'
2
-
3
- describe_extended Range, Nuggets::Range::QuantileMixin do
4
-
5
- example do
6
- (1..5).quantile(0, 3).should == 1
7
- end
8
-
9
- example do
10
- (1..5).quantile(1, 3).should == 1
11
- end
12
-
13
- example do
14
- (1..5).quantile(2, 3).should == 1
15
- end
16
-
17
- example do
18
- (1..5).quantile(3, 3).should == 2
19
- end
20
-
21
- example do
22
- (1..5).quantile(4, 3).should == 3
23
- end
24
-
25
- example do
26
- (1..5).quantile(5, 3).should == 3
27
- end
28
-
29
- example do
30
- (1..5).quantile(6, 3).should == 3
31
- end
32
-
33
- end
@@ -1,114 +0,0 @@
1
- require 'nuggets/string/camelscore'
2
-
3
- describe_extended String, Nuggets::String::CamelscoreMixin do
4
-
5
- def self.with_acronyms(acronyms, &block)
6
- describe "with acronyms #{acronyms.inspect}" do
7
- before :all do ::String::CAMELSCORE_ACRONYMS.replace(acronyms) end
8
- after :all do ::String::CAMELSCORE_ACRONYMS.clear end
9
-
10
- instance_eval(&block)
11
- end
12
- end
13
-
14
- with_acronyms({}) { [
15
- ['', ''],
16
- %w[a A],
17
- %w[a_b AB],
18
- %w[a_b_c ABC],
19
- %w[a/b A::B],
20
- %w[a/b_c A::BC],
21
- %w[a/b/c A::B::C],
22
- %w[foo Foo],
23
- %w[foo_bar FooBar],
24
- %w[foo_bar_baz FooBarBaz],
25
- %w[foo/bar Foo::Bar],
26
- %w[foo/bar_baz Foo::BarBaz],
27
- %w[foo/bar/baz Foo::Bar::Baz],
28
- %w[active_model ActiveModel],
29
- %w[active_model/errors ActiveModel::Errors],
30
- %w[ssl_error SslError],
31
- %w[s_s_l_error SSLError]
32
- ].each { |a, b|
33
- example { a.camelcase.should == b }
34
- example { b.underscore.should == a }
35
- } }
36
-
37
- with_acronyms('ab' => 'AB') {
38
- example { 'ab'.camelcase.should == 'AB' }
39
- example { 'AB'.underscore.should == 'ab' }
40
- example { 'abc'.camelcase.should == 'Abc' }
41
- example { 'Abc'.underscore.should == 'abc' }
42
- example { 'ab_c'.camelcase.should == 'ABC' }
43
- example { 'ABC'.underscore.should == 'ab_c' }
44
- }
45
-
46
- with_acronyms('abc' => 'ABC') {
47
- example { 'ab'.camelcase.should == 'Ab' }
48
- example { 'AB'.underscore.should == 'a_b' }
49
- example { 'abc'.camelcase.should == 'ABC' }
50
- example { 'ABC'.underscore.should == 'abc' }
51
- }
52
-
53
- with_acronyms('ab' => 'AB', 'abc' => 'ABC') {
54
- example { 'ab'.camelcase.should == 'AB' }
55
- example { 'AB'.underscore.should == 'ab' }
56
- example { 'abc'.camelcase.should == 'ABC' }
57
- example { 'Abc'.underscore.should == 'abc' }
58
- example { 'ab_c'.camelcase.should == 'ABC' }
59
- example { 'ABC'.underscore.should == 'ab_c' }
60
- }
61
-
62
- with_acronyms('xml' => 'XML', 'html' => 'HTML', 'sql' => 'SQL') {
63
- example { 'xml'.camelcase.should == 'XML' }
64
- example { 'XML'.underscore.should == 'xml' }
65
- example { 'html'.camelcase.should == 'HTML' }
66
- example { 'HTML'.underscore.should == 'html' }
67
- example { 'html5'.camelcase.should == 'HTML5' }
68
- example { 'HTML5'.underscore.should == 'html5' }
69
- #pending { 'xhtml'.camelcase.should == 'XHTML' }
70
- #pending { 'XHTML'.underscore.should == 'xhtml' }
71
- example { 'sql'.camelcase.should == 'SQL' }
72
- example { 'SQL'.underscore.should == 'sql' }
73
- #pending { 'mysql'.camelcase.should == 'MySQL' }
74
- #pending { 'MySQL'.underscore.should == 'mysql' }
75
- #pending { 'postgresql'.camelcase.should == 'PostgreSQL' }
76
- #pending { 'PostgreSQL'.underscore.should == 'postgresql' }
77
- #pending { 'sqlite'.camelcase.should == 'SQLite' }
78
- #pending { 'SQLite'.underscore.should == 'sqlite' }
79
- #pending { 'nosql'.camelcase.should == 'NoSQL' }
80
- #pending { 'NoSQL'.underscore.should == 'nosql' }
81
- }
82
-
83
- with_acronyms('rss' => 'RSS', 'xml' => 'XML') {
84
- example { 'rss2xml'.camelcase.should == 'RSS2XML' }
85
- example { 'RSS2XML'.underscore.should == 'rss2xml' }
86
- }
87
-
88
- with_acronyms('ssl' => 'SSL') {
89
- example { 'ssl'.camelcase.should == 'SSL' }
90
- example { 'SSL'.underscore.should == 'ssl' }
91
- example { 'ssl_error'.camelcase.should == 'SSLError' }
92
- example { 'SSLError'.underscore.should == 'ssl_error' }
93
- }
94
-
95
- example { ''.constantize.should be_nil }
96
- example { '::'.constantize.should be_nil }
97
-
98
- example { 'Nuggets'.constantize.should == ::Nuggets }
99
- example { '::Nuggets'.constantize.should == ::Nuggets }
100
-
101
- example { 'Nuggets::String'.constantize.should == ::Nuggets::String }
102
- example { '::Nuggets::String'.constantize.should == ::Nuggets::String }
103
-
104
- example { 'String'.constantize.should == ::String }
105
- example { 'String'.constantize(::Nuggets).should == ::Nuggets::String }
106
- example { '::String'.constantize(::Nuggets).should == ::String }
107
- example { 'String'.constantize(::Nuggets::String).should == ::String }
108
- example { 'String'.constantize(::Nuggets::String::CamelscoreMixin).should == ::String }
109
-
110
- example { lambda { 'CamelscoreMixin'.constantize }.should raise_error(NameError) }
111
- example { lambda { 'CamelscoreMixin'.constantize(::Nuggets) }.should raise_error(NameError) }
112
- example { 'CamelscoreMixin'.constantize(::Nuggets::String).should == ::Nuggets::String::CamelscoreMixin }
113
-
114
- end
@@ -1,13 +0,0 @@
1
- require 'nuggets/string/capitalize_first'
2
-
3
- describe String, 'capitalize_first' do
4
-
5
- {
6
- 'Some string' => 'Some string',
7
- 'some string' => 'Some string',
8
- 'SOME STRING' => 'SOME STRING'
9
- }.each { |s, c|
10
- example { s.capitalize_first.should == c }
11
- }
12
-
13
- end
@@ -1,31 +0,0 @@
1
- require 'nuggets/string/case'
2
-
3
- describe String, 'case' do
4
-
5
- example {
6
- s = 'Some string'
7
-
8
- s.case.should == :mixed
9
- s.should_not be_downcase
10
- s.should_not be_upcase
11
- s.should be_mixed_case
12
- s.should be_capitalized
13
- }
14
-
15
- example {
16
- s = 'some string'
17
-
18
- s.case.should == :lower
19
- s.should be_downcase
20
- s.should_not be_mixed_case
21
- }
22
-
23
- example {
24
- s = 'SOME STRING'
25
-
26
- s.case.should == :upper
27
- s.should be_upcase
28
- s.should_not be_mixed_case
29
- }
30
-
31
- end