meer 0.0.7 → 0.0.8

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: 995a0b2cdac02dc4d8d2b23f391252953ef1b1ae
4
- data.tar.gz: b30fe6ee33e7dbeb8f942b9f43135e41dbc08348
3
+ metadata.gz: e74d2cf311f4c0a2c7f8def9ee3d016f42bd864a
4
+ data.tar.gz: b850a87d8f329d219d32cef374b484ede546a736
5
5
  SHA512:
6
- metadata.gz: 9696472be4953387cf8a990f998ddaa66d8075a16bf2c7d24469fb2f96485af96369b055572b57ee2ea5b902dc35f89f895faecbdd3911ad18046fbcaa4bb9c9
7
- data.tar.gz: ea0b4bf9610f3acda7e213e0b143f791927ae160cd6e31b91880c7aa8c9d8a4f2f2e605f596ed8f074ce89f7354be062fe8f004b69c5c4d27153a63eede2507a
6
+ metadata.gz: 4d7a5fd6eb509903084062376b569b72633444b5ec64455044670cec567637bf7f9aefd15fd603efa49140fb178b09a02a5c45a55d509af5feee93aaf3a7d942
7
+ data.tar.gz: 9cfdf9544230e96f645152ab619454d32c4582c53acfe078c2015837c7534e8d69451afdcc264f08b9f6e3e50c6af300216d5a5c2c88322c5c096792e7036ba3
data/README.md CHANGED
@@ -14,12 +14,13 @@ Meer pulls the base url for what datameer to hit from environment variables, so
14
14
 
15
15
  ``` shell
16
16
  $ meer help
17
-
18
17
  Commands:
19
18
  meer csv [WORKBOOK-ID] [SHEET_NAME] # Outputs the CSV for a given workbook
20
19
  meer help [COMMAND] # Describe available commands or one specific command
20
+ meer jobs # Lists all currently running jobs
21
21
  meer login # Logs into datameer for quick access
22
22
  meer sheets [WORKBOOK-ID] # Lists all sheets in a workbook
23
+ meer start [WORKBOOK-ID] # Trigger a run of a workbook
23
24
  meer table [WORKBOOK-ID] [SHEET_NAME] # Outputs a nicely formatted table for a given workbook
24
25
  meer workbooks # Lists all workbooks
25
26
  ```
data/lib/meer.rb CHANGED
@@ -3,6 +3,7 @@ require "meer/version"
3
3
  require 'net/http'
4
4
  require 'uri'
5
5
  require 'json'
6
+ require 'yaml'
6
7
  require 'csv'
7
8
  require 'thor'
8
9
  require 'highline/import'
data/lib/meer/cli.rb CHANGED
@@ -46,6 +46,29 @@ module Meer
46
46
  puts Terminal::Table.new(headings: headers, rows: rows)
47
47
  end
48
48
 
49
+ desc 'start [WORKBOOK-ID]', 'Trigger a run of a workbook'
50
+ def start(wb_id)
51
+ puts client.run_workbook(wb_id).to_yaml
52
+ end
53
+
54
+ JOB_HEADERS = %w(startTime jobStatus dapJobConfigurationId jobExecutionId progress estimateTime)
55
+
56
+ desc 'jobs', 'Lists all currently running jobs'
57
+ option :workbook, type: :numeric, aliases: :w
58
+ option :job, type: :numeric, aliases: :j
59
+ def jobs
60
+ data = client.running_jobs
61
+
62
+ rows = if data.size > 0
63
+ data.select!{|r| r['dapJobConfigurationId'].to_i == options[:workbook] } if options[:workbook]
64
+ data.select!{|r| r['jobExecutionId'].to_i == options[:job] } if options[:job]
65
+ data.sort_by {|r| -r['progress'].to_i }.map { |r| JOB_HEADERS.map{|k| r[k]} }
66
+ else
67
+ []
68
+ end
69
+
70
+ puts Terminal::Table.new(headings: JOB_HEADERS, rows: rows)
71
+ end
49
72
 
50
73
  private
51
74
 
data/lib/meer/datameer.rb CHANGED
@@ -32,6 +32,11 @@ module Meer
32
32
  req = Net::HTTP::Get.new(URI(uri.to_s + url))
33
33
  request(req)
34
34
  end
35
+
36
+ def post url
37
+ req = Net::HTTP::Post.new(URI(uri.to_s + url))
38
+ request(req)
39
+ end
35
40
 
36
41
 
37
42
  def login
@@ -59,6 +64,14 @@ module Meer
59
64
  JSON.parse(get("/rest/workbook").body)
60
65
  end
61
66
 
67
+ def run_workbook wb_id
68
+ JSON.parse post("/rest/job-execution?configuration=#{wb_id}").body
69
+ end
70
+
71
+ def running_jobs
72
+ JSON.parse get("/rest/jobs/list-running").body
73
+ end
74
+
62
75
  module Session
63
76
  SESSION_FILE = File.expand_path('~/.dmsession')
64
77
 
data/lib/meer/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Meer
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: meer
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
  - philip.monroe