metric_tools 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/.rspec +1 -0
- data/.rvmrc +1 -0
- data/config/pref.rb +11 -16
- data/doc/Gemfile.html +107 -0
- data/doc/MetricTools/IndexTree.html +308 -0
- data/doc/MetricTools/S3.html +325 -0
- data/doc/MetricTools/Skype.html +343 -0
- data/doc/MetricTools/SpreadSheet.html +552 -0
- data/doc/MetricTools/Table.html +952 -0
- data/doc/MetricTools.html +158 -0
- data/doc/Object.html +179 -0
- data/doc/Pref/GoogleDocs.html +176 -0
- data/doc/Pref/S3.html +181 -0
- data/doc/Pref/Skype.html +156 -0
- data/doc/Pref.html +141 -0
- data/doc/created.rid +15 -0
- data/doc/images/add.png +0 -0
- data/doc/images/brick.png +0 -0
- data/doc/images/brick_link.png +0 -0
- data/doc/images/bug.png +0 -0
- data/doc/images/bullet_black.png +0 -0
- data/doc/images/bullet_toggle_minus.png +0 -0
- data/doc/images/bullet_toggle_plus.png +0 -0
- data/doc/images/date.png +0 -0
- data/doc/images/delete.png +0 -0
- data/doc/images/find.png +0 -0
- data/doc/images/loadingAnimation.gif +0 -0
- data/doc/images/macFFBgHack.png +0 -0
- data/doc/images/package.png +0 -0
- data/doc/images/page_green.png +0 -0
- data/doc/images/page_white_text.png +0 -0
- data/doc/images/page_white_width.png +0 -0
- data/doc/images/plugin.png +0 -0
- data/doc/images/ruby.png +0 -0
- data/doc/images/tag_blue.png +0 -0
- data/doc/images/tag_green.png +0 -0
- data/doc/images/transparent.png +0 -0
- data/doc/images/wrench.png +0 -0
- data/doc/images/wrench_orange.png +0 -0
- data/doc/images/zoom.png +0 -0
- data/doc/index.html +100 -0
- data/doc/js/darkfish.js +153 -0
- data/doc/js/jquery.js +18 -0
- data/doc/js/navigation.js +142 -0
- data/doc/js/search.js +94 -0
- data/doc/js/search_index.js +1 -0
- data/doc/js/searcher.js +228 -0
- data/doc/rdoc.css +543 -0
- data/doc/table_of_contents.html +176 -0
- data/lib/metric_tools/spread_sheet.rb +23 -1
- data/metric_tools.gemspec +13 -0
- data/spec/index_tree_spec.rb +101 -0
- data/spec/s3_spec.rb +80 -0
- data/spec/skype_spec.rb +39 -0
- data/spec/spread_sheet_spec.rb +165 -0
- data/spec/table_spec.rb +114 -0
- metadata +60 -6
- data/Gemfile.lock +0 -45
@@ -55,7 +55,29 @@ module MetricTools
|
|
55
55
|
|
56
56
|
@worksheet
|
57
57
|
end
|
58
|
-
|
58
|
+
|
59
|
+
#
|
60
|
+
# ワークシートの幅を返します
|
61
|
+
#
|
62
|
+
def width
|
63
|
+
max = 0
|
64
|
+
@worksheet.cells.each do |coord, val|
|
65
|
+
max = coord[1] if coord[1] >= max
|
66
|
+
end
|
67
|
+
max
|
68
|
+
end
|
69
|
+
|
70
|
+
#
|
71
|
+
# ワークシートの高さを返します
|
72
|
+
#
|
73
|
+
def height
|
74
|
+
max = 0
|
75
|
+
@worksheet.cells.each do |coord, val|
|
76
|
+
max = coord[0] if coord[0] >= max
|
77
|
+
end
|
78
|
+
max
|
79
|
+
end
|
80
|
+
|
59
81
|
# editing
|
60
82
|
|
61
83
|
#
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'rake'
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = 'metric_tools'
|
5
|
+
s.version = '0.0.9'
|
6
|
+
s.date = '2010-04-28'
|
7
|
+
s.summary = "Utilities for analyzing metrics"
|
8
|
+
s.description = "Utilities for analyzing metrics"
|
9
|
+
s.authors = ["Masaori Hirono"]
|
10
|
+
s.email = 'masaori@pankaku.com'
|
11
|
+
s.files = `git ls-files`.split($/)
|
12
|
+
s.homepage = 'https://github.com/masaori/metric_tools'
|
13
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
require 'metric_tools'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
describe MetricTools::IndexTree do
|
5
|
+
before do
|
6
|
+
@tree = MetricTools::IndexTree.new
|
7
|
+
end
|
8
|
+
|
9
|
+
describe '#new' do
|
10
|
+
context 'when no argument passed' do
|
11
|
+
it 'creates an empty tree' do
|
12
|
+
@tree = MetricTools::IndexTree.new
|
13
|
+
empty = {}
|
14
|
+
@tree.to_s.should eql empty.to_s
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'when source hash passed as an argument' do
|
19
|
+
it 'create a tree from given hash' do
|
20
|
+
source = {'a' => 'b', 'c' => {'d' => 'e'}}
|
21
|
+
@tree = MetricTools::IndexTree.new(source)
|
22
|
+
@tree.to_s.should eql source.to_s
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'when json string passed as an argument' do
|
27
|
+
it 'create a tree from given json string' do
|
28
|
+
json = '{"a" : "b", "c" : {"d" : "e"}}'
|
29
|
+
@tree = MetricTools::IndexTree.new(json)
|
30
|
+
@tree.to_s.should eql JSON.parse(json).to_s
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '#[]=' do
|
37
|
+
it 'sets value for for specified keys array' do
|
38
|
+
@tree['a', 'b', 'c', 'd'] = ['d', 'e']
|
39
|
+
|
40
|
+
compare = {
|
41
|
+
'a' => {
|
42
|
+
'b' => {
|
43
|
+
'c' => {
|
44
|
+
'd' => ['d', 'e']
|
45
|
+
}
|
46
|
+
}
|
47
|
+
}
|
48
|
+
}
|
49
|
+
@tree.to_s.should eql compare.to_s
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe '#[]' do
|
54
|
+
before do
|
55
|
+
@tree['a', 'b', 'c'] = 'result'
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'returns value for specified keys array' do
|
59
|
+
@tree['a', 'b', 'c'].should eql 'result'
|
60
|
+
@tree['not', 'existing', 'keys'].should be_nil
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe '#clear' do
|
65
|
+
before do
|
66
|
+
@tree['a', 'b', 'c'] = ['d', 'e']
|
67
|
+
@tree['e', 'f'] = 'g'
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'make hash empty' do
|
71
|
+
empty_hash = {}
|
72
|
+
|
73
|
+
@tree.clear
|
74
|
+
@tree.to_s.should eql empty_hash.to_s
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe '#to_json' do
|
79
|
+
before do
|
80
|
+
@tree['a', 'b', 'c'] = ['d', 'e']
|
81
|
+
@compare = {
|
82
|
+
'a' => {
|
83
|
+
'b' => {
|
84
|
+
'c' => ['d', 'e']
|
85
|
+
}
|
86
|
+
}
|
87
|
+
}
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'returns represented json string of tree' do
|
91
|
+
@tree.to_json.should eql JSON.generate(@compare)
|
92
|
+
end
|
93
|
+
|
94
|
+
context "when 'pretty: true' specified" do
|
95
|
+
it 'returns represented (pretty formatted) json string of tree' do
|
96
|
+
@tree.to_json(pretty: true).should eql JSON.pretty_generate(@compare)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
data/spec/s3_spec.rb
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'metric_tools'
|
2
|
+
require 'aws/s3'
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
describe MetricTools::S3 do
|
6
|
+
before(:all) do
|
7
|
+
@key = Pref::S3::TEST_ACCESS_KEY
|
8
|
+
@secret = Pref::S3::TEST_SECRET_KEY
|
9
|
+
@bucket_name = Pref::S3::TEST_BUCKET_NAME
|
10
|
+
|
11
|
+
MetricTools::S3.login(@key, @secret, @bucket_name)
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#download' do
|
15
|
+
before do
|
16
|
+
@file_key = Pref::S3::TEST_FILE_KEY
|
17
|
+
@dir = Pref::S3::TEST_LOCAL_DIRECTORY
|
18
|
+
@file_path = File.join(@dir, File.basename(@file_key))
|
19
|
+
|
20
|
+
raise 'Pref::S3::TEST_LOCAL_DIRECTORY has not set yet.' if @dir.nil? || @dir.empty?
|
21
|
+
|
22
|
+
File.delete(@file_path) if File.exists?(@file_path)
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'when hierarchy is set true' do
|
26
|
+
it 'downloads specified file to target dir saving directory hierarchy on S3-bucket' do
|
27
|
+
MetricTools::S3.download(@file_key, @dir, true)
|
28
|
+
|
29
|
+
File.exists?(File.join(@dir, @file_key)).should be_true
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'when hierarchy is set false' do
|
34
|
+
it 'downloads specified file to target dir' do
|
35
|
+
MetricTools::S3.download(@file_key, @dir)
|
36
|
+
|
37
|
+
File.exists?(@file_path).should be_true
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#fetch_all' do
|
43
|
+
before do
|
44
|
+
@dir = Pref::S3::TEST_LOCAL_DIRECTORY
|
45
|
+
@dir_key = Pref::S3::TEST_DIR_KEY
|
46
|
+
|
47
|
+
@bucket = AWS::S3::Service.buckets.find{|b| b.name == @bucket_name}
|
48
|
+
@file_names = @bucket
|
49
|
+
.select{|obj| (obj.key[obj.key.length-1]!='/') && (obj.key.include? @dir_key) }
|
50
|
+
.collect{|obj| obj.key}
|
51
|
+
@file_names.each{|name|
|
52
|
+
file_path = File.join(@dir, name)
|
53
|
+
File.delete(file_path) if File.exists?(file_path)
|
54
|
+
}
|
55
|
+
end
|
56
|
+
|
57
|
+
context 'when no additional condition passed' do
|
58
|
+
it "downloads all files which have not been downloaded in 'dir_key'" do
|
59
|
+
MetricTools::S3.fetch_all(@dir_key, @dir)
|
60
|
+
|
61
|
+
@file_names.each{|name|
|
62
|
+
file_path = File.join(@dir, name)
|
63
|
+
File.exists?(file_path).should be_true
|
64
|
+
}
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'when an additional condition passed' do
|
69
|
+
it "downloads files which have not been downloaded and match given condition" do
|
70
|
+
MetricTools::S3.fetch_all(@dir_key, @dir) {|obj| obj.key.include?("8")}
|
71
|
+
|
72
|
+
@file_names.each{|name|
|
73
|
+
file_path = File.join(@dir, name)
|
74
|
+
File.exists?(file_path).should (name.include?("8") ? be_true : be_false)
|
75
|
+
}
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
end
|
data/spec/skype_spec.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'metric_tools'
|
4
|
+
|
5
|
+
include MetricTools
|
6
|
+
|
7
|
+
describe MetricTools::Skype do
|
8
|
+
before do
|
9
|
+
Skype.logout
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#login_chat' do
|
13
|
+
context 'when specified existing room name' do
|
14
|
+
it 'login chat room has specified friendly name' do
|
15
|
+
Skype.login_chat(Pref::Skype::TEST_CHAT_ROOM)
|
16
|
+
|
17
|
+
Skype.current_chat_id.should_not be_nil
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'when specified not existing room name' do
|
22
|
+
it 'login chat room has specified friendly name' do
|
23
|
+
proc { Skype.login_chat("そんな部屋はない") }.should raise_error(RuntimeError, 'not existing chat room : そんな部屋はない')
|
24
|
+
Skype.current_chat_id.should be_nil
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '#post' do
|
30
|
+
before do
|
31
|
+
Skype.login_chat(Pref::Skype::TEST_CHAT_ROOM)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "post a message to specified id's chat" do
|
35
|
+
Skype.post("テストです。" + DateTime.now.to_s)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,165 @@
|
|
1
|
+
require 'metric_tools'
|
2
|
+
|
3
|
+
include MetricTools
|
4
|
+
|
5
|
+
describe MetricTools::SpreadSheet do
|
6
|
+
before(:all) do
|
7
|
+
@test_mail = Pref::GoogleDocs::TEST_MAIL
|
8
|
+
@test_pass = Pref::GoogleDocs::TEST_PASSWORD
|
9
|
+
@mail = Pref::GoogleDocs::ANOTHER_MAIL
|
10
|
+
@password = Pref::GoogleDocs::ANOTHER_PASSWORD
|
11
|
+
@key = Pref::GoogleDocs::TEST_KEY
|
12
|
+
@sheet_name = 'test_sheet'
|
13
|
+
|
14
|
+
raise 'Pref::GoogleDocs::TEST_MAIL has not set yet.' if @test_mail.nil? || @test_mail.empty?
|
15
|
+
|
16
|
+
@session = GoogleDrive.login(@test_mail, @test_pass)
|
17
|
+
@sheet = @session.spreadsheet_by_key(@key)
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'when not login yet' do
|
21
|
+
|
22
|
+
describe '#login' do
|
23
|
+
it 'receive mail and password then try login to google analytics' do
|
24
|
+
SpreadSheet.login(@mail, @password, @key)
|
25
|
+
|
26
|
+
SpreadSheet.login?.should be_true
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'when logged in already' do
|
33
|
+
|
34
|
+
before(:all) do
|
35
|
+
SpreadSheet.login(@mail, @password, @key)
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '#current_worksheet_title' do
|
39
|
+
context 'when no worksheet selected' do
|
40
|
+
it 'returns nil' do
|
41
|
+
SpreadSheet.current_worksheet_title.should be_nil
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'when worksheet selected' do
|
46
|
+
it 'returns worksheet name' do
|
47
|
+
SpreadSheet.change_worksheet_by_title('aaaaa')
|
48
|
+
SpreadSheet.current_worksheet_title.should eql 'aaaaa'
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe '#change_worksheet_by_title' do
|
54
|
+
it 'selects or creates specified worksheet' do
|
55
|
+
SpreadSheet.change_worksheet_by_title(@sheet_name)
|
56
|
+
|
57
|
+
SpreadSheet.current_worksheet_title.should eql @sheet_name
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
context 'when worksheet selected already' do
|
62
|
+
before(:all) do
|
63
|
+
@worksheet = @sheet.worksheet_by_title(@sheet_name)
|
64
|
+
@worksheet = @sheet.add_worksheet(@sheet_name) if @worksheet.nil?
|
65
|
+
@worksheet.cells.each{|k, v| @worksheet[k[0], k[1]] = ''}
|
66
|
+
@worksheet.synchronize
|
67
|
+
end
|
68
|
+
|
69
|
+
describe '#[]' do
|
70
|
+
before do
|
71
|
+
@worksheet[6, 7] = 'testtest'
|
72
|
+
@worksheet.synchronize
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'returns a value in the specified cell' do
|
76
|
+
SpreadSheet.save
|
77
|
+
SpreadSheet[5, 6].should eql 'testtest'
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe '#[]=' do
|
82
|
+
it 'set a value to the specified cell' do
|
83
|
+
SpreadSheet[10, 11] = 'test_test_test'
|
84
|
+
SpreadSheet.save
|
85
|
+
|
86
|
+
@worksheet.synchronize
|
87
|
+
@worksheet[11, 12].should eql 'test_test_test'
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe '#width' do
|
92
|
+
it 'returns width of worksheet' do
|
93
|
+
SpreadSheet[10, 11] = 'test_test_test'
|
94
|
+
SpreadSheet.save
|
95
|
+
|
96
|
+
SpreadSheet.width.should eql 12
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe '#height' do
|
101
|
+
it 'returns height of worksheet' do
|
102
|
+
SpreadSheet[10, 11] = 'test_test_test'
|
103
|
+
SpreadSheet.save
|
104
|
+
|
105
|
+
SpreadSheet.height.should eql 11
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
describe '#set_value_table' do
|
110
|
+
it 'set velues from Table instance' do
|
111
|
+
table = MetricTools::Table.create(2, 3){|i, j| (i+19)*j}
|
112
|
+
|
113
|
+
SpreadSheet.set_value_table(table)
|
114
|
+
SpreadSheet.save
|
115
|
+
|
116
|
+
@worksheet.synchronize
|
117
|
+
for i in 0...2
|
118
|
+
for j in 0...3
|
119
|
+
@worksheet[i+1, j+1].should eql ((i+19)*j).to_s
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
context 'when pass not Table object' do
|
125
|
+
it 'raises exception' do
|
126
|
+
proc { SpreadSheet.set_value_table([[470, 3965], [49, 198]]) }.should raise_error(RuntimeError, 'can receive Table class only')
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|
132
|
+
|
133
|
+
context "when worksheet isn't selected yet" do
|
134
|
+
before do
|
135
|
+
SpreadSheet.logout
|
136
|
+
end
|
137
|
+
|
138
|
+
describe '#[]' do
|
139
|
+
it 'raises exception' do
|
140
|
+
proc { SpreadSheet[0, 0] }.should raise_error( RuntimeError, "call 'change_worksheet_by_title' before." )
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
describe '#[]=' do
|
145
|
+
it 'raises exception' do
|
146
|
+
proc { SpreadSheet[0, 0]='a' }.should raise_error( RuntimeError, "call 'change_worksheet_by_title' before." )
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
describe 'save' do
|
151
|
+
it 'raises exception' do
|
152
|
+
proc { SpreadSheet.save }.should raise_error( RuntimeError, "call 'change_worksheet_by_title' before." )
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
describe '#set_value_table' do
|
157
|
+
it 'raises exception' do
|
158
|
+
proc { SpreadSheet.set_value_table({}) }.should raise_error( RuntimeError, "call 'change_worksheet_by_title' before." )
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
end
|
164
|
+
|
165
|
+
end
|
data/spec/table_spec.rb
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
require 'metric_tools'
|
2
|
+
|
3
|
+
describe MetricTools::Table do
|
4
|
+
|
5
|
+
describe '#create' do
|
6
|
+
|
7
|
+
it 'creates new table which has specified size and data.' do
|
8
|
+
new_one = MetricTools::Table.create(5, 7){|i, j| i*j}
|
9
|
+
|
10
|
+
new_one.should_not be_nil
|
11
|
+
for i in 0...5
|
12
|
+
for j in 0...7
|
13
|
+
new_one[i, j].should eql i*j
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#create_with_array' do
|
21
|
+
|
22
|
+
it 'creates new table with represented array(2-dimentions).' do
|
23
|
+
array = [
|
24
|
+
[1, 2, 3, 4],
|
25
|
+
[5, 6, 7, 8],
|
26
|
+
[9, 10, 11, 12],
|
27
|
+
[13, 14, 15, 16],
|
28
|
+
[17, 18, 19, 20],
|
29
|
+
]
|
30
|
+
|
31
|
+
new_one = MetricTools::Table.create_with_array(array)
|
32
|
+
|
33
|
+
new_one.should_not be_nil
|
34
|
+
for i in 0...4
|
35
|
+
for j in 0...5
|
36
|
+
new_one[i, j].should eql array[j][i]
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#[]=' do
|
44
|
+
|
45
|
+
it 'assigns object to specified index.' do
|
46
|
+
new_one = MetricTools::Table.create(3, 4){|i, j| 0}
|
47
|
+
|
48
|
+
new_one[1, 2] = 1
|
49
|
+
|
50
|
+
for i in 0...3
|
51
|
+
for j in 0...4
|
52
|
+
new_one[i, j].should eql (i == 1 && j == 2) ? 1 : 0
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
describe '#width' do
|
61
|
+
|
62
|
+
it 'returns width of table.' do
|
63
|
+
new_one = MetricTools::Table.create(3, 4){|i, j| 0}
|
64
|
+
new_one.width.should eql 4
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
describe '#height' do
|
70
|
+
|
71
|
+
it 'returns height of table.' do
|
72
|
+
new_one = MetricTools::Table.create(3, 4){|i, j| 0}
|
73
|
+
new_one.height.should eql 3
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
describe '#header' do
|
79
|
+
|
80
|
+
it 'returns first row as array.' do
|
81
|
+
new_one = MetricTools::Table.create(3, 4){|i, j| i+j}
|
82
|
+
new_one.header.should eql [0, 1, 2, 3]
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
describe '#to_obj' do
|
88
|
+
|
89
|
+
it 'returns array of hash with keys created from #header.' do
|
90
|
+
new_one = MetricTools::Table.create(3, 4){|i, j| i+j}
|
91
|
+
new_one.to_obj.should eql [
|
92
|
+
{0 => 1, 1 => 2, 2 => 3, 3 => 4},
|
93
|
+
{0 => 2, 1 => 3, 2 => 4, 3 => 5},
|
94
|
+
]
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
describe '#collect' do
|
100
|
+
|
101
|
+
it 'creates another table by return values in given block. The new one will have same size.' do
|
102
|
+
source = MetricTools::Table.create(3, 4){|i, j| i*j }
|
103
|
+
new_one = source.collect{|src, i, j| src%2}
|
104
|
+
|
105
|
+
new_one.width.should eql source.width
|
106
|
+
new_one.height.should eql source.height
|
107
|
+
new_one.each_with_index{|val, i, j|
|
108
|
+
val.should eql (i*j)%2
|
109
|
+
}
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metric_tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -17,17 +17,71 @@ executables: []
|
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
+
- .gitignore
|
21
|
+
- .rspec
|
22
|
+
- .rvmrc
|
20
23
|
- Gemfile
|
24
|
+
- README.md
|
25
|
+
- config/pref.rb
|
26
|
+
- doc/Gemfile.html
|
27
|
+
- doc/MetricTools.html
|
28
|
+
- doc/MetricTools/IndexTree.html
|
29
|
+
- doc/MetricTools/S3.html
|
30
|
+
- doc/MetricTools/Skype.html
|
31
|
+
- doc/MetricTools/SpreadSheet.html
|
32
|
+
- doc/MetricTools/Table.html
|
33
|
+
- doc/Object.html
|
34
|
+
- doc/Pref.html
|
35
|
+
- doc/Pref/GoogleDocs.html
|
36
|
+
- doc/Pref/S3.html
|
37
|
+
- doc/Pref/Skype.html
|
38
|
+
- doc/created.rid
|
39
|
+
- doc/images/add.png
|
40
|
+
- doc/images/brick.png
|
41
|
+
- doc/images/brick_link.png
|
42
|
+
- doc/images/bug.png
|
43
|
+
- doc/images/bullet_black.png
|
44
|
+
- doc/images/bullet_toggle_minus.png
|
45
|
+
- doc/images/bullet_toggle_plus.png
|
46
|
+
- doc/images/date.png
|
47
|
+
- doc/images/delete.png
|
48
|
+
- doc/images/find.png
|
49
|
+
- doc/images/loadingAnimation.gif
|
50
|
+
- doc/images/macFFBgHack.png
|
51
|
+
- doc/images/package.png
|
52
|
+
- doc/images/page_green.png
|
53
|
+
- doc/images/page_white_text.png
|
54
|
+
- doc/images/page_white_width.png
|
55
|
+
- doc/images/plugin.png
|
56
|
+
- doc/images/ruby.png
|
57
|
+
- doc/images/tag_blue.png
|
58
|
+
- doc/images/tag_green.png
|
59
|
+
- doc/images/transparent.png
|
60
|
+
- doc/images/wrench.png
|
61
|
+
- doc/images/wrench_orange.png
|
62
|
+
- doc/images/zoom.png
|
63
|
+
- doc/index.html
|
64
|
+
- doc/js/darkfish.js
|
65
|
+
- doc/js/jquery.js
|
66
|
+
- doc/js/navigation.js
|
67
|
+
- doc/js/search.js
|
68
|
+
- doc/js/search_index.js
|
69
|
+
- doc/js/searcher.js
|
70
|
+
- doc/rdoc.css
|
71
|
+
- doc/table_of_contents.html
|
72
|
+
- lib/metric_tools.rb
|
21
73
|
- lib/metric_tools/index_tree.rb
|
22
74
|
- lib/metric_tools/s3.rb
|
23
75
|
- lib/metric_tools/skype.rb
|
24
76
|
- lib/metric_tools/spread_sheet.rb
|
25
77
|
- lib/metric_tools/table.rb
|
26
|
-
-
|
27
|
-
-
|
28
|
-
-
|
29
|
-
-
|
30
|
-
|
78
|
+
- metric_tools.gemspec
|
79
|
+
- spec/index_tree_spec.rb
|
80
|
+
- spec/s3_spec.rb
|
81
|
+
- spec/skype_spec.rb
|
82
|
+
- spec/spread_sheet_spec.rb
|
83
|
+
- spec/table_spec.rb
|
84
|
+
homepage: https://github.com/masaori/metric_tools
|
31
85
|
licenses: []
|
32
86
|
post_install_message:
|
33
87
|
rdoc_options: []
|
data/Gemfile.lock
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: http://rubygems.org/
|
3
|
-
specs:
|
4
|
-
aws-s3 (0.6.3)
|
5
|
-
builder
|
6
|
-
mime-types
|
7
|
-
xml-simple
|
8
|
-
builder (3.2.0)
|
9
|
-
faraday (0.8.6)
|
10
|
-
multipart-post (~> 1.1)
|
11
|
-
google_drive (0.3.4)
|
12
|
-
nokogiri (>= 1.4.4, != 1.5.2, != 1.5.1)
|
13
|
-
oauth (>= 0.3.6)
|
14
|
-
oauth2 (>= 0.5.0)
|
15
|
-
hirb (0.7.1)
|
16
|
-
httpauth (0.2.0)
|
17
|
-
jwt (0.1.8)
|
18
|
-
multi_json (>= 1.5)
|
19
|
-
mime-types (1.21)
|
20
|
-
multi_json (1.7.1)
|
21
|
-
multi_xml (0.5.3)
|
22
|
-
multipart-post (1.2.0)
|
23
|
-
nokogiri (1.5.8)
|
24
|
-
oauth (0.4.7)
|
25
|
-
oauth2 (0.9.1)
|
26
|
-
faraday (~> 0.8)
|
27
|
-
httpauth (~> 0.1)
|
28
|
-
jwt (~> 0.1.4)
|
29
|
-
multi_json (~> 1.0)
|
30
|
-
multi_xml (~> 0.5)
|
31
|
-
rack (~> 1.2)
|
32
|
-
rack (1.5.2)
|
33
|
-
rb-appscript (0.6.1)
|
34
|
-
rb-skypemac (0.3.2)
|
35
|
-
rb-appscript (>= 0.3.0)
|
36
|
-
xml-simple (1.1.2)
|
37
|
-
|
38
|
-
PLATFORMS
|
39
|
-
ruby
|
40
|
-
|
41
|
-
DEPENDENCIES
|
42
|
-
aws-s3 (~> 0)
|
43
|
-
google_drive (~> 0)
|
44
|
-
hirb (~> 0)
|
45
|
-
rb-skypemac (~> 0)
|