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.
- checksums.yaml +4 -4
- metadata +20 -324
- data/COPYING +0 -663
- data/ChangeLog +0 -7
- data/README +0 -62
- data/Rakefile +0 -47
- data/lib/nuggets.rb +0 -73
- data/lib/nuggets/all.rb +0 -36
- data/lib/nuggets/all_mixins.rb +0 -34
- data/lib/nuggets/ansicolor2css.rb +0 -125
- data/lib/nuggets/argv/option.rb +0 -3
- data/lib/nuggets/argv/option_mixin.rb +0 -85
- data/lib/nuggets/array/boost.rb +0 -5
- data/lib/nuggets/array/boost_mixin.rb +0 -78
- data/lib/nuggets/array/combination.rb +0 -63
- data/lib/nuggets/array/correlation.rb +0 -5
- data/lib/nuggets/array/correlation_mixin.rb +0 -64
- data/lib/nuggets/array/flatten_once.rb +0 -57
- data/lib/nuggets/array/flush.rb +0 -5
- data/lib/nuggets/array/flush_mixin.rb +0 -47
- data/lib/nuggets/array/format.rb +0 -66
- data/lib/nuggets/array/hashify.rb +0 -5
- data/lib/nuggets/array/hashify_mixin.rb +0 -48
- data/lib/nuggets/array/histogram.rb +0 -5
- data/lib/nuggets/array/histogram_mixin.rb +0 -170
- data/lib/nuggets/array/in_order.rb +0 -51
- data/lib/nuggets/array/limit.rb +0 -5
- data/lib/nuggets/array/limit_mixin.rb +0 -57
- data/lib/nuggets/array/mean.rb +0 -5
- data/lib/nuggets/array/mean_mixin.rb +0 -203
- data/lib/nuggets/array/median.rb +0 -5
- data/lib/nuggets/array/median_mixin.rb +0 -74
- data/lib/nuggets/array/mode.rb +0 -5
- data/lib/nuggets/array/mode_mixin.rb +0 -70
- data/lib/nuggets/array/monotone.rb +0 -84
- data/lib/nuggets/array/only.rb +0 -42
- data/lib/nuggets/array/rand.rb +0 -45
- data/lib/nuggets/array/regression.rb +0 -5
- data/lib/nuggets/array/regression_mixin.rb +0 -150
- data/lib/nuggets/array/runiq.rb +0 -5
- data/lib/nuggets/array/runiq_mixin.rb +0 -53
- data/lib/nuggets/array/shuffle.rb +0 -133
- data/lib/nuggets/array/standard_deviation.rb +0 -5
- data/lib/nuggets/array/standard_deviation_mixin.rb +0 -51
- data/lib/nuggets/array/to_hash.rb +0 -65
- data/lib/nuggets/array/variance.rb +0 -5
- data/lib/nuggets/array/variance_mixin.rb +0 -82
- data/lib/nuggets/cli.rb +0 -8
- data/lib/nuggets/content_type.rb +0 -98
- data/lib/nuggets/dotted_decimal.rb +0 -60
- data/lib/nuggets/enumerable/agrep.rb +0 -80
- data/lib/nuggets/enumerable/all_any_extended.rb +0 -67
- data/lib/nuggets/enumerable/minmax.rb +0 -103
- data/lib/nuggets/env/set.rb +0 -3
- data/lib/nuggets/env/set_mixin.rb +0 -68
- data/lib/nuggets/env/user_encoding.rb +0 -3
- data/lib/nuggets/env/user_encoding_mixin.rb +0 -55
- data/lib/nuggets/env/user_home.rb +0 -3
- data/lib/nuggets/env/user_home_mixin.rb +0 -57
- data/lib/nuggets/file/ext.rb +0 -5
- data/lib/nuggets/file/ext_mixin.rb +0 -88
- data/lib/nuggets/file/replace.rb +0 -5
- data/lib/nuggets/file/replace_mixin.rb +0 -56
- data/lib/nuggets/file/sub.rb +0 -5
- data/lib/nuggets/file/sub_mixin.rb +0 -96
- data/lib/nuggets/file/which.rb +0 -5
- data/lib/nuggets/file/which_mixin.rb +0 -73
- data/lib/nuggets/hash/at.rb +0 -69
- data/lib/nuggets/hash/deep_fetch.rb +0 -5
- data/lib/nuggets/hash/deep_fetch_mixin.rb +0 -75
- data/lib/nuggets/hash/deep_merge.rb +0 -5
- data/lib/nuggets/hash/deep_merge_mixin.rb +0 -54
- data/lib/nuggets/hash/idmap.rb +0 -5
- data/lib/nuggets/hash/idmap_mixin.rb +0 -42
- data/lib/nuggets/hash/in_order.rb +0 -44
- data/lib/nuggets/hash/insert.rb +0 -54
- data/lib/nuggets/hash/nest.rb +0 -5
- data/lib/nuggets/hash/nest_mixin.rb +0 -79
- data/lib/nuggets/hash/only.rb +0 -53
- data/lib/nuggets/hash/seen.rb +0 -5
- data/lib/nuggets/hash/seen_mixin.rb +0 -59
- data/lib/nuggets/hash/unroll.rb +0 -5
- data/lib/nuggets/hash/unroll_mixin.rb +0 -89
- data/lib/nuggets/hash/zip.rb +0 -5
- data/lib/nuggets/hash/zip_mixin.rb +0 -160
- data/lib/nuggets/i18n.rb +0 -156
- data/lib/nuggets/integer/factorial.rb +0 -57
- data/lib/nuggets/integer/length.rb +0 -5
- data/lib/nuggets/integer/length_mixin.rb +0 -50
- data/lib/nuggets/integer/map.rb +0 -5
- data/lib/nuggets/integer/map_mixin.rb +0 -43
- data/lib/nuggets/integer/to_binary_s.rb +0 -39
- data/lib/nuggets/io/agrep.rb +0 -44
- data/lib/nuggets/io/interact.rb +0 -5
- data/lib/nuggets/io/interact_mixin.rb +0 -160
- data/lib/nuggets/io/modes.rb +0 -122
- data/lib/nuggets/io/null.rb +0 -5
- data/lib/nuggets/io/null_mixin.rb +0 -41
- data/lib/nuggets/io/redirect.rb +0 -5
- data/lib/nuggets/io/redirect_mixin.rb +0 -51
- data/lib/nuggets/lazy_attr.rb +0 -45
- data/lib/nuggets/log_parser.rb +0 -71
- data/lib/nuggets/log_parser/apache.rb +0 -102
- data/lib/nuggets/log_parser/rails.rb +0 -220
- data/lib/nuggets/lsi.rb +0 -8
- data/lib/nuggets/midos.rb +0 -8
- data/lib/nuggets/mysql.rb +0 -8
- data/lib/nuggets/net/success.rb +0 -60
- data/lib/nuggets/numeric/between.rb +0 -2
- data/lib/nuggets/numeric/duration.rb +0 -101
- data/lib/nuggets/numeric/limit.rb +0 -63
- data/lib/nuggets/numeric/signum.rb +0 -53
- data/lib/nuggets/numeric/to_multiple.rb +0 -62
- data/lib/nuggets/object/blank.rb +0 -20
- data/lib/nuggets/object/blank_mixin.rb +0 -100
- data/lib/nuggets/object/boolean.rb +0 -5
- data/lib/nuggets/object/boolean_mixin.rb +0 -62
- data/lib/nuggets/object/eigenclass.rb +0 -2
- data/lib/nuggets/object/ghost_class.rb +0 -2
- data/lib/nuggets/object/metaclass.rb +0 -2
- data/lib/nuggets/object/msend.rb +0 -5
- data/lib/nuggets/object/msend_mixin.rb +0 -44
- data/lib/nuggets/object/silence.rb +0 -5
- data/lib/nuggets/object/silence_mixin.rb +0 -45
- data/lib/nuggets/object/singleton_class.rb +0 -5
- data/lib/nuggets/object/singleton_class_mixin.rb +0 -96
- data/lib/nuggets/object/uniclass.rb +0 -2
- data/lib/nuggets/object/virtual_class.rb +0 -2
- data/lib/nuggets/pluggable.rb +0 -92
- data/lib/nuggets/proc/bind.rb +0 -5
- data/lib/nuggets/proc/bind_mixin.rb +0 -52
- data/lib/nuggets/range/quantile.rb +0 -5
- data/lib/nuggets/range/quantile_mixin.rb +0 -43
- data/lib/nuggets/rdf/compression.rb +0 -6
- data/lib/nuggets/rdf/prefix.rb +0 -6
- data/lib/nuggets/rdf/turtle.rb +0 -8
- data/lib/nuggets/rdf/turtle/reader.rb +0 -6
- data/lib/nuggets/rdf/uri.rb +0 -6
- data/lib/nuggets/ruby.rb +0 -236
- data/lib/nuggets/statistics.rb +0 -12
- data/lib/nuggets/statistics_mixins.rb +0 -12
- data/lib/nuggets/string/camelscore.rb +0 -5
- data/lib/nuggets/string/camelscore_mixin.rb +0 -117
- data/lib/nuggets/string/capitalize_first.rb +0 -47
- data/lib/nuggets/string/case.rb +0 -82
- data/lib/nuggets/string/evaluate.rb +0 -5
- data/lib/nuggets/string/evaluate_mixin.rb +0 -48
- data/lib/nuggets/string/msub.rb +0 -85
- data/lib/nuggets/string/nsub.rb +0 -66
- data/lib/nuggets/string/sub_with_md.rb +0 -112
- data/lib/nuggets/string/wc.rb +0 -5
- data/lib/nuggets/string/wc_mixin.rb +0 -96
- data/lib/nuggets/string/word_wrap.rb +0 -77
- data/lib/nuggets/string/xor.rb +0 -5
- data/lib/nuggets/string/xor_mixin.rb +0 -60
- data/lib/nuggets/tempfile/open.rb +0 -58
- data/lib/nuggets/uri/content_type.rb +0 -5
- data/lib/nuggets/uri/content_type_mixin.rb +0 -48
- data/lib/nuggets/uri/exist.rb +0 -5
- data/lib/nuggets/uri/exist_mixin.rb +0 -57
- data/lib/nuggets/uri/redirect.rb +0 -5
- data/lib/nuggets/uri/redirect_mixin.rb +0 -102
- data/lib/nuggets/util/ansicolor2css.rb +0 -4
- data/lib/nuggets/util/cli.rb +0 -4
- data/lib/nuggets/util/content_type.rb +0 -4
- data/lib/nuggets/util/dotted_decimal.rb +0 -3
- data/lib/nuggets/util/i18n.rb +0 -4
- data/lib/nuggets/util/lazy_attr.rb +0 -4
- data/lib/nuggets/util/log_parser.rb +0 -4
- data/lib/nuggets/util/log_parser/apache.rb +0 -4
- data/lib/nuggets/util/log_parser/rails.rb +0 -4
- data/lib/nuggets/util/midos.rb +0 -4
- data/lib/nuggets/util/mysql.rb +0 -4
- data/lib/nuggets/util/pluggable.rb +0 -4
- data/lib/nuggets/util/ruby.rb +0 -4
- data/lib/nuggets/version.rb +0 -27
- data/spec/nuggets/array/boost_spec.rb +0 -50
- data/spec/nuggets/array/combination_spec.rb +0 -25
- data/spec/nuggets/array/correlation_spec.rb +0 -81
- data/spec/nuggets/array/flatten_once_spec.rb +0 -16
- data/spec/nuggets/array/flush_spec.rb +0 -43
- data/spec/nuggets/array/format_spec.rb +0 -52
- data/spec/nuggets/array/hashify_spec.rb +0 -41
- data/spec/nuggets/array/histogram_spec.rb +0 -87
- data/spec/nuggets/array/in_order_spec.rb +0 -13
- data/spec/nuggets/array/limit_spec.rb +0 -62
- data/spec/nuggets/array/mean_spec.rb +0 -203
- data/spec/nuggets/array/median_spec.rb +0 -77
- data/spec/nuggets/array/mode_spec.rb +0 -57
- data/spec/nuggets/array/monotone_spec.rb +0 -30
- data/spec/nuggets/array/only_spec.rb +0 -26
- data/spec/nuggets/array/regression_spec.rb +0 -54
- data/spec/nuggets/array/runiq_spec.rb +0 -25
- data/spec/nuggets/array/standard_deviation_spec.rb +0 -33
- data/spec/nuggets/array/to_hash_spec.rb +0 -28
- data/spec/nuggets/array/variance_spec.rb +0 -106
- data/spec/nuggets/dotted_decimal_spec.rb +0 -27
- data/spec/nuggets/enumerable/all_any_extended_spec.rb +0 -31
- data/spec/nuggets/enumerable/minmax_spec.rb +0 -21
- data/spec/nuggets/env/set_spec.rb +0 -29
- data/spec/nuggets/env/user_encoding_spec.rb +0 -38
- data/spec/nuggets/env/user_home_spec.rb +0 -42
- data/spec/nuggets/file/ext_spec.rb +0 -38
- data/spec/nuggets/file/replace_spec.rb +0 -95
- data/spec/nuggets/file/sub_spec.rb +0 -149
- data/spec/nuggets/file/which_spec.rb +0 -22
- data/spec/nuggets/hash/at_spec.rb +0 -19
- data/spec/nuggets/hash/deep_fetch_spec.rb +0 -159
- data/spec/nuggets/hash/deep_merge_spec.rb +0 -78
- data/spec/nuggets/hash/in_order_spec.rb +0 -12
- data/spec/nuggets/hash/insert_spec.rb +0 -13
- data/spec/nuggets/hash/nest_spec.rb +0 -102
- data/spec/nuggets/hash/only_spec.rb +0 -29
- data/spec/nuggets/hash/seen_spec.rb +0 -36
- data/spec/nuggets/hash/unroll_spec.rb +0 -68
- data/spec/nuggets/i18n_spec.rb +0 -13
- data/spec/nuggets/integer/factorial_spec.rb +0 -10
- data/spec/nuggets/integer/length_spec.rb +0 -18
- data/spec/nuggets/integer/map_spec.rb +0 -19
- data/spec/nuggets/integer/to_binary_s_spec.rb +0 -19
- data/spec/nuggets/numeric/duration_spec.rb +0 -25
- data/spec/nuggets/numeric/limit_spec.rb +0 -16
- data/spec/nuggets/numeric/signum_spec.rb +0 -16
- data/spec/nuggets/numeric/to_multiple_spec.rb +0 -16
- data/spec/nuggets/object/blank_spec.rb +0 -34
- data/spec/nuggets/object/boolean_spec.rb +0 -23
- data/spec/nuggets/object/msend_spec.rb +0 -25
- data/spec/nuggets/object/silence_spec.rb +0 -36
- data/spec/nuggets/object/singleton_class_spec.rb +0 -51
- data/spec/nuggets/proc/bind_spec.rb +0 -28
- data/spec/nuggets/range/quantile_spec.rb +0 -33
- data/spec/nuggets/string/camelscore_spec.rb +0 -114
- data/spec/nuggets/string/capitalize_first_spec.rb +0 -13
- data/spec/nuggets/string/case_spec.rb +0 -31
- data/spec/nuggets/string/evaluate_spec.rb +0 -24
- data/spec/nuggets/string/msub_spec.rb +0 -20
- data/spec/nuggets/string/nsub_spec.rb +0 -13
- data/spec/nuggets/string/sub_with_md_spec.rb +0 -25
- data/spec/nuggets/string/wc_spec.rb +0 -73
- data/spec/nuggets/string/word_wrap_spec.rb +0 -81
- data/spec/nuggets/string/xor_spec.rb +0 -57
- data/spec/nuggets/uri/content_type_spec.rb +0 -42
- data/spec/nuggets/uri/exist_spec.rb +0 -49
- data/spec/spec_helper.rb +0 -36
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'nuggets/string/evaluate'
|
2
|
-
|
3
|
-
describe_extended String, Nuggets::String::EvaluateMixin do
|
4
|
-
|
5
|
-
describe do
|
6
|
-
|
7
|
-
%w[bl#{a}blub bl#{a}#{b}lub].each { |str|
|
8
|
-
{ 'blablub' => %w[a b], 'blubblub' => %w[ub b] }.each { |res, (a, b)|
|
9
|
-
example { str.evaluate(binding).should == res }
|
10
|
-
}
|
11
|
-
|
12
|
-
example do
|
13
|
-
lambda { str.evaluate(binding) }.should raise_error(NameError, /`a'/)
|
14
|
-
end
|
15
|
-
}
|
16
|
-
|
17
|
-
end
|
18
|
-
|
19
|
-
[ 'a"b"c', 'a\"b\"c', 'a\\"b\\"c', 'a\\\"b\\\"c',
|
20
|
-
"a'b'c", 'a%q{b}c', 'a{b}c', 'a{bc', 'ab}c' ].each { |str|
|
21
|
-
example { str.evaluate(binding).should == str }
|
22
|
-
}
|
23
|
-
|
24
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'nuggets/string/msub'
|
2
|
-
|
3
|
-
describe String, 'msub' do
|
4
|
-
|
5
|
-
let(:s) { 'Foo, Bar - Baz' }
|
6
|
-
|
7
|
-
example { s.gsub(/a/, 'o').gsub(/o/, 'a').should == 'Faa, Bar - Baz' }
|
8
|
-
example { s.msub('a' => 'o', 'o' => 'a').should == 'Faa, Bor - Boz' }
|
9
|
-
|
10
|
-
example { s.msub!('a' => 'o', 'o' => 'a'); s.should == 'Faa, Bor - Boz' }
|
11
|
-
|
12
|
-
example { s.msub(/[A-Z]/ => '#{__match__.downcase}', __binding__: binding).should == 'foo, bar - baz' }
|
13
|
-
example { s.msub(/[A-Z]/ => lambda { |match| match.downcase }).should == 'foo, bar - baz' }
|
14
|
-
|
15
|
-
t = '!!!'
|
16
|
-
|
17
|
-
example { lambda { s.msub('r' => '???', 'z' => '#{t}') }.should raise_error(NameError) }
|
18
|
-
example { s.msub('r' => '???', 'z' => '#{t}', __binding__: binding).should == 'Foo, Ba??? - Ba!!!' }
|
19
|
-
|
20
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
require 'nuggets/string/nsub'
|
2
|
-
|
3
|
-
describe String, 'nsub' do
|
4
|
-
|
5
|
-
let(:s) { 'a b c d e f g h i' }
|
6
|
-
|
7
|
-
example { s.nsub(' ', '', 6).should == 'abcdefg h i' }
|
8
|
-
|
9
|
-
example { s.nsub(' ', 6) { '' }.should == 'abcdefg h i' }
|
10
|
-
|
11
|
-
example { s.nsub!(' ', '', 6); s.should == 'abcdefg h i' }
|
12
|
-
|
13
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'nuggets/string/sub_with_md'
|
2
|
-
|
3
|
-
describe String, 'sub_with_md' do
|
4
|
-
|
5
|
-
let(:s) { 'Foo, Bar - Baz' }
|
6
|
-
|
7
|
-
example {
|
8
|
-
s.gsub(/\w(\w+)(\W*)/) { |m|
|
9
|
-
"#{$1.gsub(/[ao]/, 'X')}#{$2}"
|
10
|
-
}.should == 'XXXrXz'
|
11
|
-
}
|
12
|
-
|
13
|
-
example {
|
14
|
-
s.gsub_with_md(/\w(\w+)(\W*)/) { |md|
|
15
|
-
"#{md[1].gsub(/[ao]/, 'X')}#{md[2]}"
|
16
|
-
}.should == 'XX, Xr - Xz'
|
17
|
-
}
|
18
|
-
|
19
|
-
example {
|
20
|
-
s.gsub_with_md(/\w(\w+)(\W*)/) { |md|
|
21
|
-
"#{md[1].gsub_with_md(/[ao]/) { |md2| md2[0].upcase }}#{md[2]}"
|
22
|
-
}.should == 'OO, Ar - Az'
|
23
|
-
}
|
24
|
-
|
25
|
-
end
|
@@ -1,73 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'nuggets/string/wc'
|
4
|
-
|
5
|
-
describe_extended String, Nuggets::String::WcMixin do
|
6
|
-
|
7
|
-
describe 'empty' do
|
8
|
-
|
9
|
-
before do
|
10
|
-
@str = ''
|
11
|
-
end
|
12
|
-
|
13
|
-
example { @str.wc.should == [0, 0, 0] }
|
14
|
-
|
15
|
-
example { @str.line_count.should == 0 }
|
16
|
-
|
17
|
-
example { @str.word_count.should == 0 }
|
18
|
-
|
19
|
-
example { @str.byte_count.should == 0 }
|
20
|
-
|
21
|
-
example { @str.char_count.should == 0 }
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
describe 'non-empty' do
|
26
|
-
|
27
|
-
before do
|
28
|
-
@str = <<-STR
|
29
|
-
The fox went out on a chilly night / Prayed for the moon to give him light / For he had many a mile to go that night / Before he reached the town o
|
30
|
-
He ran til he came to a great big bin / Where the ducks and the geese were kept therein / Said, a couple of you are going to grease my chin / Before I leave this town o
|
31
|
-
He grabbed the grey goose by the neck / Throwed a duck across his back / He didn't mind the quack, quack, quack / And the legs all dangling down o
|
32
|
-
Then old mother Flipper-flopper jumped out of bed / Out of the window she cocked her head / Crying, John, John the grey goose is gone / and the fox is on the town o
|
33
|
-
Then John he went to the top of the hill / Blew his horn both loud and shrill / The fox, he said, I better flee with my kill / Or they'll soon be on my trail o
|
34
|
-
He ran till he came to his cozy den / There were the little ones, eight, nine, ten / Saying, Daddy, daddy, Better go back again / For it must be a mighty fine town o
|
35
|
-
Then the fox and his wife, without any strife / Cut up the goose with a carving knife / They never had such a supper in their life / And the little ones chewed on the bones o
|
36
|
-
STR
|
37
|
-
end
|
38
|
-
|
39
|
-
example { @str.wc.should == [7, 252, 1130] }
|
40
|
-
|
41
|
-
example { @str.line_count.should == 7 }
|
42
|
-
|
43
|
-
example { @str.word_count.should == 252 }
|
44
|
-
|
45
|
-
example { @str.byte_count.should == 1130 }
|
46
|
-
|
47
|
-
example { @str.char_count.should == 1130 }
|
48
|
-
|
49
|
-
end
|
50
|
-
|
51
|
-
describe 'special' do
|
52
|
-
|
53
|
-
before do
|
54
|
-
@str = <<-STR
|
55
|
-
TECHNICIÄNS ÖF SPÅCE SHIP EÅRTH
|
56
|
-
THIS IS YÖÜR CÄPTÅIN SPEÄKING
|
57
|
-
YÖÜR ØÅPTÅIN IS DEA̋D
|
58
|
-
STR
|
59
|
-
end
|
60
|
-
|
61
|
-
example { @str.wc.should == [3, 14, 99] }
|
62
|
-
|
63
|
-
example { @str.line_count.should == 3 }
|
64
|
-
|
65
|
-
example { @str.word_count.should == 14 }
|
66
|
-
|
67
|
-
example { @str.byte_count.should == 99 }
|
68
|
-
|
69
|
-
example { @str.char_count.should == 84 }
|
70
|
-
|
71
|
-
end
|
72
|
-
|
73
|
-
end
|
@@ -1,81 +0,0 @@
|
|
1
|
-
require 'nuggets/string/word_wrap'
|
2
|
-
|
3
|
-
describe String, 'word_wrap' do
|
4
|
-
|
5
|
-
let(:s) { <<-EOT }
|
6
|
-
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nullam nulla arcu,
|
7
|
-
ullamcorper non, vulputate eget, elementum quis, sapien. Quisque consequat
|
8
|
-
porta enim. Phasellus porta libero et turpis. Ut felis.
|
9
|
-
|
10
|
-
Phasellus eget est a enim rutrum accumsan. Integer nec purus. Maecenas
|
11
|
-
facilisis urna sed arcu. Suspendisse potenti.
|
12
|
-
|
13
|
-
|
14
|
-
Vestibulum lacus metus, faucibus sit amet, mattis non, mollis sed, pede. Aenean
|
15
|
-
vitae sem nec sem euismod sollicitudin. Cras rhoncus.
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
Phasellus condimentum, ante a cursus dictum, lectus ipsum convallis magna, sed
|
20
|
-
tincidunt massa eros vitae ante. Suspendisse nec sem.
|
21
|
-
In hac habitasse platea dictumst. Fusce purus leo, ullamcorper sit amet, luctus
|
22
|
-
in, mollis mollis, enim. In adipiscing erat.
|
23
|
-
EOT
|
24
|
-
|
25
|
-
s60 = <<-EOT
|
26
|
-
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
|
27
|
-
Nullam nulla arcu,
|
28
|
-
ullamcorper non, vulputate eget, elementum quis, sapien.
|
29
|
-
Quisque consequat
|
30
|
-
porta enim. Phasellus porta libero et turpis. Ut felis.
|
31
|
-
|
32
|
-
Phasellus eget est a enim rutrum accumsan. Integer nec
|
33
|
-
purus. Maecenas
|
34
|
-
facilisis urna sed arcu. Suspendisse potenti.
|
35
|
-
|
36
|
-
|
37
|
-
Vestibulum lacus metus, faucibus sit amet, mattis non,
|
38
|
-
mollis sed, pede. Aenean
|
39
|
-
vitae sem nec sem euismod sollicitudin. Cras rhoncus.
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
Phasellus condimentum, ante a cursus dictum, lectus ipsum
|
44
|
-
convallis magna, sed
|
45
|
-
tincidunt massa eros vitae ante. Suspendisse nec sem.
|
46
|
-
In hac habitasse platea dictumst. Fusce purus leo,
|
47
|
-
ullamcorper sit amet, luctus
|
48
|
-
in, mollis mollis, enim. In adipiscing erat.
|
49
|
-
EOT
|
50
|
-
|
51
|
-
example {
|
52
|
-
s.word_wrap(60).should == s60
|
53
|
-
}
|
54
|
-
|
55
|
-
example {
|
56
|
-
s.word_wrap!(60); s.should == s60
|
57
|
-
}
|
58
|
-
|
59
|
-
example {
|
60
|
-
s.word_wrap(79).should == <<-EOT
|
61
|
-
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nullam nulla arcu,
|
62
|
-
ullamcorper non, vulputate eget, elementum quis, sapien. Quisque consequat
|
63
|
-
porta enim. Phasellus porta libero et turpis. Ut felis.
|
64
|
-
|
65
|
-
Phasellus eget est a enim rutrum accumsan. Integer nec purus. Maecenas
|
66
|
-
facilisis urna sed arcu. Suspendisse potenti.
|
67
|
-
|
68
|
-
|
69
|
-
Vestibulum lacus metus, faucibus sit amet, mattis non, mollis sed, pede. Aenean
|
70
|
-
vitae sem nec sem euismod sollicitudin. Cras rhoncus.
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
Phasellus condimentum, ante a cursus dictum, lectus ipsum convallis magna, sed
|
75
|
-
tincidunt massa eros vitae ante. Suspendisse nec sem.
|
76
|
-
In hac habitasse platea dictumst. Fusce purus leo, ullamcorper sit amet, luctus
|
77
|
-
in, mollis mollis, enim. In adipiscing erat.
|
78
|
-
EOT
|
79
|
-
}
|
80
|
-
|
81
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
require 'nuggets/string/xor'
|
2
|
-
|
3
|
-
describe_extended String, Nuggets::String::XorMixin do
|
4
|
-
|
5
|
-
describe 'same length' do
|
6
|
-
|
7
|
-
before do
|
8
|
-
@str1 = 'foobar'
|
9
|
-
@str2 = 'secret'
|
10
|
-
|
11
|
-
@res = "\025\n\f\020\004\006"
|
12
|
-
end
|
13
|
-
|
14
|
-
example { @str1.xor(@str2).should == @res }
|
15
|
-
|
16
|
-
example { @str2.xor(@str1).should == @res }
|
17
|
-
|
18
|
-
example { (@str1 ^ @str2).should == @res }
|
19
|
-
|
20
|
-
example { (@str2 ^ @str1).should == @res }
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
describe 'different length' do
|
25
|
-
|
26
|
-
before do
|
27
|
-
@str1 = 'baz'
|
28
|
-
@str2 = 'secret'
|
29
|
-
@str3 = 'foobarbaz'
|
30
|
-
|
31
|
-
@res1 = "sec\020\004\016"
|
32
|
-
@res2 = "foo\021\004\021\020\004\016"
|
33
|
-
end
|
34
|
-
|
35
|
-
example { @str1.xor(@str2).should == @res1 }
|
36
|
-
|
37
|
-
example { @str2.xor(@str1).should == @res1 }
|
38
|
-
|
39
|
-
example { (@str1 ^ @str2).should == @res1 }
|
40
|
-
|
41
|
-
example { (@str2 ^ @str1).should == @res1 }
|
42
|
-
|
43
|
-
example { lambda { @str1.xor(@str2, true) }.should raise_error(ArgumentError, 'must be of same length') }
|
44
|
-
|
45
|
-
example { @str2.xor(@str3).should == @res2 }
|
46
|
-
|
47
|
-
example { @str3.xor(@str2).should == @res2 }
|
48
|
-
|
49
|
-
example { (@str2 ^ @str3).should == @res2 }
|
50
|
-
|
51
|
-
example { (@str3 ^ @str2).should == @res2 }
|
52
|
-
|
53
|
-
example { lambda { @str2.xor(@str3, true) }.should raise_error(ArgumentError, 'must be of same length') }
|
54
|
-
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'nuggets/uri/content_type'
|
2
|
-
|
3
|
-
describe_extended URI, Nuggets::URI::ContentTypeMixin, true do
|
4
|
-
|
5
|
-
let(:cache) { Nuggets::URI::RedirectMixin::URI_REDIRECT_HTTP_CACHE }
|
6
|
-
|
7
|
-
{
|
8
|
-
'http://www.google.de' => 'text/html',
|
9
|
-
'http://example.de/misc/' => 'text/html',
|
10
|
-
'http://example.de/misc/ww.png' => 'image/png',
|
11
|
-
'http://example.de/misc/suicide_is_painless.mid' => 'audio/midi',
|
12
|
-
'http://example.de/misc/fugmann/wille_-_fugmann-slides.tar.gz' => 'application/x-gzip',
|
13
|
-
'http://example.de/misc/i_hate_ms.pdf' => 'application/pdf',
|
14
|
-
'http://example.de/bla' => false,
|
15
|
-
'http://blawinter.de' => nil,
|
16
|
-
'htp://www.google.de' => nil,
|
17
|
-
'ftp://example.org' => nil,
|
18
|
-
'www.google.de' => nil
|
19
|
-
}.each { |u, t|
|
20
|
-
example {
|
21
|
-
begin
|
22
|
-
req, res = double(Net::HTTP), double(Net::HTTPResponse)
|
23
|
-
|
24
|
-
req.stub(:use_ssl=)
|
25
|
-
req.stub(:use_ssl?)
|
26
|
-
|
27
|
-
res.stub(:success?).and_return(t)
|
28
|
-
res.stub(:content_type).and_return(t)
|
29
|
-
|
30
|
-
req.stub(:head).and_return(res)
|
31
|
-
|
32
|
-
cache.update([(uri = URI(u)).host, uri.port] => req)
|
33
|
-
|
34
|
-
URI.content_type(u).should == t
|
35
|
-
cache.size.should == 1
|
36
|
-
ensure
|
37
|
-
cache.clear
|
38
|
-
end
|
39
|
-
}
|
40
|
-
}
|
41
|
-
|
42
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
require 'nuggets/uri/exist'
|
2
|
-
|
3
|
-
describe_extended URI, Nuggets::URI::ExistMixin, true do
|
4
|
-
|
5
|
-
let(:cache) { Nuggets::URI::RedirectMixin::URI_REDIRECT_HTTP_CACHE }
|
6
|
-
|
7
|
-
%w[
|
8
|
-
http://www.google.de
|
9
|
-
http://example.de
|
10
|
-
http://example.de/bla
|
11
|
-
http://example.de/index.html
|
12
|
-
http://example.de/index.htm
|
13
|
-
http://xuugle.de
|
14
|
-
].each { |u|
|
15
|
-
[true, false, nil].each { |s|
|
16
|
-
example {
|
17
|
-
begin
|
18
|
-
req, res = double(Net::HTTP), double(Net::HTTPResponse)
|
19
|
-
|
20
|
-
req.stub(:use_ssl=)
|
21
|
-
req.stub(:use_ssl?)
|
22
|
-
|
23
|
-
res.stub(:success?).and_return(s)
|
24
|
-
|
25
|
-
req.stub(:head).and_return(res)
|
26
|
-
|
27
|
-
cache.update([(uri = URI(u)).host, uri.port] => req)
|
28
|
-
|
29
|
-
URI.exist?(u).should == s
|
30
|
-
cache.size.should == 1
|
31
|
-
ensure
|
32
|
-
cache.clear
|
33
|
-
end
|
34
|
-
}
|
35
|
-
}
|
36
|
-
}
|
37
|
-
|
38
|
-
%w[
|
39
|
-
htp://www.google.de
|
40
|
-
ftp://example.org
|
41
|
-
www.google.de
|
42
|
-
].each { |u|
|
43
|
-
example {
|
44
|
-
URI.exist?(u).should be_nil
|
45
|
-
cache.should be_empty
|
46
|
-
}
|
47
|
-
}
|
48
|
-
|
49
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
$:.unshift('lib') unless $:.first == 'lib'
|
2
|
-
|
3
|
-
Float::NAN = 0 / 0.0 unless Float.const_defined?(:NAN)
|
4
|
-
Float::INFINITY = 1 / 0.0 unless Float.const_defined?(:INFINITY)
|
5
|
-
|
6
|
-
RSpec.configure { |config|
|
7
|
-
%w[expect mock].each { |what|
|
8
|
-
config.send("#{what}_with", :rspec) { |c| c.syntax = [:should, :expect] }
|
9
|
-
}
|
10
|
-
|
11
|
-
config.include(Module.new {
|
12
|
-
def equal_float(value, precision = 1.0e-14)
|
13
|
-
be_within(precision).of(value)
|
14
|
-
end
|
15
|
-
|
16
|
-
def tempfile(txt = @txt)
|
17
|
-
t = Tempfile.open("nuggets_spec_#{object_id}_temp") { |f| f.puts txt }
|
18
|
-
block_given? ? yield(t.path) : t.path
|
19
|
-
ensure
|
20
|
-
t.close(true) if t
|
21
|
-
end
|
22
|
-
})
|
23
|
-
}
|
24
|
-
|
25
|
-
extend(Module.new {
|
26
|
-
def describe_extended(mod, ext, singleton = false, &block)
|
27
|
-
describe(mod, 'when extended by', ext) {
|
28
|
-
example {
|
29
|
-
klass = singleton ? class << mod; self; end : mod
|
30
|
-
klass.ancestors.should include(ext)
|
31
|
-
}
|
32
|
-
|
33
|
-
class_eval(&block)
|
34
|
-
}
|
35
|
-
end
|
36
|
-
})
|