holistics 0.0.7 → 0.0.8

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: 61601d17f426d38122402a767f5b4534e6671b50
4
- data.tar.gz: 0c533d1dcb1f12c193ebc79fb168db3524a2fde6
3
+ metadata.gz: 66b023c2e0d7da99e00b5577457ce8a2c3ba5f1d
4
+ data.tar.gz: 317efca7f9469d5ab87054dee66cf00b6aa21a5d
5
5
  SHA512:
6
- metadata.gz: 9b77f45439562d748fd22fb498e5dc9f130f9d36e18cd67b2bdf05c5a1230e528d6bdba20e4cabd6135d3fe2364f0ac6a9012b8d824ac985ebd8a5827cd0aa6e
7
- data.tar.gz: 9ae95aa35c514d7860963d07180d091d3f3b67a75a59e16bff113817e4e231865687accec89143688e7e6f33105a57750eec562d9cb09c5f7eb036735881f97a
6
+ metadata.gz: bef183d58afbd0431b11b0bf9d3156b04ae53260124da046b03b857db5d6eebe15ac27e814f14e5caf75788cd70ce015e0b0689c267c319add604a666d20a783
7
+ data.tar.gz: 40b222ae0c41ba15087469e3d1aeea911dde0dc880a505e8b5a105c5561cfc55f708760ed9a716d25e8d3e0a0fa6f76df2dd0c1afb2b231dc2a353c1c7793e45
data/bin/holistics CHANGED
@@ -2,4 +2,4 @@
2
2
  ENV['GEM_ROOT_PATH'] = File.expand_path('../../', __FILE__)
3
3
 
4
4
  require 'holistics'
5
- HolisticsRunner.start
5
+ Holistics::HolisticsRunner.start
@@ -27,14 +27,14 @@ module Holistics
27
27
  end
28
28
 
29
29
  def holistics_authenticate(token)
30
- url = api_url_for('users/info.json', token)
30
+ url = api_url_for('users/info.json', {}, token)
31
31
  response = HTTParty.get(url)
32
32
  return response, (response.code == 200)
33
33
  end
34
34
 
35
35
  def job_show options
36
36
  job_id = options[:job_id]
37
- tail_job(job_id)
37
+ tail_logs(job_id)
38
38
  end
39
39
 
40
40
  def ds_list
@@ -62,20 +62,17 @@ module Holistics
62
62
  job_id = parsed['job_id']
63
63
 
64
64
  puts "Job submitted. Job ID: #{job_id}."
65
- tail_job(job_id)
65
+ tail_logs(job_id)
66
66
  end
67
67
 
68
- def tail_job(job_id)
68
+ def tail_logs(job_id)
69
69
  last_id = 0
70
70
  while true
71
- response = fetch_job_details(job_id, last_id)
72
- parsed = JSON.parse(response.body)
73
-
71
+ parsed = fetch_job_details(job_id, last_id)
74
72
  logs = parsed['logs']
75
-
76
73
  logs.each { |log| print_log(log) }
77
-
78
74
  last_id = logs.last['id'] if logs.size > 0
75
+
79
76
  break unless parsed['has_more']
80
77
 
81
78
  sleep 0.5
@@ -83,7 +80,8 @@ module Holistics
83
80
  end
84
81
 
85
82
  def fetch_job_details(job_id, last_id = 0)
86
- HTTParty.get(api_url_for("jobs/#{job_id}.json?last_id=#{last_id}"))
83
+ response = HTTParty.get(api_url_for("jobs/#{job_id}/logs.json", last_id: last_id))
84
+ JSON.parse(response.body)
87
85
  end
88
86
 
89
87
  def submit_transport_job(params)
@@ -142,12 +140,13 @@ module Holistics
142
140
  File.expand_path('~/.holistics.yml', __FILE__)
143
141
  end
144
142
 
145
- def api_url_for(path, token = nil)
146
- "#{server_url}#{path}?_utoken=#{token || get_token_from_gconfig}"
143
+ def api_url_for(path, params = {}, token = nil)
144
+ params[:_utoken] = token || get_token_from_gconfig
145
+ "#{server_url}#{path}?#{URI.encode_www_form(params)}"
147
146
  end
148
147
 
149
148
  def print_log log
150
- ts = Time.parse(log['created_at'])
149
+ ts = Time.parse(log['timestamp'])
151
150
  Holistics.logger.log(log['level'], log['message'], timestamp: ts)
152
151
  end
153
152
 
@@ -1,3 +1,3 @@
1
- class Holistics
2
- VERSION = '0.0.7'
1
+ module Holistics
2
+ VERSION = '0.0.8'
3
3
  end
data/lib/holistics.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'thor'
2
2
  require 'holistics/api_client'
3
+ require 'holistics/custom_logger'
3
4
  require 'vcr'
4
5
 
5
6
  module Holistics
@@ -7,57 +8,57 @@ module Holistics
7
8
  Pathname.new(__FILE__).parent.parent
8
9
  end
9
10
 
10
- def logger
11
+ def self.logger
11
12
  @logger ||= CustomLogger.new(STDOUT)
12
13
  end
13
14
 
14
- end
15
-
16
15
  # Right now we can't do `holistics ds:list`
17
16
  # Known issue: https://github.com/erikhuda/thor/issues/249
18
17
  # Either we use other libs, or figure out an elegant way to do it without
19
18
 
20
- class HolisticsRunner < Thor
21
19
 
22
- method_option :verbosity, aliases: '-v', type: :numeric, default: 2, required: false,
23
- desc: 'Set the logging verbosity. Values range from 1 (log everything) to 6 (log nothing)'
20
+ class HolisticsRunner < Thor
24
21
 
25
- def initialize(args=[], options={}, config={})
26
- super(args, options, config)
27
- end
22
+ method_option :verbosity, aliases: '-v', type: :numeric, default: 2, required: false,
23
+ desc: 'Set the logging verbosity. Values range from 1 (log everything) to 6 (log nothing)'
28
24
 
29
- desc 'login [auth_token]', 'Perform authentication'
25
+ def initialize(args=[], options={}, config={})
26
+ super(args, options, config)
27
+ end
30
28
 
31
- def login token
32
- client = ApiClient.new
33
- client.login(token)
34
- end
29
+ desc 'login [auth_token]', 'Perform authentication'
35
30
 
31
+ def login token
32
+ client = ApiClient.new
33
+ client.login(token)
34
+ end
36
35
 
37
- desc 'ds_list', 'List all data sources'
38
36
 
39
- def ds_list
40
- ApiClient.new.ds_list
41
- end
37
+ desc 'ds_list', 'List all data sources'
42
38
 
39
+ def ds_list
40
+ ApiClient.new.ds_list
41
+ end
43
42
 
44
- method_option :from_ds_id, aliases: '-s', type: :string, required: false, desc: 'From data source'
45
- method_option :dest_ds_id, aliases: '-d', type: :string, required: false, desc: 'To data source'
46
- method_option :from_table_name, aliases: '-t', type: :string, required: false, desc: 'The table to copy over'
47
- method_option :dest_table_name, aliases: '-n', type: :string, required: false, desc: '(optional) Rename destination table. Please specify fully qualified name'
48
- method_option :config_path, aliases: '-c', type: :string, required: false, desc: 'Path to transport config (JSON/YML)̄ file'
49
- desc 'transport', 'Submit a data transport job'
50
43
 
51
- def transport
52
- ApiClient.new.send_transport(options.dup)
53
- end
44
+ method_option :from_ds_id, aliases: '-s', type: :string, required: false, desc: 'From data source'
45
+ method_option :dest_ds_id, aliases: '-d', type: :string, required: false, desc: 'To data source'
46
+ method_option :from_table_name, aliases: '-t', type: :string, required: false, desc: 'The table to copy over'
47
+ method_option :dest_table_name, aliases: '-n', type: :string, required: false, desc: '(optional) Rename destination table. Please specify fully qualified name'
48
+ method_option :config_path, aliases: '-c', type: :string, required: false, desc: 'Path to transport config (JSON/YML)̄ file'
49
+ desc 'transport', 'Submit a data transport job'
54
50
 
51
+ def transport
52
+ ApiClient.new.send_transport(options.dup)
53
+ end
55
54
 
56
- method_option :job_id, aliases: '-j', type: :string, required: true, desc: 'Job ID'
57
- desc 'job_show', 'Show job log'
58
55
 
59
- def job_show
60
- ApiClient.new.job_show(options.dup)
61
- end
56
+ method_option :job_id, aliases: '-j', type: :string, required: true, desc: 'Job ID'
57
+ desc 'job_show', 'Show job log'
62
58
 
63
- end
59
+ def job_show
60
+ ApiClient.new.job_show(options.dup)
61
+ end
62
+
63
+ end
64
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: holistics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thanh Dinh Khac