bill_hicks 1.1.5 → 1.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0e5bfce774f2e573064636a5160f9196aaa70998
4
- data.tar.gz: 8bd8d77577eccaab3af58a596b4b56fd28faf7d6
3
+ metadata.gz: 14cbdf2a7909f74d9e9ed220ace8f62588810be0
4
+ data.tar.gz: 20119ac538fe4debcadf6aae3914b8faf80742d4
5
5
  SHA512:
6
- metadata.gz: eadd363c7d06e8e10287b727f21f79b1f937879e3d3508bb14c82ccf4cada78920b0846bb0f099e219a09445a4adf197bcd1a36ef518f4b9c41e3f2e1e039db7
7
- data.tar.gz: 4d16b238b34d7051c5bb28b8877ffa7ce88a9164e0caafc9e4eaa2b55b06db9f96fdb70e9f46e0ec9f7e15cfa56b5dd2e8a3470800faf3bb0bc68eb11fdb9448
6
+ metadata.gz: 72d2ea4bafa8cf965a4729f4fe65e88bd1d8999cbfa83f19d33f87f22c5ea26ff43e4ee0f4be79c61c389fb9b0452565cb246f6f171a88e715d075c235a2be15
7
+ data.tar.gz: c226b034bb5293c34ad7f76cffa70d7cfdc7d4c898536a2d7c349ed79f005d8191f72ac638817c192069c444892e3047be3969945b0c0dcb9f57f47de67ba173
data/bill_hicks.gemspec CHANGED
@@ -21,6 +21,8 @@ Gem::Specification.new do |spec|
21
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
22
  spec.require_paths = ["lib"]
23
23
 
24
+ spec.add_runtime_dependency "smarter_csv", "~> 1.1.4"
25
+
24
26
  spec.add_development_dependency "bundler", "~> 1.12"
25
27
  spec.add_development_dependency "rake", "~> 11.3"
26
28
  spec.add_development_dependency "rspec", "~> 3.5"
data/lib/bill_hicks.rb CHANGED
@@ -2,6 +2,7 @@ require 'bill_hicks/version'
2
2
 
3
3
  require 'csv'
4
4
  require 'net/ftp'
5
+ require 'smarter_csv'
5
6
 
6
7
  require 'bill_hicks/base'
7
8
  require 'bill_hicks/catalog'
@@ -30,6 +30,13 @@ module BillHicks
30
30
  new(options).all
31
31
  end
32
32
 
33
+ def self.process_as_chunks(size = 15, options = {})
34
+ requires!(options, :username, :password)
35
+ new(options).process_as_chunks(size) do |chunk|
36
+ yield(chunk)
37
+ end
38
+ end
39
+
33
40
  # Returns an array of hashes with the catalog item details.
34
41
  def all
35
42
  catalog = []
@@ -55,5 +62,23 @@ module BillHicks
55
62
  catalog
56
63
  end
57
64
 
65
+ # Streams csv and chunks it
66
+ #
67
+ # @size integer The number of items in each chunk
68
+ def process_as_chunks(size)
69
+ connect(@options) do |ftp|
70
+ temp_csv_file = Tempfile.new
71
+
72
+ ftp.chdir(BillHicks.config.top_level_dir)
73
+ ftp.gettextfile(CATALOG_FILENAME, temp_csv_file.path)
74
+
75
+ SmarterCSV.process(temp_csv_file, { :chunk_size => size }) do |chunk|
76
+ yield(chunk)
77
+ end
78
+
79
+ temp_csv_file.unlink
80
+ end
81
+ end
82
+
58
83
  end
59
84
  end
@@ -20,6 +20,13 @@ module BillHicks
20
20
  new(options).all
21
21
  end
22
22
 
23
+ def self.process_as_chunks(size = 15, options = {})
24
+ requires!(options, :username, :password)
25
+ new(options).process_as_chunks(size) do |chunk|
26
+ yield(chunk)
27
+ end
28
+ end
29
+
23
30
  # Returns an array of hashes with the inventory item details.
24
31
  def all
25
32
  inventory = []
@@ -41,5 +48,23 @@ module BillHicks
41
48
  inventory
42
49
  end
43
50
 
51
+ # Streams csv and chunks it
52
+ #
53
+ # @size integer The number of items in each chunk
54
+ def process_as_chunks(size)
55
+ connect(@options) do |ftp|
56
+ temp_csv_file = Tempfile.new
57
+
58
+ ftp.chdir(BillHicks.config.top_level_dir)
59
+ ftp.gettextfile(INVENTORY_FILENAME, temp_csv_file.path)
60
+
61
+ SmarterCSV.process(temp_csv_file, { :chunk_size => size }) do |chunk|
62
+ yield(chunk)
63
+ end
64
+
65
+ temp_csv_file.unlink
66
+ end
67
+ end
68
+
44
69
  end
45
70
  end
@@ -1,3 +1,3 @@
1
1
  module BillHicks
2
- VERSION = '1.1.5'
2
+ VERSION = '1.1.6'
3
3
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bill_hicks
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.5
4
+ version: 1.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dale Campbell
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-02-17 00:00:00.000000000 Z
11
+ date: 2017-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: smarter_csv
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.1.4
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.1.4
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -100,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
114
  version: '0'
101
115
  requirements: []
102
116
  rubyforge_project:
103
- rubygems_version: 2.6.7
117
+ rubygems_version: 2.5.1
104
118
  signing_key:
105
119
  specification_version: 4
106
120
  summary: Ruby library for Bill Hicks ERP system