meer 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +3 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +23 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +2 -0
- data/bin/meer +8 -0
- data/lib/meer/cli.rb +47 -0
- data/lib/meer/datameer.rb +60 -0
- data/lib/meer/version.rb +3 -0
- data/lib/meer.rb +15 -0
- data/meer.gemspec +26 -0
- metadata +113 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7a2c5ce58df0cef1c015eae2cdeb15886908eb1a
|
4
|
+
data.tar.gz: d7dab6a18350b5d4838c2b700ecc3ebe76a52d7a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e622dba69a402f5d94eee8c125654a8428312943ebc15defcb97749d9a3c78a070aa76af7ef3d25b5a7cc06356ae88b294a77a41e00c2042862d62a42ea3beda
|
7
|
+
data.tar.gz: febd4bdf3f204fe2defdac79735b070f14c10403ec1255c1fd0ddd1fe8e0a11a32fd36537b80f9fb205c7fd0f3dd52440bef851001fe572c8528532e7f71c8ad
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
meer (0.0.1)
|
5
|
+
bundler (~> 1.7)
|
6
|
+
highline
|
7
|
+
rake (~> 10.0)
|
8
|
+
terminal-table
|
9
|
+
thor
|
10
|
+
|
11
|
+
GEM
|
12
|
+
remote: https://rubygems.org/
|
13
|
+
specs:
|
14
|
+
highline (1.7.2)
|
15
|
+
rake (10.4.2)
|
16
|
+
terminal-table (1.4.5)
|
17
|
+
thor (0.19.1)
|
18
|
+
|
19
|
+
PLATFORMS
|
20
|
+
ruby
|
21
|
+
|
22
|
+
DEPENDENCIES
|
23
|
+
meer!
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 philip.monroe
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Meer
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'meer'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install meer
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it ( https://github.com/[my-github-username]/meer/fork )
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/meer
ADDED
data/lib/meer/cli.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'meer/datameer'
|
2
|
+
|
3
|
+
module Meer
|
4
|
+
class CLI < ::Thor
|
5
|
+
desc "login", "logs into datameer for quick access"
|
6
|
+
def login
|
7
|
+
user = ask("username:", default: ENV['USER'])
|
8
|
+
password = ask("password:", :echo => false)
|
9
|
+
puts
|
10
|
+
|
11
|
+
client(user, password).login
|
12
|
+
end
|
13
|
+
|
14
|
+
desc "workbooks", "lists all workbooks"
|
15
|
+
def workbooks
|
16
|
+
client.workbooks.sort_by { |w| w['path'] }.each do |workbook|
|
17
|
+
puts " - [#{workbook['id']}] #{workbook['path']}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
desc "sheets", "lists all sheets in a workbook"
|
22
|
+
def sheets(workbook_id)
|
23
|
+
client.workbook(workbook_id)['sheets'].each do |sheet|
|
24
|
+
puts " - #{sheet['name']}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
desc "csv", "outputs the CSV for a given workbook"
|
29
|
+
def csv(workbook, sheet)
|
30
|
+
puts client.workbook_data(workbook, sheet)
|
31
|
+
end
|
32
|
+
|
33
|
+
desc "table", "outputs a nicely formatted table for a given workbook"
|
34
|
+
def table(workbook, sheet)
|
35
|
+
data = client.workbook_data(workbook, sheet)
|
36
|
+
rows = CSV.parse(data, :headers => true).to_a
|
37
|
+
puts Terminal::Table.new headings: rows[0], rows: rows[1..-1]
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def client user=nil, password=nil
|
44
|
+
@client = Datameer.new ENV['DATAMEER_URL'], user, password
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module Meer
|
2
|
+
class Datameer
|
3
|
+
attr_reader :uri, :user, :password
|
4
|
+
def initialize url, user=nil, password=nil
|
5
|
+
@uri, @user, @password = URI(url), user, password
|
6
|
+
|
7
|
+
@http = Net::HTTP.new uri.host, uri.port
|
8
|
+
@http.use_ssl = true if uri.port == 443
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
def request req
|
13
|
+
if [user, password].compact.size == 2
|
14
|
+
req.basic_auth self.user, self.password
|
15
|
+
else
|
16
|
+
req['Cookie'] = File.read('.session')
|
17
|
+
end
|
18
|
+
|
19
|
+
res = @http.request(req)
|
20
|
+
if res.code == '200'
|
21
|
+
res
|
22
|
+
else
|
23
|
+
puts "error fetching #{req.uri}"
|
24
|
+
puts res.code
|
25
|
+
puts res.to_hash
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def get url
|
30
|
+
req = Net::HTTP::Get.new(URI(uri.to_s + url))
|
31
|
+
request(req)
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
def login
|
36
|
+
resp = get('/browser')
|
37
|
+
|
38
|
+
if resp.code.to_i == 200
|
39
|
+
File.open('.session', 'w') { |f| f.puts resp['set-cookie'] }
|
40
|
+
puts "Logged In"
|
41
|
+
else
|
42
|
+
puts "Failed to log in"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
def workbook_data wb_id, sheet
|
48
|
+
res = get "/rest/data/workbook/#{wb_id}/#{sheet}/download"
|
49
|
+
res.body
|
50
|
+
end
|
51
|
+
|
52
|
+
def workbook wb_id
|
53
|
+
JSON.parse(get("/rest/workbook/#{wb_id}").body)
|
54
|
+
end
|
55
|
+
|
56
|
+
def workbooks
|
57
|
+
JSON.parse(get("/rest/workbook").body)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
data/lib/meer/version.rb
ADDED
data/lib/meer.rb
ADDED
data/meer.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'meer/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "meer"
|
8
|
+
spec.version = Meer::VERSION
|
9
|
+
spec.authors = ["philip.monroe"]
|
10
|
+
spec.email = ["philip.monroe@workday.com"]
|
11
|
+
spec.summary = %q{CLI for datameer}
|
12
|
+
spec.description = %q{CLI for datameer}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency "highline"
|
22
|
+
spec.add_runtime_dependency "thor"
|
23
|
+
spec.add_runtime_dependency "terminal-table"
|
24
|
+
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: meer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- philip.monroe
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-05-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: highline
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: thor
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: terminal-table
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
description: CLI for datameer
|
70
|
+
email:
|
71
|
+
- philip.monroe@workday.com
|
72
|
+
executables:
|
73
|
+
- meer
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- Gemfile
|
79
|
+
- Gemfile.lock
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/meer
|
84
|
+
- lib/meer.rb
|
85
|
+
- lib/meer/cli.rb
|
86
|
+
- lib/meer/datameer.rb
|
87
|
+
- lib/meer/version.rb
|
88
|
+
- meer.gemspec
|
89
|
+
homepage: ''
|
90
|
+
licenses:
|
91
|
+
- MIT
|
92
|
+
metadata: {}
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options: []
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
requirements: []
|
108
|
+
rubyforge_project:
|
109
|
+
rubygems_version: 2.4.5
|
110
|
+
signing_key:
|
111
|
+
specification_version: 4
|
112
|
+
summary: CLI for datameer
|
113
|
+
test_files: []
|