caseblocks_bucket_extractor 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/bucket_downloader +12 -10
- metadata +5 -5
data/bin/bucket_downloader
CHANGED
@@ -5,7 +5,7 @@ require 'slop'
|
|
5
5
|
require 'csv'
|
6
6
|
require 'fileutils'
|
7
7
|
require (File.expand_path '../..', __FILE__) + '/lib/caseblocks_bucket_extractor'
|
8
|
-
|
8
|
+
|
9
9
|
opts = Slop.parse do
|
10
10
|
banner 'Usage: bucket_downloader [options]'
|
11
11
|
|
@@ -20,27 +20,29 @@ opts = Slop.parse do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
if opts[:casetype] && opts[:bucket] && opts[:path] && opts[:token]
|
23
|
+
$stdout.reopen(File.join(opts[:path], "#{opts[:casetype]}-#{opts[:bucket]}.log"))
|
24
|
+
$stderr.reopen(File.join(opts[:path], "#{opts[:casetype]}-#{opts[:bucket]}.error.log"))
|
23
25
|
|
24
26
|
# Bucket Downloader
|
25
27
|
puts " == Bucket Downloader == "
|
26
|
-
|
28
|
+
|
27
29
|
bucket_name = opts[:bucket]
|
28
30
|
case_type = opts[:casetype]
|
29
31
|
retry_limit = (opts[:timeout] || 180).to_i
|
30
32
|
relation_type = opts[:relation_type] || "domain"
|
31
|
-
url = opts[:url] || "
|
32
|
-
|
33
|
+
url = opts[:url] || "http://localhost:3000"
|
34
|
+
|
33
35
|
puts "Downloading bucket: #{bucket_name} from #{case_type}"
|
34
|
-
|
36
|
+
|
35
37
|
puts "Creating Bucket Extractor... "
|
36
38
|
bucket_extractor = CaseblocksBucketExtractor.new(url, opts[:token], {:retry_limit => retry_limit,:time_between_retries => 60})
|
37
|
-
|
39
|
+
|
38
40
|
file_path = opts[:path] + "/"+ DateTime.now.strftime("%y-%m-%d-%M-%H") + "_" + bucket_name + ".csv"
|
39
|
-
|
41
|
+
|
40
42
|
file_options = [{:path => file_path, :name => "#{relation_type}.csv"}]
|
41
|
-
|
43
|
+
|
42
44
|
puts "Downloading to #{file_path}"
|
43
|
-
|
45
|
+
|
44
46
|
#Begin download specifying Case Type Name, bucket slug and the file options defined above
|
45
47
|
begin
|
46
48
|
bucket_extractor.download(case_type, bucket_name, file_options)
|
@@ -56,7 +58,7 @@ if opts[:casetype] && opts[:bucket] && opts[:path] && opts[:token]
|
|
56
58
|
end
|
57
59
|
FileUtils.mv("#{file_path[0..-5]}.tmp", file_path)
|
58
60
|
end
|
59
|
-
|
61
|
+
|
60
62
|
puts "End Bucket Downloader"
|
61
63
|
rescue => e
|
62
64
|
puts "Download has not completed successully: #{e.message}"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: caseblocks_bucket_extractor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2013-06-04 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
16
|
-
requirement: &
|
16
|
+
requirement: &70263547422640 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.11.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70263547422640
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: slop
|
27
|
-
requirement: &
|
27
|
+
requirement: &70263547422240 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70263547422240
|
36
36
|
description: A simple hello world gem
|
37
37
|
email: development@emergeadapt.com
|
38
38
|
executables:
|