storehouse_client 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  module StorehouseClient
2
- VERSION = '0.0.8'
2
+ VERSION = '0.0.9'
3
3
  AUTHORS = ['Jon Gillies']
4
4
  EMAIL = %w(supercoder@gmail.com)
5
5
  DESCRIPTION = %q{This the API client to the Storehouse application.}
@@ -16,12 +16,13 @@ module StorehouseClient
16
16
 
17
17
  def initialize(args)
18
18
 
19
- @error = nil
20
- @url = args.fetch(:url) { raise 'You must provide :url' }
19
+ @error = nil
20
+ @url = args.fetch(:url) { raise 'You must provide :url' }
21
21
  @api_version = args.fetch(:api_version) { 1 }
22
- @auth_token = args.fetch(:auth_token) { raise 'You must provide :auth_token' }
22
+ @auth_token = args.fetch(:auth_token) { raise 'You must provide :auth_token' }
23
+
23
24
  @record_count = 0
24
- @duration = nil
25
+ @duration = nil
25
26
 
26
27
  @resource = RestClient::Resource.new @url
27
28
 
@@ -39,10 +40,10 @@ module StorehouseClient
39
40
 
40
41
  @data_source_id = data_source_id
41
42
 
42
- run = {}
43
- run['export_run'] = {}
43
+ run = {}
44
+ run['export_run'] = {}
44
45
  run['export_run']['data_source_id'] = @data_source_id
45
- run['export_run']['started_at'] = Time.now
46
+ run['export_run']['started_at'] = Time.now
46
47
 
47
48
  r = post("api/#{@api_version}/export_runs?auth_token=#{@auth_token}", run)
48
49
 
@@ -55,9 +56,9 @@ module StorehouseClient
55
56
 
56
57
  def finish_run
57
58
 
58
- run = {}
59
- run['export_run'] = {}
60
- run['export_run']['finished_at'] = Time.now.to_s
59
+ run = {}
60
+ run['export_run'] = {}
61
+ run['export_run']['finished_at'] = Time.now.to_s
61
62
  run['export_run']['record_count'] = @record_count
62
63
 
63
64
  r = put("api/#{@api_version}/export_runs/#{@run_id}?auth_token=#{@auth_token}", run)
@@ -71,22 +72,23 @@ module StorehouseClient
71
72
 
72
73
  def add_record(primary_key, data)
73
74
 
74
- # primary_key must be a string
75
-
76
- e = {}
77
- e['export_record'] = {}
78
- e['export_record']['blob_attributes'] = {}
79
- e['export_record']['blob_attributes']['data'] = data
80
- e['export_record']['blob_attributes']['checksum'] = Digest::SHA256.hexdigest(data.to_json)
81
- e['export_record']['record_size'] = data.to_json.length
82
- e['export_record']['checksum'] = e['export_record']['blob_attributes']['checksum']
83
- e['export_record']['primary_key'] = primary_key.to_s # Ensure primary key is a string
84
- e['export_record']['data_source_id'] = @data_source_id
85
- e['export_record']['export_run_id'] = @run_id
86
-
87
- post("api/#{@api_version}/export_records/?auth_token=#{@auth_token}", e)
75
+ begin
76
+ e = {}
77
+ e['export_record'] = {}
78
+ e['export_record']['blob_attributes'] = {}
79
+ e['export_record']['blob_attributes']['data'] = data
80
+ e['export_record']['blob_attributes']['checksum'] = Digest::SHA256.hexdigest(data.to_json)
81
+ e['export_record']['record_size'] = data.to_json.length
82
+ e['export_record']['checksum'] = e['export_record']['blob_attributes']['checksum']
83
+ e['export_record']['primary_key'] = primary_key.to_s # Ensure primary key is a string
84
+ e['export_record']['data_source_id'] = @data_source_id
85
+ e['export_record']['export_run_id'] = @run_id
86
+
87
+ post("api/#{@api_version}/export_records/?auth_token=#{@auth_token}", e)
88
88
 
89
- return nil if error?
89
+ rescue Exception => @error
90
+ return nil
91
+ end
90
92
 
91
93
  @record_count += 1
92
94
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: storehouse_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-08 00:00:00.000000000 Z
12
+ date: 2013-08-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: !ruby/object:Gem::Requirement
16
+ requirement: &70264738461980 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,15 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: '0'
24
+ version_requirements: *70264738461980
30
25
  - !ruby/object:Gem::Dependency
31
26
  name: lorem
32
- requirement: !ruby/object:Gem::Requirement
27
+ requirement: &70264738461480 !ruby/object:Gem::Requirement
33
28
  none: false
34
29
  requirements:
35
30
  - - ! '>='
@@ -37,31 +32,43 @@ dependencies:
37
32
  version: '0'
38
33
  type: :development
39
34
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
35
+ version_requirements: *70264738461480
36
+ - !ruby/object:Gem::Dependency
37
+ name: gemcutter
38
+ requirement: &70264738460980 !ruby/object:Gem::Requirement
41
39
  none: false
42
40
  requirements:
43
41
  - - ! '>='
44
42
  - !ruby/object:Gem::Version
45
43
  version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70264738460980
46
47
  - !ruby/object:Gem::Dependency
47
- name: rest-client
48
- requirement: !ruby/object:Gem::Requirement
48
+ name: dnsruby
49
+ requirement: &70264738460520 !ruby/object:Gem::Requirement
49
50
  none: false
50
51
  requirements:
51
52
  - - ! '>='
52
53
  - !ruby/object:Gem::Version
53
54
  version: '0'
54
- type: :runtime
55
+ type: :development
55
56
  prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
+ version_requirements: *70264738460520
58
+ - !ruby/object:Gem::Dependency
59
+ name: fog
60
+ requirement: &70264738460040 !ruby/object:Gem::Requirement
57
61
  none: false
58
62
  requirements:
59
63
  - - ! '>='
60
64
  - !ruby/object:Gem::Version
61
65
  version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *70264738460040
62
69
  - !ruby/object:Gem::Dependency
63
- name: crack
64
- requirement: !ruby/object:Gem::Requirement
70
+ name: rest-client
71
+ requirement: &70264738459580 !ruby/object:Gem::Requirement
65
72
  none: false
66
73
  requirements:
67
74
  - - ! '>='
@@ -69,12 +76,18 @@ dependencies:
69
76
  version: '0'
70
77
  type: :runtime
71
78
  prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
79
+ version_requirements: *70264738459580
80
+ - !ruby/object:Gem::Dependency
81
+ name: crack
82
+ requirement: &70264738459140 !ruby/object:Gem::Requirement
73
83
  none: false
74
84
  requirements:
75
85
  - - ! '>='
76
86
  - !ruby/object:Gem::Version
77
87
  version: '0'
88
+ type: :runtime
89
+ prerelease: false
90
+ version_requirements: *70264738459140
78
91
  description: This the API client to the Storehouse application.
79
92
  email:
80
93
  - supercoder@gmail.com
@@ -111,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
124
  version: '0'
112
125
  requirements: []
113
126
  rubyforge_project:
114
- rubygems_version: 1.8.23
127
+ rubygems_version: 1.8.15
115
128
  signing_key:
116
129
  specification_version: 3
117
130
  summary: API client to the Storehouse