flowthings 0.1.3 → 0.1.4

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: df57d7b5ba229d83384f9aee0d7db3f5de4eecc5
4
- data.tar.gz: 8155a192a5af95b160a6fb43ad65d913a2a80cb7
3
+ metadata.gz: 2bcb7b80d3fae39964b12d431b1402ad09fa1602
4
+ data.tar.gz: 43543caf9dcb122073d217cab8bdd854adb1eb08
5
5
  SHA512:
6
- metadata.gz: 4e0894ba703afc9725c1887f903fbad2ca34a7932eea4820b3ba4306c84c7fbe712c087f4fc446ee496ac89b81d76cd8fa62b3c872f0e2acac3875f953486ba2
7
- data.tar.gz: e0dae677e044e14793cb878b0b91d33901bcc80a60a1a6c28b1edd4587b314071029873b38b0a42f079e1e8ab727a45eeb156f16f26d3c0ef2c6f479b58c748a
6
+ metadata.gz: b32768256a5b6d8c1de7f496a5902e461a3b7ef85eda3c13ba0720d17e88b5e1c56f95d139ed4cc3acbe8a99b8da021ebda65f29f5ac1159a77e8ca0f248fd15
7
+ data.tar.gz: 898beb5607198b7d81262a1d022ecff9000c5a75d9b527f4a9c0c0836429d41658b70fddcd77dfaa6c9578d9ad42a8bba4345ab3b025532fb419e880e379a099
@@ -43,8 +43,8 @@ module Flowthings
43
43
 
44
44
  if service_name == "drop"
45
45
  instance_eval <<-EOS
46
- def #{service_name}(flowId)
47
- #{service}.new flowId, connection, get_options
46
+ def #{service_name}(flow_id=nil)
47
+ #{service}.new flow_id, connection, get_options
48
48
  end
49
49
  EOS
50
50
  else
@@ -4,20 +4,22 @@ require 'flowthings/error'
4
4
 
5
5
  module Flowthings
6
6
  module Connection
7
-
8
7
  private
8
+
9
9
  def connection
10
10
  url = @endpoint
11
11
  if @secure
12
- url = "https://" + url
12
+ url = 'https://' + url
13
13
  else
14
- url = "http://" + url
14
+ url = 'http://' + url
15
15
  end
16
16
 
17
17
  @connection = Excon.new(url,
18
- headers: {"X-Auth-Token" => @account_token,
19
- "Content-Type" => "application/json"})
18
+ headers: {
19
+ 'X-Auth-Token' => @account_token,
20
+ 'Content-Type' => 'application/json',
21
+ 'User-Agent' => @user_agent
22
+ })
20
23
  end
21
-
22
24
  end
23
25
  end
@@ -13,7 +13,7 @@ module Flowthings
13
13
  platform_post path, data=data, params=params
14
14
  end
15
15
 
16
- def read(id, params={})
16
+ def read(id=nil, params={})
17
17
  path = mk_path id: id
18
18
  params = mk_params params
19
19
 
@@ -35,6 +35,17 @@ module Flowthings
35
35
  platform_delete path, params=params
36
36
  end
37
37
 
38
+ def read_many(ids, params={})
39
+ # read many is essentially a neutered version of find.
40
+ # this is largely unimplemented
41
+ path = mk_path
42
+ params = mk_params params
43
+
44
+ raise "This is not yet implemented"
45
+
46
+ platform_get path, params=params
47
+ end
48
+
38
49
  alias_method :delete, :destroy
39
50
  end
40
51
  end
@@ -4,7 +4,12 @@ module Flowthings
4
4
  module Crud
5
5
  module ExtendedMethods
6
6
  include Flowthings::CrudUtils
7
- def delete_all(params={})
7
+
8
+ def destroy_all(params={})
9
+ path = mk_path
10
+ params = mk_params params
11
+
12
+ platform_delete path, params=params
8
13
  end
9
14
 
10
15
  def find_many(filters={}, params={})
@@ -12,18 +17,20 @@ module Flowthings
12
17
  params = mk_params params
13
18
  data = []
14
19
 
15
- @flowIds.each do flowId
16
- if filters[flowId]
17
- data << {"flowId" => flowId,
18
- "params" => filters[flowId]}
20
+ @flow_ids.each do flow_id
21
+ if filters[flow_id]
22
+ data << {"flowId" => flow_id,
23
+ "params" => filters[flow_id]}
19
24
  else
20
- data << {"flowId" => flowId}
25
+ data << {"flowId" => flow_id}
21
26
  end
22
27
  end
23
28
 
24
29
 
25
30
  platform_mget path, data=data, params=params
26
31
  end
32
+
33
+ alias_method :delete_all, :destroy_all
27
34
  end
28
35
  end
29
36
  end
@@ -12,18 +12,26 @@ module Flowthings
12
12
  include Flowthings::Crud::MemberUpdate
13
13
  include Flowthings::Crud::Aggregate
14
14
 
15
- attr_accessor :flowId
15
+ attr_accessor :flow_id, :flow_ids
16
16
 
17
- def initialize(flowId, connection, options={})
18
- if flowId.kind_of? Array
19
- @flowIds = flowId
17
+ def initialize(flow_id, connection, options={})
18
+ if flow_id.kind_of? Array
19
+ @flow_ids = flow_id
20
20
  else
21
- @flowId = flowId
21
+ @flow_id = flow_id
22
22
  end
23
23
 
24
24
  super connection, options
25
25
  end
26
26
 
27
+ def create(data, params={})
28
+ if !data["path"] && !@flow_id
29
+ raise ArgumentError.new("You either need a path in the drop data, or the Drop instance needs a flow_id")
30
+ end
31
+
32
+ super data, params
33
+ end
34
+
27
35
  end
28
36
 
29
37
  end
@@ -20,8 +20,8 @@ module Flowthings
20
20
 
21
21
  path = [@platform_version, @account_name, service_path[self.class.name]]
22
22
 
23
- if @flowId
24
- path << @flowId
23
+ if @flow_id
24
+ path << @flow_id
25
25
  end
26
26
 
27
27
  if params[:id]
@@ -1,3 +1,3 @@
1
1
  module Flowthings
2
- VERSION = "0.1.3"
2
+ VERSION = '0.1.4'
3
3
  end
data/spec/client_spec.rb CHANGED
@@ -28,20 +28,6 @@ describe Flowthings::Client do
28
28
  end
29
29
  end
30
30
 
31
- if service == 'drop'
32
- it "should throw an error if it is called without an argument" do
33
- expect { @api.send("#{service}") }.to raise_error
34
- end
35
-
36
- it "should raise an argument error" do
37
- expect { @api.send("#{service}") }.to raise_error(ArgumentError)
38
- end
39
-
40
- it "should not throw an error if it is called with an argument" do
41
- expect { @api.send("#{service}", "d") }.not_to raise_error
42
- end
43
- end
44
-
45
31
  end # describe block
46
32
 
47
33
  end # services loop
@@ -18,7 +18,7 @@ describe Flowthings::Drop do
18
18
  describe ".get" do
19
19
  it "should get the proper information from the platform" do
20
20
  api = Flowthings::Client.new({account_name: "greg",
21
- account_token: "p2lAhiLuQeqWN0EMeClmTAYPjgPy"})
21
+ account_token: "3PxWefluMlQeMtFpy9WPGkeijU5G"})
22
22
 
23
23
  result = {
24
24
  "id" => "d551720070cf25d405fb1e495",
@@ -93,6 +93,27 @@ describe Flowthings::Drop do
93
93
  expect(destroy_response.empty?).to be true
94
94
  end
95
95
 
96
+ it "should create a flow with a path and no flow_id" do
97
+ @drop["path"] = @path
98
+
99
+ create_response = @api.drop.create @drop
100
+ expect(create_response.empty?).not_to be true
101
+ expect(create_response["flowId"]).to eq(@flowId)
102
+ expect(create_response["elems"]).to eq(@drop["elems"])
103
+ end
104
+
105
+ it "should error if it does not have a path or a flow_id" do
106
+ expect {
107
+ @api.drop.create @drop
108
+ }.to raise_error
109
+ end
110
+
111
+ it "should be an argument error" do
112
+ expect {
113
+ @api.drop.create @drop
114
+ }.to raise_error(ArgumentError)
115
+ end
116
+
96
117
  end
97
118
 
98
119
  describe ".aggregate" do
@@ -13,7 +13,7 @@ describe Flowthings::Flow do
13
13
  describe ".read" do
14
14
  it "should get the proper information from the platform" do
15
15
  api = Flowthings::Client.new({account_name: 'greg',
16
- account_token: "p2lAhiLuQeqWN0EMeClmTAYPjgPy"})
16
+ account_token: "3PxWefluMlQeMtFpy9WPGkeijU5G"})
17
17
 
18
18
  response = {"id" => "f55171ff90cf2ece6103ef410",
19
19
  "capacity" => 1000,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flowthings
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Meyer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-07-13 00:00:00.000000000 Z
11
+ date: 2015-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport