mind_meld 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/mind_meld +52 -9
  3. data/lib/mind_meld.rb +1 -0
  4. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e7b9ee29cd21ea6c2e0ff1b017839b960b1d9af8
4
- data.tar.gz: c82d8435c583863afd8a3f8b90235f77c928e82a
3
+ metadata.gz: a9a58f290eec9c50837d4178728b9b2f4c4e3423
4
+ data.tar.gz: af0060bb12091a28e5d08b4aa42f058a19d81836
5
5
  SHA512:
6
- metadata.gz: 999d3e342c8b79f74993fc1ad308781ae780fddd8d1fab752ac59fc5f7280ac4e92027b5b6b79bd718b7afef2143bd5c5dae2a4331bcbb525133a76e2212a58f
7
- data.tar.gz: ced83fc98284262ee4c24f03302d2754246046a97b8ba11f1575ea390688adeb7e4188c02f85388ef1067a60e54cd38a93ef72b8b3046900f3c817bd7b132f82
6
+ metadata.gz: 93837946b3e466d5ba5e2d5c006ee726321cf61c8eed0efe2d4669e5a3722a12494109e0558ee9902f49afe10859af1b256fb15629dc6cbbe06e697e20b0ec66
7
+ data.tar.gz: 02e8d4185a62c86ac13f3678a60cec7815dc47c1581046e4628df1b294ab8f0099c46c3722f75e70b1fe17e3fcba133b9319423b548d20831c00fe0a1d7095e6
data/bin/mind_meld CHANGED
@@ -6,23 +6,66 @@ ENV['BUNDLE_GEMFILE'] ||= File.expand_path(
6
6
  Pathname.new(__FILE__).realpath
7
7
  )
8
8
 
9
+ require 'optparse'
10
+ require 'ostruct'
11
+
9
12
  $LOAD_PATH << File.expand_path('../../lib', __FILE__)
10
13
  require 'mind_meld'
14
+ require 'mind_meld/device'
11
15
 
12
16
  url = ENV['HIVEMIND_URL'] || 'http://localhost:3000'
13
17
  pem = ENV['HIVEMIND_PEM'] || nil
14
18
  ca_file = ENV['HIVEMIND_CAFILE'] || nil
15
19
  verify_mode = ENV['HIVEMIND_VERIFY_MODE'] || nil
16
20
 
17
- mm = MindMeld.new(
18
- url: url,
19
- pem: pem,
20
- ca_file: ca_file,
21
- verify_mode: verify_mode
22
- )
21
+ cmd = ARGV.shift
22
+
23
+ class Parser
24
+ def self.parse(type, opts = {})
25
+ connection = nil
26
+ options = OpenStruct.new
27
+
28
+ opt_parser = OptionParser.new do |opts|
29
+ opts.banner = "Usage: mind_meld action"
30
+ opts.on("-i ID") do |i|
31
+ connection = MindMeld::Device.new(
32
+ url: ENV['HIVEMIND_URL'] || 'http://localhost:3000',
33
+ pem: ENV['HIVEMIND_PEM'] || nil,
34
+ ca_file: ENV['HIVEMIND_CAFILE'] || nil,
35
+ verify_mode: ENV['HIVEMIND_VERIFY_MODE'] || nil,
36
+ device: { id: i }
37
+ )
38
+ end
39
+ opts.on("-t TYPE") { |t| options.action_type = t }
40
+ opts.on("-b BODY") { |b| options.body = b }
41
+ end
42
+
43
+ opt_parser.parse(opts)
44
+ return { connection: connection, options: options }
45
+ end
46
+ end
47
+
48
+ case cmd
49
+ when 'list'
50
+ mm = MindMeld.new(
51
+ url: url,
52
+ pem: pem,
53
+ ca_file: ca_file,
54
+ verify_mode: verify_mode
55
+ )
56
+
57
+ devs = mm.devices
23
58
 
24
- devs = mm.devices
59
+ devs.each do |dev|
60
+ puts "#{dev['id']}) #{dev['name']}"
61
+ end
62
+ when 'action'
63
+ opts = Parser.parse 'action', ARGV
25
64
 
26
- devs.each do |dev|
27
- puts "#{dev['id']}) #{dev['name']}"
65
+ opts[:connection].create_action( opts[:options].to_h )
66
+ when nil, /^-+/
67
+ puts "Missing command"
68
+ puts "(and missing help file)"
69
+ else
70
+ puts "Unknown command '#{cmd}'"
28
71
  end
data/lib/mind_meld.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'json'
2
2
  require 'net/http'
3
3
  require 'active_support/core_ext/object/to_query'
4
+ require 'openssl'
4
5
 
5
6
  class MindMeld
6
7
  def initialize options
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mind_meld
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Haig
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-01 00:00:00.000000000 Z
11
+ date: 2016-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -86,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
86
  version: '0'
87
87
  requirements: []
88
88
  rubyforge_project:
89
- rubygems_version: 2.5.0
89
+ rubygems_version: 2.5.1
90
90
  signing_key:
91
91
  specification_version: 4
92
92
  summary: API for Hive Mind