exceler 0.9.1
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.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +42 -0
- data/Rakefile +2 -0
- data/exceler.gemspec +24 -0
- data/lib/exceler/version.rb +3 -0
- data/lib/exceler.rb +259 -0
- metadata +94 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3aadae848b603aa554e9688a24498cafa635cc7d
|
4
|
+
data.tar.gz: d96007cd7fb7228d43d5e8a58abd5e7a999ae986
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 67665a58659cf2c7c4fd2c497241afe4bac92ff167e6f017ae28a905914574157e0f74fb667669b3a88775be91b3c88f5af81d4acd5ede2c1acda903e84cd30b
|
7
|
+
data.tar.gz: 1cf1b392019e7a998f11c861b53475a6b36d79f126fda969ee7d86ff6727803ee6b142593d0738da43e3d474bed269b9f2af96f2fa557676f32478a1cc1b8166
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 kitfactory
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# Exceler
|
2
|
+
|
3
|
+
Excel document parser for project metrics.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
$ gem install exceler
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
```
|
12
|
+
require 'exceler'
|
13
|
+
|
14
|
+
# Example1 F列が埋まっていれば済とみなす例
|
15
|
+
|
16
|
+
list = Exceler.list_files( "test1" )
|
17
|
+
so = ScanOption.new( 0 , "A" , "B" , "D" , "E" , "F" , nil )
|
18
|
+
items = Exceler.scan_items( list ,so )
|
19
|
+
|
20
|
+
# Example2 F列が済となっていれば済とみなす例
|
21
|
+
|
22
|
+
list = Exceler.list_files( "test2" )
|
23
|
+
so = ScanOption.new( 2 , "A" , "B" , "D" , "E" , "F" , "済" )
|
24
|
+
items = Exceler.scan_items( list ,so )
|
25
|
+
assigned_items = Exceler.pickup_assigned( items , "山田")
|
26
|
+
incomplete_items = Exceler.pickup_incomplete( items )
|
27
|
+
expiration_items = Exceler.pickup_expiration( items )
|
28
|
+
|
29
|
+
puts "Total items:" + items.length.to_s
|
30
|
+
puts "Yamda assgined items :" + assigned_items.length.to_s
|
31
|
+
puts "Incomplete items :" + incomplete_items.length.to_s
|
32
|
+
puts "Expiration items :" + expiration_items.length.to_s
|
33
|
+
|
34
|
+
```
|
35
|
+
|
36
|
+
## Contributing
|
37
|
+
|
38
|
+
1. Fork it ( https://github.com/kitfactory/exceler/fork )
|
39
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
40
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
41
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
42
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/exceler.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'exceler/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "exceler"
|
8
|
+
spec.version = Exceler::VERSION
|
9
|
+
spec.authors = ["kitfactory"]
|
10
|
+
spec.email = ["kitfactory@gmail.com"]
|
11
|
+
spec.summary = %q{Excel document parser for project metrics.}
|
12
|
+
spec.description = %q{check homepage.}
|
13
|
+
spec.homepage = "https://github.com/kitfactory/exceler"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_dependency "roo"
|
24
|
+
end
|
data/lib/exceler.rb
ADDED
@@ -0,0 +1,259 @@
|
|
1
|
+
require "exceler/version"
|
2
|
+
|
3
|
+
module Exceler
|
4
|
+
def hello
|
5
|
+
puts "hello"
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.hello2
|
9
|
+
puts "helo2"
|
10
|
+
end
|
11
|
+
|
12
|
+
class Foo
|
13
|
+
def self.bar
|
14
|
+
puts "bar"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
#
|
19
|
+
# ScanOption
|
20
|
+
# アイテムを取得する際のオプション
|
21
|
+
#
|
22
|
+
class ScanOption
|
23
|
+
|
24
|
+
#
|
25
|
+
# new
|
26
|
+
#
|
27
|
+
# ==== Args
|
28
|
+
# header :: ヘッダー行(スキップする行数)
|
29
|
+
# id_row :: アイテムの存在を確認する列
|
30
|
+
# assign_row :: 担当者の列
|
31
|
+
# start_row :: 開始日の列
|
32
|
+
# limit_row :: 期限の列
|
33
|
+
# state_row :: ステータスの列
|
34
|
+
# state_condition :: 合致で済とする場合は合致の文字列、埋まっていることで済とする場合はnil
|
35
|
+
#
|
36
|
+
def initialize( header , id_row , assign_row , start_row , limit_row , state_row, state_condition )
|
37
|
+
@header = header # ヘッダー行(スキップする行数)
|
38
|
+
@id_row = id_row # アイテムの存在を確認する列
|
39
|
+
@assign_row = assign_row # 担当者の列
|
40
|
+
@start_row = start_row # 開始日の列
|
41
|
+
@limit_row = limit_row # 期限の列
|
42
|
+
@state_row = state_row # ステータスの列
|
43
|
+
@state_condition = state_condition
|
44
|
+
end
|
45
|
+
|
46
|
+
attr_reader :header
|
47
|
+
attr_reader :id_row
|
48
|
+
attr_reader :assign_row
|
49
|
+
attr_reader :start_row
|
50
|
+
attr_reader :limit_row
|
51
|
+
attr_reader :state_row
|
52
|
+
attr_reader :state_condition
|
53
|
+
end
|
54
|
+
|
55
|
+
#
|
56
|
+
# 実施状況を確認するアイテム
|
57
|
+
#
|
58
|
+
class Item
|
59
|
+
COMPLETE = 1
|
60
|
+
INCOMPLETE = 2
|
61
|
+
|
62
|
+
def initialize
|
63
|
+
@content = nil
|
64
|
+
@state = INCOMPLETE
|
65
|
+
@assign = nil
|
66
|
+
@start = nil
|
67
|
+
@limit = nil
|
68
|
+
end
|
69
|
+
|
70
|
+
attr_accessor :content
|
71
|
+
attr_accessor :state
|
72
|
+
attr_accessor :assign
|
73
|
+
attr_accessor :start
|
74
|
+
attr_accessor :limit
|
75
|
+
end
|
76
|
+
|
77
|
+
XLS = "xls"
|
78
|
+
XLSX = "xlsx"
|
79
|
+
EXT_PATTERNS = [ XLS , XLSX ];
|
80
|
+
|
81
|
+
# 指定されたディレクトリからファイル(.xls,.xlsx)を取得します
|
82
|
+
# find Excel files from the specified directory
|
83
|
+
# ==== Args
|
84
|
+
# dir :: エクセルファイルを検索するディレクトリ
|
85
|
+
# ==== Return
|
86
|
+
# エクセルファイルの名前の配列
|
87
|
+
def self.list_files( dir )
|
88
|
+
ret = [];
|
89
|
+
for ext in EXT_PATTERNS
|
90
|
+
filepattern = dir+File::SEPARATOR+"*."+ext;
|
91
|
+
Dir[filepattern].each do |file|
|
92
|
+
puts "founds " + file
|
93
|
+
ret.push( file )
|
94
|
+
end
|
95
|
+
end
|
96
|
+
return ret
|
97
|
+
end
|
98
|
+
|
99
|
+
#
|
100
|
+
#
|
101
|
+
#
|
102
|
+
def self.show_item( item )
|
103
|
+
s = ""
|
104
|
+
if( item.assign != nil )
|
105
|
+
s += ("assign:" + item.assign + "," )
|
106
|
+
end
|
107
|
+
if( item.start != nil )
|
108
|
+
s += ( "start:" + item.start.strftime("%Y/%m/%d") + "," )
|
109
|
+
end
|
110
|
+
if( item.limit != nil )
|
111
|
+
s += ( "limit:" + item.limit.strftime("%Y/%m/%d") + "," )
|
112
|
+
end
|
113
|
+
if( item.state != nil )
|
114
|
+
if( item.state == Item::COMPLETE )
|
115
|
+
s += ( "state: complete ")
|
116
|
+
else
|
117
|
+
s += "state: incomplete"
|
118
|
+
end
|
119
|
+
end
|
120
|
+
puts s
|
121
|
+
end
|
122
|
+
|
123
|
+
#
|
124
|
+
# オプションにしたがってファイルを解析し、アイテムを返却します。
|
125
|
+
# scan the items with specified option from the files
|
126
|
+
#
|
127
|
+
# ==== Args
|
128
|
+
# files :: エクセルファイルの配列
|
129
|
+
# opt :: 検索時のオプション、ScanOptionオブジェクト
|
130
|
+
# ==== Return
|
131
|
+
# アイテムの配列
|
132
|
+
def self.scan_items( files , opt)
|
133
|
+
ret = []
|
134
|
+
if( opt == nil )
|
135
|
+
return nil
|
136
|
+
end
|
137
|
+
for file in files
|
138
|
+
puts file
|
139
|
+
re = Regexp.new( XLS+"$" )
|
140
|
+
if( file =~ re ) # XLS file
|
141
|
+
puts "XLS file scan " + file
|
142
|
+
s = Roo::Excel.new(file)
|
143
|
+
else #XLSX file
|
144
|
+
puts "XLSX file scan"+file
|
145
|
+
s = Roo::Excelx.new(file)
|
146
|
+
end
|
147
|
+
|
148
|
+
for sheet in s.sheets
|
149
|
+
s.default_sheet = sheet
|
150
|
+
if( s.first_row == nil )
|
151
|
+
next
|
152
|
+
else
|
153
|
+
header = s.first_row
|
154
|
+
end
|
155
|
+
if( opt.header >= header )
|
156
|
+
header = opt.header
|
157
|
+
end
|
158
|
+
(header..s.last_row).each do |num|
|
159
|
+
c = s.cell( opt.id_row , num )
|
160
|
+
if( c != nil )
|
161
|
+
i = Item.new
|
162
|
+
if( opt.assign_row != nil )
|
163
|
+
i.assign = s.cell( opt.assign_row , num )
|
164
|
+
end
|
165
|
+
if( opt.start_row != nil )
|
166
|
+
i.start = s.cell( opt.start_row , num )
|
167
|
+
end
|
168
|
+
if( opt.limit_row != nil )
|
169
|
+
i.limit = s.cell( opt.limit_row , num )
|
170
|
+
end
|
171
|
+
if( opt.state_row != nil )
|
172
|
+
puts opt.state_row
|
173
|
+
if( opt.state_condition == nil )
|
174
|
+
if( s.cell( opt.state_row , num ) != nil )
|
175
|
+
i.state = Item::COMPLETE
|
176
|
+
else
|
177
|
+
i.state = Item::INCOMPLETE
|
178
|
+
end
|
179
|
+
else
|
180
|
+
if( s.cell( opt.state_row ,num ) == opt.state_condition )
|
181
|
+
i.state = Item::COMPLETE
|
182
|
+
else
|
183
|
+
i.state = Item::INCOMPLETE
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
show_item( i )
|
188
|
+
ret.push( i )
|
189
|
+
else
|
190
|
+
puts "skip!!"
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
195
|
+
return ret
|
196
|
+
end
|
197
|
+
|
198
|
+
|
199
|
+
#
|
200
|
+
# 渡されたアイテムのうち、特定の人に割り当てられたアイテムをピックアップします。
|
201
|
+
# pickup specified person assigned items from the specified items
|
202
|
+
#
|
203
|
+
# ==== Args
|
204
|
+
# items :: アイテムの配列
|
205
|
+
# assign :: 担当
|
206
|
+
# ==== Return
|
207
|
+
# 担当に割あたっているアイテムの配列
|
208
|
+
#
|
209
|
+
def self.pickup_assigned( items , assign )
|
210
|
+
ret = []
|
211
|
+
for item in items
|
212
|
+
if( item.assign == assign )
|
213
|
+
ret.push( item )
|
214
|
+
end
|
215
|
+
end
|
216
|
+
return ret
|
217
|
+
end
|
218
|
+
|
219
|
+
#
|
220
|
+
# 渡されたアイテムのうち未完了のアイテムをピックアップします。
|
221
|
+
# pickup incompleted items from the specified items
|
222
|
+
#
|
223
|
+
# ==== Args
|
224
|
+
# items :: アイテムの配列
|
225
|
+
# ==== Return
|
226
|
+
# 未完了アイテムの配列
|
227
|
+
def self.pickup_incomplete( items )
|
228
|
+
ret = []
|
229
|
+
for item in items
|
230
|
+
if( item.state == Item::INCOMPLETE )
|
231
|
+
ret.push( item )
|
232
|
+
end
|
233
|
+
end
|
234
|
+
return ret
|
235
|
+
end
|
236
|
+
|
237
|
+
#
|
238
|
+
# 期限切れのアイテムを探します
|
239
|
+
# pickup limit exceeded items from the specified items
|
240
|
+
#
|
241
|
+
# ==== Args
|
242
|
+
# items :: アイテムの配列
|
243
|
+
# ==== Return
|
244
|
+
# 期限切れになっているアイテムの配列
|
245
|
+
def self.pickup_expiration( items )
|
246
|
+
ret = []
|
247
|
+
current = Date.today
|
248
|
+
incomplete = pickup_incomplete( items )
|
249
|
+
for item in incomplete
|
250
|
+
if( item.limit != nil )
|
251
|
+
puts item.limit.strftime("%Y/%m/%d")+"-"+current.strftime("%Y/%m%d")
|
252
|
+
if( item.limit < current )
|
253
|
+
ret.push(item)
|
254
|
+
end
|
255
|
+
end
|
256
|
+
end
|
257
|
+
return ret
|
258
|
+
end
|
259
|
+
end
|
metadata
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: exceler
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- kitfactory
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-07-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: roo
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: check homepage.
|
56
|
+
email:
|
57
|
+
- kitfactory@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- .gitignore
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- exceler.gemspec
|
68
|
+
- lib/exceler.rb
|
69
|
+
- lib/exceler/version.rb
|
70
|
+
homepage: https://github.com/kitfactory/exceler
|
71
|
+
licenses:
|
72
|
+
- MIT
|
73
|
+
metadata: {}
|
74
|
+
post_install_message:
|
75
|
+
rdoc_options: []
|
76
|
+
require_paths:
|
77
|
+
- lib
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
requirements: []
|
89
|
+
rubyforge_project:
|
90
|
+
rubygems_version: 2.3.0
|
91
|
+
signing_key:
|
92
|
+
specification_version: 4
|
93
|
+
summary: Excel document parser for project metrics.
|
94
|
+
test_files: []
|