refocus 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3796fbad7b14d1d5e154aa27c0e08575328adeba
4
- data.tar.gz: f57ed90a8d676a6696f09aaed4ff69ceec132444
3
+ metadata.gz: ffbe55500e7ba82291cf038d936dd0e535558733
4
+ data.tar.gz: 5c6036bbf3f0129c8f8efc8a5a7158a2647d38ce
5
5
  SHA512:
6
- metadata.gz: 36ca0a7d8c64123146c495fc748aea3b897f7def80eb55b509f784b03d9b2f76bced23862548e52bf6d825a7540d21397ad138e6679949661e26fbe0a657e831
7
- data.tar.gz: c92068f6462416c11ea47a403c327555b30741f51a4ead800ed2001cdda5c25ec49fb8df581fea6c2c0843c62224abf42a5a3ae652bd54a5508c3f081b38c8a6
6
+ metadata.gz: 82b3b152fc392f96d270595bd2770c89d0a8c00b3d7fe1dcf0e839e5571560f73311dde0474953794d856fc2fe9b209ebda36b219aa5b66ed7c59568b8cee7bd
7
+ data.tar.gz: d4adfbed9581257df45ba067ecdf8801b9e5c9bf2de906766ea80718986217a3fcfd08fe04248dd89c3ac2eaf38af6c4582708993cc7f60ec7c713314dda43a5
data/.gitignore CHANGED
@@ -9,3 +9,4 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+ *.gem
@@ -1,9 +1,11 @@
1
1
  require "refocus/http"
2
2
  require "refocus/json_helper"
3
+ require "refocus/path_helper"
3
4
 
4
5
  module Refocus
5
6
  class Aspects
6
7
  include JsonHelper
8
+ include PathHelper
7
9
 
8
10
  attr_reader :http
9
11
 
@@ -15,9 +17,10 @@ module Refocus
15
17
  json(http.get(""))
16
18
  end
17
19
 
18
- def create(parent: nil, name:, options: {} )
20
+ def create(name:, options: {} )
21
+ parent, child = parent_and_name(name)
19
22
  path = parent ? "#{parent}/child" : ""
20
- body = default_options.merge("name" => name).merge(options)
23
+ body = default_options.merge("name" => child).merge(options)
21
24
  json(http.post(path, body: body))
22
25
  end
23
26
 
data/lib/refocus/http.rb CHANGED
@@ -17,6 +17,14 @@ module Refocus
17
17
  connection(path).get(headers: headers, expects: 200)
18
18
  end
19
19
 
20
+ def patch(path, body:)
21
+ connection(path).put(body: convert(body), headers: headers, expects: 201)
22
+ end
23
+
24
+ def put(path, body:)
25
+ connection(path).put(body: convert(body), headers: headers, expects: 201)
26
+ end
27
+
20
28
  def delete(path)
21
29
  connection(path).delete(headers: headers, expects: 200)
22
30
  end
@@ -0,0 +1,12 @@
1
+ module Refocus
2
+ module PathHelper
3
+ # Given a dot-separated string, returns the parent and name.
4
+ # Returns nil for parent if there are no dots.
5
+ def parent_and_name(name)
6
+ array = name.split(".")
7
+ parent = array.length == 1 ? nil : array[0..-2].join(".")
8
+ name = array[-1]
9
+ [parent, name]
10
+ end
11
+ end
12
+ end
@@ -1,9 +1,11 @@
1
1
  require "refocus/http"
2
2
  require "refocus/json_helper"
3
+ require "refocus/path_helper"
3
4
 
4
5
  module Refocus
5
6
  class Subjects
6
7
  include JsonHelper
8
+ include PathHelper
7
9
 
8
10
  attr_reader :http
9
11
 
@@ -15,9 +17,10 @@ module Refocus
15
17
  json(http.get(""))
16
18
  end
17
19
 
18
- def create(parent: nil, name:, options: {})
20
+ def create(name:, options: {})
21
+ parent, child = parent_and_name(name)
19
22
  path = parent ? "#{parent}/child" : ""
20
- body = options.merge({"name" => name})
23
+ body = options.merge({"name" => child})
21
24
  json(http.post(path, body: body))
22
25
  end
23
26
 
@@ -1,3 +1,3 @@
1
1
  module Refocus
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: refocus
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
  - Michael Shea
@@ -102,6 +102,7 @@ files:
102
102
  - lib/refocus/client.rb
103
103
  - lib/refocus/http.rb
104
104
  - lib/refocus/json_helper.rb
105
+ - lib/refocus/path_helper.rb
105
106
  - lib/refocus/perspectives.rb
106
107
  - lib/refocus/samples.rb
107
108
  - lib/refocus/samples/collector.rb