tagen 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. data/.gitignore +2 -0
  2. data/.yardopts +5 -0
  3. data/Gemfile +7 -0
  4. data/Gemfile.lock +24 -0
  5. data/README.md +60 -0
  6. data/Rakefile +9 -0
  7. data/docs/Architecture.md +17 -0
  8. data/docs/CoreExtensions.md +56 -0
  9. data/docs/ExtraExtensions.md +20 -0
  10. data/lib/tagen/audioinfo.rb +21 -0
  11. data/lib/tagen/cairo.rb +809 -0
  12. data/lib/tagen/core.rb +34 -0
  13. data/lib/tagen/core/array.rb +41 -0
  14. data/lib/tagen/core/array/extract_options.rb +40 -0
  15. data/lib/tagen/core/hash.rb +17 -0
  16. data/lib/tagen/core/io.rb +29 -0
  17. data/lib/tagen/core/kernel.rb +73 -0
  18. data/lib/tagen/core/marshal.rb +34 -0
  19. data/lib/tagen/core/module.rb +25 -0
  20. data/lib/tagen/core/numeric.rb +10 -0
  21. data/lib/tagen/core/object.rb +21 -0
  22. data/lib/tagen/core/pa.rb +187 -0
  23. data/lib/tagen/core/pa/cmd.rb +374 -0
  24. data/lib/tagen/core/pa/dir.rb +144 -0
  25. data/lib/tagen/core/pa/path.rb +190 -0
  26. data/lib/tagen/core/pa/state.rb +56 -0
  27. data/lib/tagen/core/process.rb +11 -0
  28. data/lib/tagen/core/re.rb +8 -0
  29. data/lib/tagen/core/string.rb +43 -0
  30. data/lib/tagen/core/string/pyformat.rb +322 -0
  31. data/lib/tagen/core/time.rb +8 -0
  32. data/lib/tagen/gdk_pixbuf2.rb +26 -0
  33. data/lib/tagen/gtk2.rb +122 -0
  34. data/lib/tagen/magick.rb +23 -0
  35. data/lib/tagen/ncurses.rb +245 -0
  36. data/lib/tagen/net/http.rb +34 -0
  37. data/lib/tagen/pathname.rb +8 -0
  38. data/lib/tagen/poppler.rb +47 -0
  39. data/lib/tagen/socket.rb +20 -0
  40. data/lib/tagen/tree.rb +75 -0
  41. data/lib/tagen/vim.rb +19 -0
  42. data/lib/tagen/xmpp4r.rb +1 -0
  43. data/lib/tagen/xmpp4r/roster.rb +20 -0
  44. data/spec/cairo_spec.rb +137 -0
  45. data/spec/core/pa/cmd_spec.rb +251 -0
  46. data/spec/core/pa/dir_spec.rb +59 -0
  47. data/spec/core/string/pyformat_spec.rb +86 -0
  48. data/spec/spec_helper.rb +0 -0
  49. data/tagen.gemspec +20 -0
  50. data/version.rb +7 -0
  51. metadata +117 -0
@@ -0,0 +1,59 @@
1
+ require "tagen/core"
2
+ require "fileutils"
3
+ require "tmpdir"
4
+
5
+ describe Pa do
6
+ before :all do
7
+ $tmpdir = Dir.mktmpdir
8
+ Dir.chdir($tmpdir)
9
+ end
10
+
11
+ after(:all) do
12
+ FileUtils.rm_r $tmpdir
13
+ end
14
+
15
+ describe "#glob" do
16
+ before(:all) do
17
+ FileUtils.touch(%w(fa .fa))
18
+ end
19
+
20
+ context "call without any option" do
21
+ it "returns 1 items" do
22
+ Pa.glob("*").should have(1).items
23
+ end
24
+ end
25
+
26
+ context "call with :dotmatch option" do
27
+ it "returns 2 items" do
28
+ Pa.glob("*", dotmatch: true).should have(2).items
29
+ end
30
+ end
31
+ end
32
+
33
+ describe "#each" do
34
+ # fa .fa fa~
35
+ # dira/
36
+ # dirb/
37
+ # b
38
+ before(:all) do
39
+ FileUtils.mkdir_p(["dira/dirb"])
40
+ FileUtils.touch(%w(fa .fa fa~ dira/dirb/b))
41
+ end
42
+
43
+ it "each() -> Enumerator" do
44
+ Pa.each.should be_an_instance_of Enumerator
45
+ Pa.each.with_object([]){|pa,m|m<<pa.b}.sort.should == %w(.fa dira fa fa~)
46
+ end
47
+
48
+ it "each(nodot: true) -> list all files except dot file" do
49
+ Pa.each(nodot: true).with_object([]){|pa,m|m<<pa.b}.sort.should == %w(dira fa fa~)
50
+ end
51
+
52
+ it "each_r -> Enumerator" do
53
+ Pa.each_r.should be_an_instance_of Enumerator
54
+ Pa.each_r.with_object([]){|(pa,r),m|m<<r}.sort.should == %w(.fa dira dira/dirb dira/dirb/b fa fa~)
55
+ end
56
+ end
57
+
58
+
59
+ end
@@ -0,0 +1,86 @@
1
+ require "tagen/core"
2
+ require "spec_helper"
3
+ #format_spec ::= [[fill]align][sign][#][0][width][,][.precision][type]
4
+
5
+
6
+ describe PyFormat do
7
+ before :all do
8
+ # from go-src/fmt
9
+ @test_datas = [
10
+
11
+ # type ::= s c b o d x X ¦ f/F g/G e/E n %
12
+ [ "{}", 1, "1"],
13
+ [ "{:s}", 1, "1"],
14
+ [ "{:c}", 'a', "a" ],
15
+ [ "{:b}", 0b10, "10" ],
16
+ [ "{:o}", 010, "10" ],
17
+ [ "{:x}", 0xa, "a" ],
18
+ [ "{:X}", 0xa, "A" ],
19
+ [ "{:f}", 1, "1.0"],
20
+ [ "{:F}", 1, "1.0"],
21
+ [ "{:e}", 1, "1.000000e+00" ],
22
+ [ "{:E}", 1, "1.000000E+00" ],
23
+ [ "{:g}", 1, "1"],
24
+ [ "{:g}", 1e6, "1e+06" ],
25
+ [ "{:G}", 1e6, "1E+06" ],
26
+ #[ "{:n}" ],
27
+ [ "{:%}", 1, "100%" ],
28
+
29
+ # width
30
+ [ "{:5s}", 1234, " 1234"],
31
+ [ "{:3s}", 1234, "1234"],
32
+ [ "{:.3s}", 1234, "123"],
33
+
34
+ [ "{:3f}", 1.123, "1.123"],
35
+ [ "{:.1f}", 1.123, "1.1"],
36
+ [ "{:4.1f}", 1.123, " 1.1"],
37
+
38
+ # fill align
39
+ [ "{:0<2}", 1, "10"],
40
+ [ "{:0>2}", 1, "01"],
41
+ [ "{:0^4}", 1, "0100"],
42
+ [ "{:02}", 1, "01"],
43
+
44
+ # sign
45
+ [ "{:+}", 1, "+1"],
46
+ [ "{: }", 1, " 1"],
47
+ [ "{:-}", 1, "1"],
48
+
49
+ [ "{:+3}", 1, " +1"],
50
+ [ "{:=3}", 1, "+01"],
51
+
52
+ # alternate
53
+ [ "{:#b}", 0b1, "0b1"],
54
+ [ "{:#4b}", 0b1, " 0b1"],
55
+ [ "{:#o}", 01, "01"],
56
+ [ "{:#x}", 0x1, "0x1"],
57
+
58
+ # comma
59
+ [ "{:,}", 1234, "1,234"],
60
+
61
+ ] #
62
+ end
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
+ it "parse: '{} {}'" do
71
+ [
72
+ [ "{} {}", [1, 2], "1 2" ],
73
+ [ "{a} {{b}}", [{a:1}], "1 {{b}}" ],
74
+ [ "{} {a} {b}", [1,2,3,{b:4}],"1 2 4" ],
75
+ ].each do |src, args, rst|
76
+ src.format(*args).should == rst
77
+ end
78
+ end
79
+
80
+ it "@test_datas.each do format" do
81
+ @test_datas.each do |fmtsrc, a, b|
82
+ #puts "#{fmtsrc.inspect}: #{a.inspect}, #{b.inspect}"
83
+ fmtsrc.format(a).should == b
84
+ end
85
+ end
86
+ end
File without changes
data/tagen.gemspec ADDED
@@ -0,0 +1,20 @@
1
+ $: << "."
2
+ require "version"
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "tagen"
6
+ s.version = VERSION::IS
7
+ s.summary = "a core and extra extension to ruby library"
8
+ s.description = <<-EOF
9
+ an extension to ruby core and gem library. use some active_support/core_ext, but smaller than active_support. active_support is mainly target to Rails, but tagen is target to generic ruby development.
10
+ EOF
11
+
12
+ s.author = "Guten"
13
+ s.email = "ywzhaifei@gmail.com"
14
+ s.homepage = "http://github.com/GutenLinux/tagen"
15
+ s.rubyforge_project = "xx"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+
19
+ s.add_dependency "activesupport"
20
+ end
data/version.rb ADDED
@@ -0,0 +1,7 @@
1
+ module VERSION
2
+ MAJOR = 0
3
+ MINOR = 1
4
+ PATCH = 0
5
+
6
+ IS = [MAJOR, MINOR, PATCH].join(".")
7
+ end
metadata ADDED
@@ -0,0 +1,117 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tagen
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.1.0
6
+ platform: ruby
7
+ authors:
8
+ - Guten
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-03-05 00:00:00 +08:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: activesupport
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: "0"
25
+ type: :runtime
26
+ version_requirements: *id001
27
+ description: |
28
+ an extension to ruby core and gem library. use some active_support/core_ext, but smaller than active_support. active_support is mainly target to Rails, but tagen is target to generic ruby development.
29
+
30
+ email: ywzhaifei@gmail.com
31
+ executables: []
32
+
33
+ extensions: []
34
+
35
+ extra_rdoc_files: []
36
+
37
+ files:
38
+ - .gitignore
39
+ - .yardopts
40
+ - Gemfile
41
+ - Gemfile.lock
42
+ - README.md
43
+ - Rakefile
44
+ - docs/Architecture.md
45
+ - docs/CoreExtensions.md
46
+ - docs/ExtraExtensions.md
47
+ - lib/tagen/audioinfo.rb
48
+ - lib/tagen/cairo.rb
49
+ - lib/tagen/core.rb
50
+ - lib/tagen/core/array.rb
51
+ - lib/tagen/core/array/extract_options.rb
52
+ - lib/tagen/core/hash.rb
53
+ - lib/tagen/core/io.rb
54
+ - lib/tagen/core/kernel.rb
55
+ - lib/tagen/core/marshal.rb
56
+ - lib/tagen/core/module.rb
57
+ - lib/tagen/core/numeric.rb
58
+ - lib/tagen/core/object.rb
59
+ - lib/tagen/core/pa.rb
60
+ - lib/tagen/core/pa/cmd.rb
61
+ - lib/tagen/core/pa/dir.rb
62
+ - lib/tagen/core/pa/path.rb
63
+ - lib/tagen/core/pa/state.rb
64
+ - lib/tagen/core/process.rb
65
+ - lib/tagen/core/re.rb
66
+ - lib/tagen/core/string.rb
67
+ - lib/tagen/core/string/pyformat.rb
68
+ - lib/tagen/core/time.rb
69
+ - lib/tagen/gdk_pixbuf2.rb
70
+ - lib/tagen/gtk2.rb
71
+ - lib/tagen/magick.rb
72
+ - lib/tagen/ncurses.rb
73
+ - lib/tagen/net/http.rb
74
+ - lib/tagen/pathname.rb
75
+ - lib/tagen/poppler.rb
76
+ - lib/tagen/socket.rb
77
+ - lib/tagen/tree.rb
78
+ - lib/tagen/vim.rb
79
+ - lib/tagen/xmpp4r.rb
80
+ - lib/tagen/xmpp4r/roster.rb
81
+ - spec/cairo_spec.rb
82
+ - spec/core/pa/cmd_spec.rb
83
+ - spec/core/pa/dir_spec.rb
84
+ - spec/core/string/pyformat_spec.rb
85
+ - spec/spec_helper.rb
86
+ - tagen.gemspec
87
+ - version.rb
88
+ has_rdoc: true
89
+ homepage: http://github.com/GutenLinux/tagen
90
+ licenses: []
91
+
92
+ post_install_message:
93
+ rdoc_options: []
94
+
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: "0"
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ none: false
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: "0"
109
+ requirements: []
110
+
111
+ rubyforge_project: xx
112
+ rubygems_version: 1.6.1
113
+ signing_key:
114
+ specification_version: 3
115
+ summary: a core and extra extension to ruby library
116
+ test_files: []
117
+