appcues_data_uploader 0.1.0 → 0.2.0

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: 1f37ccc95281d68b9a4f6dcd313edc31ad3731c8
4
- data.tar.gz: b1290ef67cbcdb17896b5611967a8e1146f04502
3
+ metadata.gz: 0f8bb6dc96485d07fb821f6559e13588d1d032cd
4
+ data.tar.gz: 33de9f67aca03c4b6935e039766c900b6970db44
5
5
  SHA512:
6
- metadata.gz: 6352fbd7d9ded12a104dfc61e442bfa8ffb30ce7a7dc17cf7bfaed94a4906d279187c0d2542ed6db9673fddbd0dc61c616e841ce170c828309d9bc339706370f
7
- data.tar.gz: 825cdd5adfc0a52489252346a3e78b6683ffd9d751ada29539cf44d5b9f43cd18610b0093faa53d42079102b47d6c5020ec4ec2c22c42fcb59d2e37255d2b8a7
6
+ metadata.gz: ea11670e11b4971c70adc307f93f31ba438f6f6ccff67fec061bdb64db6be3f500cc8ad4522e6e5466fa2fe9e22947241ebab872bdb91a98f3df6b701afc5c82
7
+ data.tar.gz: 77273d66e4e529c09c51fe219d79d3e8783a94d52f03932ee662d485551dcbf4a9915db77bb15551ea92fa37d4363e41b6802485a01f5a2cb907e3f468e795ca
@@ -31,7 +31,7 @@ class AppcuesDataUploader
31
31
 
32
32
  option_parser = OptionParser.new do |opts|
33
33
  opts.banner = <<-EOT
34
- Usage: #{$0} [options] -a account_id [filename ...]
34
+ Usage: appcues-data-uploader [options] -a account_id [filename ...]
35
35
 
36
36
  Uploads profile data from one or more CSVs to the Appcues API.
37
37
  If no filename or a filename of '-' is given, STDIN is used.
@@ -52,6 +52,8 @@ Will result in two profile updates being sent to the API:
52
52
 
53
53
  {"account_id": "999", "user_id": "123", "profile_update": {"first_name": "Pete", "has_posse": false, "height_in_inches": 68.5}}
54
54
  {"account_id": "999", "user_id": "456", "profile_update": {"first_name": "André", "has_posse": true, "height_in_inches": 88}}
55
+
56
+ See https://github.com/appcues/data-uploader for more information.
55
57
  EOT
56
58
 
57
59
  opts.separator ""
@@ -87,10 +89,16 @@ Will result in two profile updates being sent to the API:
87
89
 
88
90
  if !options.account_id
89
91
  STDERR.puts "You must specify an account ID with the -a option."
92
+ STDERR.puts "Run `appcues-data-uploader --help` for more information."
90
93
  exit 1
91
94
  end
92
95
 
93
- new(options).perform_uploads()
96
+ begin
97
+ new(options).perform_uploads()
98
+ rescue Exception => e
99
+ STDERR.puts "#{e.class}: #{e.message}"
100
+ exit 255
101
+ end
94
102
  end
95
103
  end
96
104
 
@@ -137,7 +145,7 @@ private
137
145
  user_activities = []
138
146
 
139
147
  CSV.new(input_fh, headers: true).each do |row|
140
- row_hash = row.to_h
148
+ row_hash = row.to_hash
141
149
 
142
150
  if !user_id_column
143
151
  user_id_column = get_user_id_column(row_hash)
@@ -178,7 +186,7 @@ private
178
186
  end
179
187
 
180
188
  if failed_uas.count > 0
181
- debug "retrying #{failed_uas.count} requests."
189
+ debug "Retrying #{failed_uas.count} requests."
182
190
  make_activity_requests(failed_uas)
183
191
  end
184
192
  end
@@ -214,7 +222,7 @@ private
214
222
  canonical_key = key.gsub(/[^a-zA-Z]/, '').downcase
215
223
  return key if canonical_key == 'userid'
216
224
  end
217
- raise ArgumentError, "couldn't detect user ID column"
225
+ raise "Couldn't detect user ID column from CSV input. Ensure that the CSV data starts with headers, and one is named like 'user_id'."
218
226
  end
219
227
 
220
228
  ## Prints a message to STDERR unless we're in quiet mode.
@@ -1,4 +1,4 @@
1
1
  class AppcuesDataUploader
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  VERSION_DATE = "2018-11-08"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appcues_data_uploader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - pete gamache