csv_to_products 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/csv_to_products.rb +1 -1
- data/lib/pairs.rb +8 -2
- 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: 768a83ed10a3a99abbe78a1bb85b5b8cdc218c6b
|
4
|
+
data.tar.gz: 1823c0c5bf2272bbbf720a63b42c1706462b7f71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18bc1aafef88c5455961d501cfa2ab4af55e1236152bdca0a2d412660328e17510a28a00bde725bf3f3a5d5d296dca02160b5c1c443e61c045c1ee38174d0f36
|
7
|
+
data.tar.gz: eed9c3483e8f71258a80918620611a5f5245fc35ad28a21e6f885bcbd08f5b0a5a9f80c53eff38ca7a1d6723bb8fc9b9dd5711ca5d1c4b3763b1e8b59b44244a
|
data/lib/csv_to_products.rb
CHANGED
data/lib/pairs.rb
CHANGED
@@ -6,7 +6,7 @@ module Pairs
|
|
6
6
|
row.each do |k, v|
|
7
7
|
d_k = dehumanize(k)
|
8
8
|
next if d_k == 'description'
|
9
|
-
next pairs[d_k] = v unless k.include?('[')
|
9
|
+
next pairs[d_k] = quote_dangerous(v) unless k.include?('[')
|
10
10
|
next unless affirmative?(v)
|
11
11
|
add_to_array(k, v)
|
12
12
|
end
|
@@ -25,11 +25,12 @@ module Pairs
|
|
25
25
|
def add_to_array(k, v)
|
26
26
|
k, v = k.scan(/[^\[\]]+/)
|
27
27
|
pairs[k] ||= []
|
28
|
-
pairs[k] << v
|
28
|
+
pairs[k] << quote_dangerous(v)
|
29
29
|
end
|
30
30
|
|
31
31
|
def pretty_pairs
|
32
32
|
pairs.map do |k, v|
|
33
|
+
next unless v && v.length > 0
|
33
34
|
v = "[#{v.join(', ')}]" if v.is_a?(Array)
|
34
35
|
"#{k}: #{v}\n"
|
35
36
|
end.join
|
@@ -38,5 +39,10 @@ module Pairs
|
|
38
39
|
def dehumanize(s)
|
39
40
|
s.to_s.gsub(' ', '_').downcase
|
40
41
|
end
|
42
|
+
|
43
|
+
def quote_dangerous(s)
|
44
|
+
return s unless s =~ /[^\w. ]/
|
45
|
+
s =~ /'/ ? "\"#{s}\"" : "'#{s}'"
|
46
|
+
end
|
41
47
|
end
|
42
48
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: csv_to_products
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Max White
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -57,7 +57,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
57
57
|
version: '0'
|
58
58
|
requirements: []
|
59
59
|
rubyforge_project:
|
60
|
-
rubygems_version: 2.
|
60
|
+
rubygems_version: 2.2.2
|
61
61
|
signing_key:
|
62
62
|
specification_version: 4
|
63
63
|
summary: Jekyll-Store cmdline tool to translate CSV file to products.
|