refocus 0.1.4 → 0.1.5

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: 29e511a576db53916cd93b5a32c1fbb62b2171e5
4
- data.tar.gz: 975c4fa9a9ddd4935253e1b44d9e63cbef97f706
3
+ metadata.gz: 8c9a284d38f4ea7b2511f08c99a9cbf3b523bd35
4
+ data.tar.gz: fafad4af4d8745213791e7106105148cd150e9a0
5
5
  SHA512:
6
- metadata.gz: 555c420afa099c429ec8e2aa4a235df161a2b9845f5aa5610423c3196a47578b77d82e46fb79476ceb8fa4ee8b37673cab1fa2609a9899a163fdb5fe7a67bd43
7
- data.tar.gz: 8c0f72d975a9434ba1b857536ee7f541d90a46437bd0f0cd070c4e1b7586691db73823dedf01a4743a8e161f5cce447da7a74d72f634fe587165214556d3353e
6
+ metadata.gz: 64a82a247bcdb07a279a0c22b176f4a7fcb069142309e215e60b9be36d22dbaa42da16788c8fa8e6612af2b40a249c9ce94aba2f0a5c32f5c103bf875985c77a
7
+ data.tar.gz: 9fcd0ada00e4ddae41be0d74b89ec3960b57f56cb3d7ca42fe48b2217fa0a0580dcaafbac085aa360b7592fd4757c10b0c1845087234540b247b33fdbd1e6a0c
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- refocus (0.1.3)
5
- clamp
6
- excon
4
+ refocus (0.1.5)
5
+ clamp (~> 1.1)
6
+ excon (~> 0.60)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
@@ -36,7 +36,7 @@ PLATFORMS
36
36
 
37
37
  DEPENDENCIES
38
38
  bundler (~> 1.16)
39
- pry
39
+ pry (~> 0.11)
40
40
  rake (~> 10.0)
41
41
  refocus!
42
42
  rspec (~> 3.0)
@@ -1,18 +1,23 @@
1
+ require "refocus/cli/base"
1
2
  module Refocus
2
- class AspectsDeleteCommand< Clamp::Command
3
- parameter "ASPECT", "aspect to delete"
4
3
 
4
+ class AspectsGetCommand < BaseCommand
5
+ parameter "ASPECT", "aspect to describe"
5
6
  def execute
6
- refocus.aspects.delete(name: aspect)
7
+ puts JSON.pretty_generate(aspects.get(name: aspect))
7
8
  end
9
+ end
8
10
 
9
- def refocus
10
- Refocus.client
11
+ class AspectsDeleteCommand< BaseCommand
12
+ parameter "ASPECT", "aspect to delete"
13
+ def execute
14
+ aspects.delete(name: aspect)
11
15
  end
12
16
  end
13
17
 
14
18
  Cli.class_eval do
15
19
  subcommand "aspects:delete", "Delete an aspect", Refocus::AspectsDeleteCommand
20
+ subcommand "aspects:get", "Get an aspect. Prints out JSON.", Refocus::AspectsGetCommand
16
21
  end
17
22
  end
18
23
 
@@ -0,0 +1,21 @@
1
+ require "clamp"
2
+
3
+ module Refocus
4
+ class BaseCommand < Clamp::Command
5
+ def refocus
6
+ Refocus.client
7
+ end
8
+
9
+ def aspects
10
+ Refocus.client.aspects
11
+ end
12
+
13
+ def subjects
14
+ Refocus.client.subjects
15
+ end
16
+
17
+ def samples
18
+ Refocus.client.samples
19
+ end
20
+ end
21
+ end
@@ -1,9 +1,10 @@
1
1
  require "refocus/cli"
2
+ require "refocus/cli/base"
2
3
  require "json"
3
4
  require "yaml"
4
5
 
5
6
  module Refocus
6
- class ResourcesSyncCommand < Clamp::Command
7
+ class ResourcesSyncCommand < BaseCommand
7
8
 
8
9
  option(["-a", "--action"], "ACTION", "action to perform: create or update", default: "create") do |s|
9
10
  (raise ArgumentError, "Invalid action: #{s}") unless %w{create update}.include?(s)
@@ -11,15 +12,15 @@ module Refocus
11
12
  end
12
13
 
13
14
  def execute
14
- subjects.each do |subject|
15
- refocus.subjects.send(action, {
15
+ input_subjects.each do |subject|
16
+ subjects.send(action, {
16
17
  name: subject.fetch("name"),
17
18
  options: subject.fetch("properties")
18
19
  })
19
20
  end
20
21
 
21
- aspects.each do |aspect|
22
- refocus.aspects.send(action, {
22
+ input_aspects.each do |aspect|
23
+ aspects.send(action, {
23
24
  name: aspect.fetch("name"),
24
25
  options: aspect.fetch("properties")
25
26
  })
@@ -30,17 +31,13 @@ module Refocus
30
31
  @input ||= YAML.safe_load(STDIN.read)
31
32
  end
32
33
 
33
- def subjects
34
+ def input_subjects
34
35
  input["subjects"] || []
35
36
  end
36
37
 
37
- def aspects
38
+ def input_aspects
38
39
  input["aspects"] || []
39
40
  end
40
-
41
- def refocus
42
- Refocus.client
43
- end
44
41
  end
45
42
 
46
43
  Cli.class_eval do
@@ -1,15 +1,30 @@
1
1
  require "refocus/cli"
2
+ require "refocus/cli/base"
2
3
  require "json"
3
4
 
4
5
  module Refocus
5
- class GetSampleCommand < Clamp::Command
6
-
7
- option ["-s", "--subject"], "SUBJECT", "subject to get a sample for", required: true
8
- option ["-a", "--aspect"], "ASPECT", "aspect to get a sample for", required: true
6
+ class GetSampleCommand < BaseCommand
7
+ parameter "SAMPLE", "Sample to get, in the format SUBJECT|SAMPLE. Use quotes to avoid bash interpreting |." do |s|
8
+ s.tap do |s|
9
+ (raise ArgumentError, "Invalid sample: #{s}") unless s.split("|").size == 2
10
+ end
11
+ end
9
12
 
10
13
  def execute
11
14
  puts JSON.pretty_generate(Refocus.client.samples.get(subject: subject, aspect: aspect))
12
15
  end
16
+
17
+ def sample_array
18
+ sample.split("|")
19
+ end
20
+
21
+ def subject
22
+ sample_array.first
23
+ end
24
+
25
+ def aspect
26
+ sample_array.last
27
+ end
13
28
  end
14
29
 
15
30
  Cli.class_eval do
@@ -1,18 +1,21 @@
1
1
  module Refocus
2
- class SubjectsDeleteCommand< Clamp::Command
3
- parameter "SUBJECT", "subject to delete"
4
2
 
3
+ class SubjectsGetCommand < BaseCommand
4
+ parameter "SUBJECT", "subject to describe"
5
5
  def execute
6
- refocus.subjects.delete(name: subject)
6
+ puts JSON.pretty_generate(refocus.subjects.get(name: subject))
7
7
  end
8
+ end
8
9
 
9
- def refocus
10
- Refocus.client
10
+ class SubjectsDeleteCommand < BaseCommand
11
+ parameter "SUBJECT", "subject to delete"
12
+ def execute
13
+ refocus.subjects.delete(name: subject)
11
14
  end
12
15
  end
13
16
 
14
17
  Cli.class_eval do
15
18
  subcommand "subjects:delete", "Delete a subject", Refocus::SubjectsDeleteCommand
16
- end
17
- end
19
+ subcommand "subjects:get", "Get a subject. Prints out JSON.", Refocus::SubjectsGetCommand
20
+ end end
18
21
 
@@ -1,3 +1,3 @@
1
1
  module Refocus
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency "bundler", "~> 1.16"
24
24
  spec.add_development_dependency "rake", "~> 10.0"
25
25
  spec.add_development_dependency "rspec", "~> 3.0"
26
- spec.add_development_dependency "pry"
27
- spec.add_dependency "excon"
28
- spec.add_dependency "clamp"
26
+ spec.add_development_dependency "pry", "~> 0.11"
27
+ spec.add_dependency "excon", "~> 0.60"
28
+ spec.add_dependency "clamp", "~> 1.1"
29
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: refocus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Shea
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-19 00:00:00.000000000 Z
11
+ date: 2018-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -56,44 +56,44 @@ dependencies:
56
56
  name: pry
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: '0.11'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: '0.11'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: excon
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: '0.60'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0'
82
+ version: '0.60'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: clamp
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: '1.1'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: '1.1'
97
97
  description: Ruby client for https://github.com/salesforce/refocus
98
98
  email:
99
99
  - michael.shea@heroku.com
@@ -117,6 +117,7 @@ files:
117
117
  - lib/refocus/aspects.rb
118
118
  - lib/refocus/cli.rb
119
119
  - lib/refocus/cli/aspects.rb
120
+ - lib/refocus/cli/base.rb
120
121
  - lib/refocus/cli/resources.rb
121
122
  - lib/refocus/cli/samples.rb
122
123
  - lib/refocus/cli/subjects.rb
@@ -150,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
151
  version: '0'
151
152
  requirements: []
152
153
  rubyforge_project:
153
- rubygems_version: 2.5.1
154
+ rubygems_version: 2.5.2.1
154
155
  signing_key:
155
156
  specification_version: 4
156
157
  summary: Refocus ruby client