gr8 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,12 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ ###
4
+ ### $Release: 0.1.0 $
5
+ ### $Copyright: copyright(c) 2015 kuwata-lab.com all rights reserved $
6
+ ### $License: MIT License $
7
+ ###
8
+
9
+ require_relative "common.rb"
10
+ Dir.glob(File.join(File.dirname(__FILE__), "*_test.rb")).each do |fpath|
11
+ require_relative File.basename(fpath)
12
+ end
@@ -0,0 +1,114 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ ###
4
+ ### $Release: 0.1.0 $
5
+ ### $Copyright: copyright(c) 2015 kuwata-lab.com all rights reserved $
6
+ ### $License: MIT License $
7
+ ###
8
+
9
+ require_relative "common"
10
+ require "oktest"
11
+
12
+
13
+
14
+ Oktest.scope do
15
+
16
+
17
+ topic Kernel do
18
+
19
+ topic 'fu()' do
20
+
21
+ spec "[!ktccp] returns FileUtils class object." do
22
+ ok {fu} == FileUtils
23
+ end
24
+
25
+ end
26
+
27
+ end
28
+
29
+
30
+ topic String do
31
+
32
+
33
+ topic '#q()' do
34
+
35
+ spec "[!ejo5y] quotes string with single-quoation." do
36
+ ok {"hom".q} == "'hom'"
37
+ end
38
+
39
+ spec "[!ageyj] escapes single-quotation characters." do
40
+ ok {"'hom'".q} == "'\\'hom\\''"
41
+ end
42
+
43
+ end
44
+
45
+
46
+ topic '#qq()' do
47
+
48
+ spec "[!wwvll] quotes string with double-quotation." do
49
+ ok {'hom'.qq} == '"hom"'
50
+ end
51
+
52
+ spec "[!rc66j] escapes double-quotation characters." do
53
+ ok {'"hom"'.qq} == '"\"hom\""'
54
+ end
55
+
56
+ end
57
+
58
+
59
+ end
60
+
61
+
62
+ topic Object do
63
+
64
+ topic '_' do
65
+
66
+ spec "[!wvemx] returns self object." do
67
+ s = "hom"
68
+ ok {s}.same?(s)
69
+ ok {s}.NOT.same?(s+"")
70
+ end
71
+
72
+ end
73
+
74
+ end
75
+
76
+
77
+ topic Gr8::EnumWrapper do
78
+
79
+
80
+ topic '#each()' do
81
+
82
+ spec "[!hloy1] splits each line into array." do
83
+ enum = ["A:10:x", "B:20:y", "C:30:z"]
84
+ wrapper = Gr8::EnumWrapper.new(enum, /:/)
85
+ ok {wrapper.map {|x| x }} == [["A","10","x"], ["B","20","y"], ["C","30","z"]]
86
+ #
87
+ enum = ["A 10 x", " B 20 y", "C\t30\tz"]
88
+ wrapper = Gr8::EnumWrapper.new(enum)
89
+ ok {wrapper.map {|x| x }} == [["A","10","x"], ["B","20","y"], ["C","30","z"]]
90
+ end
91
+
92
+ spec "[!c22km] chomps each lin before splitting." do
93
+ enum = ["A:100\n", "B:200\n", "C:300\n"]
94
+ wrapper = Gr8::EnumWrapper.new(enum, /:/)
95
+ ok {wrapper.map {|x| x }} == [["A", "100"], ["B", "200"], ["C", "300"]]
96
+ #
97
+ enum = ["A 10 x\n", " B 20 y\n", "C\t30\tz\n"]
98
+ wrapper = Gr8::EnumWrapper.new(enum)
99
+ ok {wrapper.map {|x| x }} == [["A","10","x"], ["B","20","y"], ["C","30","z"]]
100
+ end
101
+
102
+ spec "[!m411f] selects column when column number specified." do
103
+ enum = ["A 10 x\n", " B 20 y\n", "C\t30\tz\n"]
104
+ wrapper = Gr8::EnumWrapper.new(enum, nil, 2)
105
+ ok {wrapper.map {|x| x }} == ["10", "20", "30"]
106
+ end
107
+
108
+ end
109
+
110
+
111
+ end
112
+
113
+
114
+ end
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gr8
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - makoto kuwata
8
+ autorequire:
9
+ bindir:
10
+ - bin
11
+ cert_chain: []
12
+ date: 2015-08-17 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: oktest
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ description: |
29
+ gr8 is a great command-line utility powered by Ruby.
30
+
31
+ Example:
32
+
33
+ $ cat data
34
+ Haruhi 100
35
+ Mikuru 80
36
+ Yuki 120
37
+ $ cat data | gr8s 'map{|s|s.split()[1]}'
38
+ 100
39
+ 80
40
+ 120
41
+ $ cat data | gr8s 'map{|s|s.split()[1]}.map(&:to_i).sum'
42
+ 300
43
+ $ cat data | gr8s 'map{split[1]}.sum_i'
44
+ 300
45
+ $ cat data | gr8s -F 'map{self[1]}.sum_i'
46
+ 300
47
+ $ cat data | gr8s -C2 'sum_i'
48
+ 300
49
+
50
+ See http://kwatch.github.io/gr8/ for detail.
51
+ email: kwa(at)kuwata-lab.com
52
+ executables:
53
+ - gr8
54
+ extensions: []
55
+ extra_rdoc_files: []
56
+ files:
57
+ - MIT-LICENSE
58
+ - README.md
59
+ - Rakefile
60
+ - bin/gr8
61
+ - gr8.gemspec
62
+ - setup.rb
63
+ - test/app_test.rb
64
+ - test/common.rb
65
+ - test/enum_test.rb
66
+ - test/test_all.rb
67
+ - test/util_test.rb
68
+ homepage: http://kwatch.github.io/gr8/
69
+ licenses:
70
+ - MIT Lisense
71
+ metadata: {}
72
+ post_install_message:
73
+ rdoc_options: []
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '2.0'
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ requirements: []
87
+ rubyforge_project:
88
+ rubygems_version: 2.4.5
89
+ signing_key:
90
+ specification_version: 4
91
+ summary: Great command-line utility powered by Ruby
92
+ test_files:
93
+ - test/test_all.rb