shipping_materials 0.0.4 → 0.0.5
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90e2e5bf9802923e8743c2b3dfee66de88be6b83
|
4
|
+
data.tar.gz: d818389a56fbd0ecbff39754147f823b5341c21c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 330ae599728d57285d340867804036c64ef689a63552735cb8ed85b18b657804bb232bc5f8787a77a0a64fd11bfa4440a96796045b72499773239544ca7c1241
|
7
|
+
data.tar.gz: 5486fc55ac7c9688bfe34974dc87294a895f8b69e1444dba22d18c09e5b211659ce832c4e1d3c7158ee855f188cd2467cbdf648c25f020b195b7e1bf29fc8092
|
@@ -2,11 +2,10 @@ module ShippingMaterials
|
|
2
2
|
class CSVDSL
|
3
3
|
require 'csv'
|
4
4
|
|
5
|
-
attr_accessor :
|
5
|
+
attr_accessor :row_maps
|
6
6
|
attr_reader :headers
|
7
7
|
|
8
|
-
def initialize(
|
9
|
-
@objects = objects
|
8
|
+
def initialize(options={})
|
10
9
|
@row_maps = []
|
11
10
|
@options = options
|
12
11
|
end
|
@@ -31,10 +30,10 @@ module ShippingMaterials
|
|
31
30
|
end
|
32
31
|
end
|
33
32
|
|
34
|
-
def
|
33
|
+
def generate(objects)
|
35
34
|
CSV.generate do |csv|
|
36
35
|
csv << headers if headers?
|
37
|
-
|
36
|
+
objects.each do |object|
|
38
37
|
@row_maps.each do |row_map|
|
39
38
|
next unless apply_callbacks(row_map[:callbacks], object)
|
40
39
|
if row_map[:context] == :object
|
@@ -48,7 +47,6 @@ module ShippingMaterials
|
|
48
47
|
end
|
49
48
|
end
|
50
49
|
end
|
51
|
-
alias_method :to_s, :to_csv
|
52
50
|
|
53
51
|
def extension
|
54
52
|
@options[:extension] || 'csv'
|
@@ -17,11 +17,10 @@ module ShippingMaterials
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def csv(options={}, &block)
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
20
|
+
return unless block
|
21
|
+
csv = CSVDSL.new(options)
|
22
|
+
csv.instance_eval(&block)
|
23
|
+
@csvs << csv
|
25
24
|
end
|
26
25
|
end
|
27
26
|
end
|
@@ -54,7 +54,7 @@ module ShippingMaterials
|
|
54
54
|
def create_csvs(group)
|
55
55
|
group.csvs.each do |csv|
|
56
56
|
filename = Storage.filenameize(group.basename) + '.' + csv.extension
|
57
|
-
Storage.write_file(filename, csv.
|
57
|
+
Storage.write_file(filename, csv.generate(group.objects))
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
@@ -2,7 +2,9 @@ module ShippingMaterials
|
|
2
2
|
class Storage
|
3
3
|
class << self
|
4
4
|
def write_file(filename, contents)
|
5
|
-
|
5
|
+
basename = filenameize(File.basename(filename, '.*'))
|
6
|
+
extension = File.extname(filename)
|
7
|
+
filename = "#{save_path}/#{basename}#{extension}"
|
6
8
|
File.open(filename, 'w') do |fp|
|
7
9
|
fp.write(contents)
|
8
10
|
if Config.use_s3? && !Config.use_gzip?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shipping_materials
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Haust
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-10-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|