takenoko 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/takenoko.rb +1 -1
- data/lib/takenoko/exporter.rb +3 -1
- data/lib/takenoko/google_client.rb +26 -23
- data/lib/takenoko/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 08ef0bb4b3b7c4482ec4470db97b30bb6fb85c35
|
4
|
+
data.tar.gz: 3483c0bbf4a6ed35fde43cda1a2b592042e657d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: baaa50a24ac0d47750bdaf42e9e756d4d84cce59bf2418a812766146b3fdff57bd2f36ce781328f585e91a52badb85831c4a603c5d5cc1e321fb4a303ea5f0bc
|
7
|
+
data.tar.gz: 54a9d7da4fe0e43e3edf3de9ad359f2c300300e91db231f6923e1dd4ccc1d955ab17b6855e29b5dd75e0475a0d8d77a0b2e132ad36aabac390b7ed88f4ab4cfb
|
data/lib/takenoko.rb
CHANGED
data/lib/takenoko/exporter.rb
CHANGED
@@ -41,9 +41,11 @@ module Takenoko
|
|
41
41
|
|
42
42
|
[:yaml,:json].each do |output|
|
43
43
|
define_method "convert_to_#{output}" do |table|
|
44
|
-
table[:rows].public_send("to_#{output}")
|
44
|
+
table[:rows].map{|r| r.to_hash}.public_send("to_#{output}")
|
45
45
|
end
|
46
46
|
end
|
47
|
+
|
48
|
+
alias convert_to_yml convert_to_yaml
|
47
49
|
end
|
48
50
|
|
49
51
|
end
|
@@ -28,40 +28,38 @@ module Takenoko
|
|
28
28
|
hash = HashWithIndifferentAccess.new
|
29
29
|
table['columns_mapping'].each do |key,val|
|
30
30
|
begin
|
31
|
-
|
31
|
+
val = r.public_send(val)
|
32
32
|
rescue Exception => e
|
33
33
|
if key == 'id'
|
34
|
-
|
34
|
+
val = r.row_num - 1
|
35
35
|
else
|
36
|
-
|
36
|
+
val = nil
|
37
37
|
end
|
38
38
|
end
|
39
|
+
hash[key.to_sym] = format_row val
|
39
40
|
end
|
40
41
|
hash
|
41
|
-
end.reject do |row|
|
42
|
-
begin
|
43
|
-
table[:enable_postprocess] && !postprocess_class.public_send("spreadsheet_row_valid?",row)
|
44
|
-
rescue NoMethodError => e
|
45
|
-
Rails.logger.warn e.message
|
46
|
-
false
|
47
|
-
end
|
48
|
-
end.map do |row|
|
49
|
-
begin
|
50
|
-
table[:enable_postprocess] ? postprocess_class.public_send("postprocess_spreadsheet_row",row) : row
|
51
|
-
rescue NoMethodError => e
|
52
|
-
Rails.logger.warn e.message
|
53
|
-
row
|
54
|
-
end
|
55
42
|
end
|
56
43
|
|
57
|
-
table[:
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
44
|
+
if(table[:enable_postprocess])
|
45
|
+
rows.reject do |row|
|
46
|
+
if postprocess_class.respond_to? "spreadsheet_row_valid?"
|
47
|
+
postprocess_class.public_send("spreadsheet_row_valid?",row)
|
48
|
+
end
|
49
|
+
end.map do |row|
|
50
|
+
if postprocess_class.respond_to? "postprocess_spreadsheet_row"
|
51
|
+
row = postprocess_class.public_send("postprocess_spreadsheet_row",row)
|
52
|
+
end
|
63
53
|
end
|
54
|
+
|
55
|
+
table[:rows] = rows
|
56
|
+
if postprocess_class.respond_to? "postprocess_spreadsheet_table"
|
57
|
+
table = postprocess_class.public_send("postprocess_spreadsheet_table",table)
|
58
|
+
end
|
59
|
+
else
|
60
|
+
table[:rows] = rows
|
64
61
|
end
|
62
|
+
|
65
63
|
return table
|
66
64
|
end
|
67
65
|
|
@@ -119,5 +117,10 @@ module Takenoko
|
|
119
117
|
table[:header] = table[:columns_mapping].keys
|
120
118
|
return table
|
121
119
|
end
|
120
|
+
|
121
|
+
def format_row(v)
|
122
|
+
return nil unless v
|
123
|
+
((float = Float(v)) && (float % 1.0 == 0) ? float.to_i : float) rescue v
|
124
|
+
end
|
122
125
|
end
|
123
126
|
end
|
data/lib/takenoko/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: takenoko
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- KhiemNS
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -89,7 +89,7 @@ files:
|
|
89
89
|
- lib/tasks/takenoko.rake
|
90
90
|
- test/takenoko_test.rb
|
91
91
|
- test/test_helper.rb
|
92
|
-
homepage: https://github.com/khiemns54/takenoko/tree/release/0.2.
|
92
|
+
homepage: https://github.com/khiemns54/takenoko/tree/release/0.2.7
|
93
93
|
licenses: []
|
94
94
|
metadata: {}
|
95
95
|
post_install_message:
|