tagen 1.1.7 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. data/.gitignore +4 -1
  2. data/.travis.yml +5 -0
  3. data/CHANGELOG +6 -0
  4. data/Gemfile +2 -3
  5. data/Gemfile.lock +13 -15
  6. data/README.md +20 -39
  7. data/Rakefile +2 -1
  8. data/benchmark/a.rb +14 -0
  9. data/lib/tagen/core.rb +17 -22
  10. data/lib/tagen/core/array.rb +5 -109
  11. data/lib/tagen/core/array/append.rb +3 -0
  12. data/lib/tagen/core/array/delete_values.rb +43 -0
  13. data/lib/tagen/core/array/extract_options.rb +35 -94
  14. data/lib/tagen/core/class.rb +1 -0
  15. data/lib/tagen/core/enumerable.rb +15 -18
  16. data/lib/tagen/core/enumerator.rb +22 -12
  17. data/lib/tagen/core/exception.rb +5 -3
  18. data/lib/tagen/core/file.rb +1 -0
  19. data/lib/tagen/core/hash.rb +4 -39
  20. data/lib/tagen/core/integer.rb +2 -0
  21. data/lib/tagen/core/io.rb +59 -26
  22. data/lib/tagen/core/kernel.rb +5 -64
  23. data/lib/tagen/core/kernel/deprecate.rb +5 -0
  24. data/lib/tagen/core/kernel/platform.rb +46 -0
  25. data/lib/tagen/core/kernel/shell.rb +45 -0
  26. data/lib/tagen/core/module.rb +9 -11
  27. data/lib/tagen/core/numeric.rb +4 -2
  28. data/lib/tagen/core/object.rb +6 -21
  29. data/lib/tagen/core/process.rb +6 -4
  30. data/lib/tagen/core/re.rb +2 -2
  31. data/lib/tagen/core/string.rb +12 -47
  32. data/lib/tagen/core/time.rb +30 -38
  33. data/lib/tagen/erb.rb +10 -8
  34. data/lib/tagen/net/http.rb +33 -29
  35. data/lib/tagen/pathname.rb +1 -5
  36. data/lib/tagen/rbconfig.rb +8 -0
  37. data/lib/tagen/socket.rb +8 -2
  38. data/lib/tagen/uri.rb +9 -0
  39. data/lib/tagen/version.rb +1 -1
  40. data/lib/tagen/vim.rb +8 -8
  41. data/lib/tagen/xmpp4r.rb +23 -23
  42. data/spec/spec_helper.rb +23 -17
  43. data/spec/tagen/core/array/delete_values_spec.rb +19 -0
  44. data/spec/tagen/core/array/extract_options_spec.rb +9 -29
  45. data/spec/tagen/core/enumerable_spec.rb +9 -0
  46. data/spec/tagen/core/enumerator_spec.rb +10 -12
  47. data/spec/tagen/core/exception_spec.rb +14 -9
  48. data/spec/tagen/core/io_spec.rb +20 -0
  49. data/spec/tagen/core/kernel/platform_spec.rb +92 -0
  50. data/spec/tagen/core/kernel/shell_spec.rb +27 -0
  51. data/spec/tagen/core/numeric_spec.rb +10 -0
  52. data/spec/tagen/core/process_spec.rb +14 -0
  53. data/spec/tagen/core/re_spec.rb +9 -0
  54. data/spec/tagen/core/string_spec.rb +9 -0
  55. data/spec/tagen/core/time_spec.rb +6 -51
  56. data/spec/tagen/erb_spec.rb +3 -10
  57. data/spec/tagen/pathname_spec.rb +11 -0
  58. data/spec/tagen/rbconfig_spec.rb +11 -0
  59. data/spec/tagen/socket_spec.rb +7 -5
  60. data/spec/tagen/uri_spec.rb +13 -0
  61. data/tagen.gemspec +3 -4
  62. metadata +45 -51
  63. data/TODO +0 -1
  64. data/docs/Architecture.md +0 -17
  65. data/docs/CoreExtensions.md +0 -40
  66. data/docs/ExtraExtensions.md +0 -20
  67. data/lib/tagen/RMagick.rb +0 -12
  68. data/lib/tagen/audioinfo.rb +0 -22
  69. data/lib/tagen/cairo.rb +0 -811
  70. data/lib/tagen/core/extend_hash.rb +0 -46
  71. data/lib/tagen/core/marshal.rb +0 -34
  72. data/lib/tagen/core/open_option.rb +0 -161
  73. data/lib/tagen/core/string/pyformat.rb +0 -336
  74. data/lib/tagen/core/symbol.rb +0 -8
  75. data/lib/tagen/date.rb +0 -80
  76. data/lib/tagen/gdk_pixbuf2.rb +0 -26
  77. data/lib/tagen/gtk2.rb +0 -122
  78. data/lib/tagen/ncurses.rb +0 -246
  79. data/lib/tagen/poppler.rb +0 -48
  80. data/lib/tagen/tree.rb +0 -77
  81. data/lib/tagen/xmpp4r/roster.rb +0 -20
  82. data/lib/tagen/yaml.rb +0 -38
  83. data/spec/tagen/cairo_spec.rb +0 -137
  84. data/spec/tagen/core/array_spec.rb +0 -42
  85. data/spec/tagen/core/extend_hash_spec.rb +0 -54
  86. data/spec/tagen/core/hash_spec.rb +0 -10
  87. data/spec/tagen/core/module_spec.rb +0 -14
  88. data/spec/tagen/core/open_option_spec.rb +0 -83
  89. data/spec/tagen/core/string/pyformat_spec.rb +0 -98
  90. data/spec/tagen/core/symbol_spec.rb +0 -15
  91. data/spec/tagen/core_spec.rb +0 -6
  92. data/spec/tagen/date_spec.rb +0 -146
@@ -1,83 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe OpenOption do
4
- before :each do
5
- @o = OpenOption.new a: 1, force: true
6
- end
7
-
8
- it "runs ok" do
9
- @o._data.should == {a: 1, force: true}
10
- end
11
-
12
-
13
-
14
- it "read value using [:sym] " do
15
- @o[:a].should == 1
16
- end
17
-
18
- it "read value using ['str'] " do
19
- @o['a'].should == 1
20
- end
21
-
22
- it "read value using #key" do
23
- @o.a.should == 1
24
- end
25
-
26
- it "read value using #key?" do
27
- @o.force?.should be_true
28
- end
29
-
30
- it "return nil if no key" do
31
- @o[:key_not_exists].should be_nil
32
- end
33
-
34
- it "write value using [:sym]=" do
35
- @o[:b] = 2
36
- @o._data[:b].should == 2
37
- end
38
-
39
- it "write value using ['key']=" do
40
- @o['b'] = 3
41
- @o._data[:b].should == 3
42
- end
43
-
44
- it "write value using #key=" do
45
- @o.b = 4
46
- @o._data[:b].should == 4
47
- end
48
-
49
- it "#_merge" do
50
- o = @o._merge(a: 2)
51
- o._data[:a].should == 2
52
- end
53
-
54
- it "#_merge!" do
55
- @o._merge!(a: 2)
56
- @o._data[:a].should == 2
57
- end
58
-
59
- it "#_replace runs ok" do
60
- @o._replace ({b: 2})
61
- @o._data.should == {b: 2}
62
- end
63
-
64
- it "support normal hash method" do
65
- @o._keys.should == [:a, :force]
66
- end
67
-
68
- describe ".convert_hash" do
69
- it "deep convert hash" do
70
- data = {a: {b: 1} }
71
- newdata = OpenOption.convert_hash(data)
72
- newdata[:a].should be_an_instance_of OpenOption
73
- end
74
-
75
- it "store string-key as symbol-key internal" do
76
- data = {'a' => 1 }
77
- newdata = OpenOption.convert_hash(data)
78
- newdata.keys[0].should be_an_instance_of Symbol
79
- end
80
-
81
- end
82
-
83
- end
@@ -1,98 +0,0 @@
1
- require "spec_helper"
2
- #format_spec ::= [[fill]align][sign][#][0][width][,][.precision][type]
3
-
4
-
5
- describe PyFormat do
6
- before :all do
7
- # from go-src/fmt
8
- @test_datas = [ #{{{1
9
-
10
- # type ::= s c b o d x X ¦ f/F g/G e/E n %
11
- [ "%{}", 1, "1"],
12
- [ "%{:s}", 1, "1"],
13
- [ "%{:c}", 'a', "a" ],
14
- [ "%{:b}", 0b10, "10" ],
15
- [ "%{:o}", 010, "10" ],
16
- [ "%{:x}", 0xa, "a" ],
17
- [ "%{:X}", 0xa, "A" ],
18
- [ "%{:f}", 1, "1.0"],
19
- [ "%{:F}", 1, "1.0"],
20
- [ "%{:e}", 1, "1.000000e+00" ],
21
- [ "%{:E}", 1, "1.000000E+00" ],
22
- [ "%{:g}", 1, "1"],
23
- [ "%{:g}", 1e6, "1e+06" ],
24
- [ "%{:G}", 1e6, "1E+06" ],
25
- #[ "{:n}" ],
26
- [ "%{:%}", 1, "100%" ],
27
-
28
- # width
29
- [ "%{:5s}", 1234, " 1234"],
30
- [ "%{:3s}", 1234, "1234"],
31
- [ "%{:.3s}", 1234, "123"],
32
-
33
- [ "%{:3f}", 1.123, "1.123"],
34
- [ "%{:.1f}", 1.123, "1.1"],
35
- [ "%{:4.1f}", 1.123, " 1.1"],
36
-
37
- # fill align
38
- [ "%{:0<2}", 1, "10"],
39
- [ "%{:0>2}", 1, "01"],
40
- [ "%{:0^4}", 1, "0100"],
41
- [ "%{:02}", 1, "01"],
42
-
43
- # sign
44
- [ "%{:+}", 1, "+1"],
45
- [ "%{: }", 1, " 1"],
46
- [ "%{:-}", 1, "1"],
47
-
48
- [ "%{:+3}", 1, " +1"],
49
- [ "%{:=3}", 1, "+01"],
50
-
51
- # alternate
52
- [ "%{:#b}", 0b1, "0b1"],
53
- [ "%{:#4b}", 0b1, " 0b1"],
54
- [ "%{:#o}", 01, "01"],
55
- [ "%{:#x}", 0x1, "0x1"],
56
-
57
- # comma
58
- [ "%{:,}", 1234, "1,234"],
59
-
60
- ] #
61
- end
62
- #}}}1
63
-
64
- it "parse_spec. PAT.match()" do
65
- a = "0> #07,.7f"
66
- b = [ '0', '>', ' ' ]+%w(# 0 7 , 7 f)
67
- PyFormat::Field::PAT.match(a).to_a[1..-1].should == b
68
- end
69
-
70
- describe "#format" do
71
- it "parse %{name}" do
72
- "%{a}".format(a: 1).should == "1"
73
- "%{a}".format(1).should == "1"
74
- end
75
-
76
- it "parse empty format %{}" do
77
- "%{}".format(1).should == "1"
78
- end
79
-
80
- it "parse escape format. \%{name}" do
81
- '\%{a}'.format.should == '\%{a}'
82
- end
83
-
84
- it "parse all formats %{} %{name} \%{name}" do
85
- '%{} %{a} \%{a}'.format(1,a: 2).should == '1 2 \%{a}'
86
- '%{} %{a} \%{a}'.format(1, 2).should == '1 2 \%{a}'
87
- end
88
- end
89
-
90
- it "@test_datas.each do format" do
91
- @test_datas.each do |fmtsrc, a, b|
92
- #puts "#{fmtsrc.inspect}: #{a.inspect}, #{b.inspect}"
93
- fmtsrc.format(a).should == b
94
- end
95
- end
96
- end
97
-
98
- # vim: foldmethod=marker
@@ -1,15 +0,0 @@
1
- require "spec_helper"
2
-
3
- =begin
4
- describe Symbol do
5
- describe "#method_missing" do
6
- it "#sub. returns a symbol" do
7
- :_foo.sub(/_/, '').should == :foo
8
- end
9
-
10
- it "#chars. return a enumerator" do
11
- :_foo.chars.should be_an_instance_of Enumerator
12
- end
13
- end
14
- end
15
- =end
@@ -1,6 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe "core" do
4
-
5
- end
6
-
@@ -1,146 +0,0 @@
1
- require "spec_helper"
2
- require "tagen/date"
3
-
4
- describe Date::Deta do
5
- before :all do
6
- Deta = Date::Deta
7
- end
8
-
9
- describe "#initialize" do
10
- it "works for 423 days" do
11
- d = Deta.new(423)
12
- d.years.should == 1
13
- d.months.should == 2
14
- d.days.should == 3
15
- end
16
-
17
- it "works for 32 days" do
18
- d = Deta.new(32)
19
- d.years.should == 0
20
- d.months.should == 1
21
- d.days.should == 2
22
- end
23
-
24
- it "works for 1 day" do
25
- d = Deta.new(1)
26
- d.years.should == 0
27
- d.months.should == 0
28
- d.days.should == 1
29
- end
30
- end
31
-
32
- describe "#display" do
33
- it "works for 1 years 2 months 3 days" do
34
- d = Deta.new(1)
35
- d.stub(:years) { 1 }
36
- d.stub(:months) { 2 }
37
- d.stub(:days) { 3 }
38
-
39
- d.display.should == "1 years 2 months 3 days"
40
- end
41
-
42
- it "works for 2 months 3 days" do
43
- d = Deta.new(1)
44
- d.stub(:years) { 0 }
45
- d.stub(:months) { 2 }
46
- d.stub(:days) { 3 }
47
-
48
- d.display.should == "2 months 3 days"
49
- end
50
-
51
- it "works for 0 days" do
52
- d = Deta.new(1)
53
- d.stub(:years) { 0 }
54
- d.stub(:months) { 0 }
55
- d.stub(:days) { 0 }
56
-
57
- d.display.should == "0 days"
58
- end
59
-
60
- it "works for 0 days with :include_days => false" do
61
- d = Deta.new(1)
62
- d.stub(:years) { 0 }
63
- d.stub(:months) { 0 }
64
- d.stub(:days) { 0 }
65
-
66
- d.display(false).should == ""
67
- end
68
- end
69
-
70
- describe "#to_a" do
71
- it "works" do
72
- d = Deta.new(1)
73
- d.stub(:years) { 1 }
74
- d.stub(:months) { 2 }
75
- d.stub(:days) { 3 }
76
-
77
- d.to_a.should == [ 1, 2, 3 ]
78
- end
79
- end
80
-
81
- describe ".deta" do
82
- it "works" do
83
- a = Deta.deta(Date.new(2011, 1, 2), Date.new(2011, 1, 1)).to_a
84
- b = [ 0, 0, 1 ]
85
-
86
- a.should == b
87
- end
88
- end
89
- end
90
-
91
- describe DateTime::Deta do
92
- before :all do
93
- Deta = DateTime::Deta
94
- end
95
-
96
- describe "#initialize" do
97
- it "works for 36561906 seconds" do
98
- d = Deta.new(36561906)
99
-
100
- d.years.should == 1
101
- d.months.should == 2
102
- d.days.should == 3
103
- d.hours.should == 4
104
- d.minutes.should == 5
105
- d.seconds.should == 6
106
- end
107
- end
108
-
109
- describe "#display" do
110
- it "works for 1 years 2 months 3 days 4 hours 5 minutes 6 seconds" do
111
- d = Deta.new(36561906)
112
-
113
- d.display.should == "1 years 2 months 3 days 4 hours 5 minutes 6 seconds"
114
- end
115
-
116
- it "works for 0 second" do
117
- d = Deta.new(0)
118
-
119
- d.display.should == "0 seconds"
120
- end
121
- end
122
-
123
- describe "#to_a" do
124
- it "works" do
125
- d = Deta.new(1)
126
- d.stub(:years) { 1 }
127
- d.stub(:months) { 2 }
128
- d.stub(:days) { 3 }
129
- d.stub(:hours) { 4 }
130
- d.stub(:minutes) { 5 }
131
- d.stub(:seconds) { 6 }
132
-
133
-
134
- d.to_a.should == [ 1, 2, 3, 4, 5, 6 ]
135
- end
136
- end
137
-
138
- describe ".deta" do
139
- it "works" do
140
- a = Deta.deta(DateTime.new(2011, 1, 1, 1, 1, 2), DateTime.new(2011, 1, 1, 1, 1, 1)).to_a
141
- b = [ 0, 0, 0, 0, 0, 1 ]
142
-
143
- a.should == b
144
- end
145
- end
146
- end