refocus 0.1.1 → 0.1.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: ffbe55500e7ba82291cf038d936dd0e535558733
4
- data.tar.gz: 5c6036bbf3f0129c8f8efc8a5a7158a2647d38ce
3
+ metadata.gz: 74f03cae9bfb4771dbf702946e7a28721687a213
4
+ data.tar.gz: 1191ca2edb1b09db54f68f3766792ca52644ebb3
5
5
  SHA512:
6
- metadata.gz: 82b3b152fc392f96d270595bd2770c89d0a8c00b3d7fe1dcf0e839e5571560f73311dde0474953794d856fc2fe9b209ebda36b219aa5b66ed7c59568b8cee7bd
7
- data.tar.gz: d4adfbed9581257df45ba067ecdf8801b9e5c9bf2de906766ea80718986217a3fcfd08fe04248dd89c3ac2eaf38af6c4582708993cc7f60ec7c713314dda43a5
6
+ metadata.gz: fb00a8ae1c20951017a799c78b4aa24aabfebbad4b794433573b3867ec5c89bdb97e34ff6eb51da60f325bca16b1c508c369adbdaa098107cbd14c29c2a1b795
7
+ data.tar.gz: 0fa6697556d2df01b23a2b44927ed2abff941038cef24e2de7a4e8da361c4fad63194c1d4afa4dd7428f3b563fc3197b923d0cc5e19887f71f805eb0a496fe9b
data/Gemfile.lock CHANGED
@@ -1,12 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- refocus (0.1.0)
4
+ refocus (0.1.1)
5
+ clamp
5
6
  excon
6
7
 
7
8
  GEM
8
9
  remote: https://rubygems.org/
9
10
  specs:
11
+ clamp (1.1.2)
10
12
  coderay (1.1.2)
11
13
  diff-lcs (1.3)
12
14
  excon (0.60.0)
data/bin/refocus ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ $: << File.join(File.dirname(__FILE__), "..", "lib")
3
+ require "refocus"
4
+ require "refocus/cli"
5
+
6
+ Refocus::Cli.run
@@ -24,6 +24,10 @@ module Refocus
24
24
  json(http.post(path, body: body))
25
25
  end
26
26
 
27
+ def update(name:, options: {} )
28
+ http.patch(name, body: options)
29
+ end
30
+
27
31
  def delete(name:)
28
32
  json(http.delete(name))
29
33
  end
@@ -0,0 +1,9 @@
1
+ require "clamp"
2
+
3
+ module Refocus
4
+ class Cli < Clamp::Command
5
+ end
6
+ end
7
+
8
+ require "refocus/cli/samples"
9
+
@@ -0,0 +1,20 @@
1
+ require "refocus/cli"
2
+ require "json"
3
+
4
+ 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
9
+
10
+ def execute
11
+ puts JSON.pretty_generate(Refocus.client.samples.get(subject: subject, aspect: aspect))
12
+ end
13
+ end
14
+
15
+ Cli.class_eval do
16
+ subcommand "samples:get", "Print a sample", GetSampleCommand
17
+ end
18
+ end
19
+
20
+
data/lib/refocus/http.rb CHANGED
@@ -9,8 +9,8 @@ module Refocus
9
9
  @content_type = content_type
10
10
  end
11
11
 
12
- def post(path, body:)
13
- connection(path).post(body: convert(body), headers: headers, expects: 201)
12
+ def post(path, body:, expects: 201)
13
+ connection(path).post(body: convert(body), headers: headers, expects: expects)
14
14
  end
15
15
 
16
16
  def get(path)
@@ -18,7 +18,7 @@ module Refocus
18
18
  end
19
19
 
20
20
  def patch(path, body:)
21
- connection(path).put(body: convert(body), headers: headers, expects: 201)
21
+ connection(path).patch(body: convert(body), headers: headers, expects: 200)
22
22
  end
23
23
 
24
24
  def put(path, body:)
@@ -1,6 +1,10 @@
1
1
  require "refocus/http"
2
+ require "refocus/json_helper"
3
+
2
4
  module Refocus
3
5
  class Samples
6
+ include JsonHelper
7
+
4
8
  attr_reader :http
5
9
 
6
10
  def initialize(url:, token:)
@@ -10,6 +14,22 @@ module Refocus
10
14
  def collector
11
15
  Collector.new(http: http)
12
16
  end
17
+
18
+ def submit(name:, aspect:, value:)
19
+ c = collector
20
+ c.add(name: name, aspect: aspect, value: value)
21
+ c.submit
22
+ end
23
+
24
+ def list(limit: nil)
25
+ params = ""
26
+ params = params + "?limit=#{limit}" if limit
27
+ json(http.get(params))
28
+ end
29
+
30
+ def get(subject:, aspect:)
31
+ json(http.get(URI.escape("#{subject}\|#{aspect}")))
32
+ end
13
33
  end
14
34
  end
15
35
 
@@ -14,7 +14,7 @@ module Refocus
14
14
  end
15
15
 
16
16
  def submit
17
- result = json(http.post("upsert/bulk", body: samples))
17
+ result = json(http.post("upsert/bulk", body: samples, expects: 200))
18
18
  samples.clear
19
19
  true
20
20
  end
@@ -28,6 +28,10 @@ module Refocus
28
28
  json(http.delete(name))
29
29
  end
30
30
 
31
+ def update(name:, options:)
32
+ json(http.patch(name, body: options))
33
+ end
34
+
31
35
  def get(name:)
32
36
  json(http.get(name))
33
37
  end
@@ -1,3 +1,3 @@
1
1
  module Refocus
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
data/refocus.gemspec CHANGED
@@ -25,4 +25,5 @@ Gem::Specification.new do |spec|
25
25
  spec.add_development_dependency "rspec", "~> 3.0"
26
26
  spec.add_development_dependency "pry"
27
27
  spec.add_dependency "excon"
28
+ spec.add_dependency "clamp"
28
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.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Shea
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-01-09 00:00:00.000000000 Z
11
+ date: 2018-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: clamp
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  description: Ruby client for https://github.com/salesforce/refocus
84
98
  email:
85
99
  - michael.shea@heroku.com
@@ -96,9 +110,12 @@ files:
96
110
  - README.md
97
111
  - Rakefile
98
112
  - bin/console
113
+ - bin/refocus
99
114
  - bin/setup
100
115
  - lib/refocus.rb
101
116
  - lib/refocus/aspects.rb
117
+ - lib/refocus/cli.rb
118
+ - lib/refocus/cli/samples.rb
102
119
  - lib/refocus/client.rb
103
120
  - lib/refocus/http.rb
104
121
  - lib/refocus/json_helper.rb