meer 0.0.1 → 0.0.2

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: 7a2c5ce58df0cef1c015eae2cdeb15886908eb1a
4
- data.tar.gz: d7dab6a18350b5d4838c2b700ecc3ebe76a52d7a
3
+ metadata.gz: 38ca37a6d0a8186dc51fc2d3baf9a2831eec36ae
4
+ data.tar.gz: a173d2b80ed03d67853b27877f744e40bcb46f11
5
5
  SHA512:
6
- metadata.gz: e622dba69a402f5d94eee8c125654a8428312943ebc15defcb97749d9a3c78a070aa76af7ef3d25b5a7cc06356ae88b294a77a41e00c2042862d62a42ea3beda
7
- data.tar.gz: febd4bdf3f204fe2defdac79735b070f14c10403ec1255c1fd0ddd1fe8e0a11a32fd36537b80f9fb205c7fd0f3dd52440bef851001fe572c8528532e7f71c8ad
6
+ metadata.gz: bff7fe8300067e0da33232960f1cf5678a91f1c642e863a3693d8e60523b18a75e55a69f61c9ad830679b3465985f284af94b5051ac253b33391cf0a6bc5e36f
7
+ data.tar.gz: eaec7d3c38a04d79ca3a29f9b637105d8992f9f35689b78deb677bdd5b563b20887d6a69f4ec79fac4bc861d5fd469291d7b54c9c056a2d608a8c5ddde1ae76f
data/README.md CHANGED
@@ -1,30 +1,69 @@
1
1
  # Meer
2
2
 
3
- TODO: Write a gem description
3
+ A CLI utility for interacting with Datameer
4
4
 
5
5
  ## Installation
6
6
 
7
- Add this line to your application's Gemfile:
7
+ gem install meer
8
8
 
9
- ```ruby
10
- gem 'meer'
9
+ ## Usage
10
+
11
+ ``` shell
12
+ $ meer help
13
+
14
+ Commands:
15
+ meer csv # outputs the CSV for a given workbook
16
+ meer help [COMMAND] # Describe available commands or one specific command
17
+ meer login # logs into datameer for quick access
18
+ meer sheets # lists all sheets in a workbook
19
+ meer table # outputs a nicely formatted table for a given workbook
20
+ meer workbooks # lists all workbooks
11
21
  ```
12
22
 
13
- And then execute:
23
+ First thing you will want to do is login to datameer from the CLI. This will store your session id as a file in `~/.dmsession` so that you can interact with Datameer constantly typing credentials.
14
24
 
15
- $ bundle
25
+ ``` shell
26
+ $ meer login
27
+ username: (user.name)
28
+ password:
29
+ Logged In
30
+ ```
16
31
 
17
- Or install it yourself as:
32
+ Then you can start working with the data in Datameer like so
18
33
 
19
- $ gem install meer
34
+ ``` bash
35
+ $ meer workbook
36
+ - [1] /foo.wbk
37
+ - [2] /test.wbk
38
+
39
+ $ meer sheets 1
40
+ - sheet_1
41
+ - sheet_2
42
+ - sheet_foo
43
+
44
+ $ meer csv 1 sheet_foo
45
+ "foo","bar","baz"
46
+ 1,2,3
47
+ 4,5,6
48
+ 7,8,9
20
49
 
21
- ## Usage
22
50
 
23
- TODO: Write usage instructions here
51
+ $ meer table 1 sheet_foo
52
+ +--------+--------+--------+
53
+ | foo | bar | baz |
54
+ +--------+--------+--------+
55
+ | 1 | 2 | 3 |
56
+ +--------+--------+--------+
57
+ | 4 | 5 | 6 |
58
+ +--------+--------+--------+
59
+ | 7 | 8 | 9 |
60
+ +--------+--------+--------+
61
+ ```
62
+
24
63
 
25
64
  ## Contributing
26
65
 
27
- 1. Fork it ( https://github.com/[my-github-username]/meer/fork )
66
+ 1. Fork it ( https://github.com/phil-monroe/meer/fork )
28
67
  2. Create your feature branch (`git checkout -b my-new-feature`)
29
68
  3. Commit your changes (`git commit -am 'Add some feature'`)
30
69
  4. Push to the branch (`git push origin my-new-feature`)
data/lib/meer/datameer.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'fileutils'
2
+
1
3
  module Meer
2
4
  class Datameer
3
5
  attr_reader :uri, :user, :password
@@ -13,7 +15,7 @@ module Meer
13
15
  if [user, password].compact.size == 2
14
16
  req.basic_auth self.user, self.password
15
17
  else
16
- req['Cookie'] = File.read('.session')
18
+ req['Cookie'] = Session.load
17
19
  end
18
20
 
19
21
  res = @http.request(req)
@@ -36,7 +38,7 @@ module Meer
36
38
  resp = get('/browser')
37
39
 
38
40
  if resp.code.to_i == 200
39
- File.open('.session', 'w') { |f| f.puts resp['set-cookie'] }
41
+ Session.set(resp['set-cookie'])
40
42
  puts "Logged In"
41
43
  else
42
44
  puts "Failed to log in"
@@ -56,5 +58,19 @@ module Meer
56
58
  def workbooks
57
59
  JSON.parse(get("/rest/workbook").body)
58
60
  end
61
+
62
+ module Session
63
+ SESSION_FILE = File.expand_path('~/.dmsession')
64
+
65
+ def self.set(cookie)
66
+ FileUtils.rm_f SESSION_FILE
67
+ File.open(SESSION_FILE, 'w') { |f| f.puts cookie }
68
+ File.chmod(0400, SESSION_FILE)
69
+ end
70
+
71
+ def self.load
72
+ File.read(SESSION_FILE) if File.exist?(SESSION_FILE)
73
+ end
74
+ end
59
75
  end
60
76
  end
data/lib/meer/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Meer
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
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.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - philip.monroe