hubs3d 0.0.1 → 0.1.0

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: 559f60efc7b85dae84b93b800c790cd3ff9bd646
4
- data.tar.gz: 39a40028d8fa6c25a89bfe2fd096ff83e90ffa8a
3
+ metadata.gz: 6b984a6af7ce4d5ac992157348261ed66441d5a1
4
+ data.tar.gz: b203fda414d4590c8ff2c4cd847ce8e55020356f
5
5
  SHA512:
6
- metadata.gz: 1f2402f78e2d8f09361d507ac34b0e1a4a812e6fb4e814cbe076d4516f61b4116ffcf07410ba857a973f7330f7e2dcedd587e1ee9643259430e3f5a0f9a99d8b
7
- data.tar.gz: 7cc411fe00ba12822a8a0c297c447969cdd83518fd2773c2bdffdaa824ec73ea600f6d8799d025627d6d142990dea86529484f2063b128692cd7e4fe3b228a4e
6
+ metadata.gz: 11e09f5c6847ea09e86428b7345b736c8d20cfcc922e08c3d97a67308d508c918b884e5d0f263435dcdaa11283777c35d579d76a6eb711448b22fc72b5bb70e6
7
+ data.tar.gz: 7a7abc828b13b019d04f7c95ea28378f65d16e38b8bb913b87083a9971f9c11fe41602abcc6f093e2cd65a7fc283ee0d3fea8eac5ec12371084276328474eda9
data/README.md CHANGED
@@ -37,7 +37,7 @@ Development
37
37
  To launch specs:
38
38
 
39
39
  ```sh
40
- $ rake
40
+ $ bundle exec rspec
41
41
  ```
42
42
 
43
43
 
data/lib/hubs3d/cart.rb CHANGED
@@ -2,10 +2,13 @@ require "hubs3d/api"
2
2
 
3
3
  module Hubs3D
4
4
  class Cart
5
- attr_reader :items
5
+ attr_reader :items, :designer_tip, :third_party_id
6
6
 
7
- def initialize
7
+ def initialize(designer_tip: nil,
8
+ third_party_id: nil)
8
9
  @items = []
10
+ @designer_tip = designer_tip
11
+ @third_party_id = third_party_id
9
12
  end
10
13
 
11
14
  def <<(item)
@@ -27,7 +30,9 @@ module Hubs3D
27
30
  hash[item.id] = { modelId: item.id, quantity: 1 }
28
31
  end
29
32
 
30
- API.post("/cart", items: hash)
33
+ API.post("/cart", items: hash,
34
+ designer_tip: designer_tip && designer_tip.to_h,
35
+ third_party_id: third_party_id)
31
36
  end
32
37
  end
33
38
  end
data/lib/hubs3d/model.rb CHANGED
@@ -3,11 +3,16 @@ require "hubs3d/api"
3
3
 
4
4
  module Hubs3D
5
5
  class Model
6
- attr_accessor :id, :name, :path
7
- def initialize(id: nil, name: nil, path: nil)
6
+ attr_reader :name, :path, :attachments
7
+
8
+ def initialize(id: nil,
9
+ name: nil,
10
+ path: nil,
11
+ attachments: nil)
8
12
  @id = id
9
13
  @name = name
10
14
  @path = path
15
+ @attachments = attachments
11
16
  end
12
17
 
13
18
  def id
@@ -22,7 +27,9 @@ module Hubs3D
22
27
  end
23
28
 
24
29
  def post
25
- API.post("/model", file: base_64, fileName: name)
30
+ API.post("/model", file: base_64,
31
+ fileName: name,
32
+ attachments: attachments)
26
33
  end
27
34
  end
28
35
  end
data/lib/hubs3d/tip.rb ADDED
@@ -0,0 +1,19 @@
1
+ module Hubs3D
2
+ class Tip
3
+ attr_reader :amount, :currency, :uuid, :mandatory
4
+
5
+ def initialize(amount: nil,
6
+ currency: nil,
7
+ uuid: nil,
8
+ mandatory: nil)
9
+ @amount = amount
10
+ @currency = currency
11
+ @uuid = uuid
12
+ @mandatory = mandatory
13
+ end
14
+
15
+ def to_h
16
+ { amount: amount, currency: currency, uuid: uuid, mandatory: mandatory }
17
+ end
18
+ end
19
+ end
@@ -1,3 +1,3 @@
1
1
  module Hubs3D
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
data/spec/api_spec.rb CHANGED
@@ -14,8 +14,8 @@ describe Hubs3D::API do
14
14
  })
15
15
  .to_return(status: 200, body: '{ "answer": 42 }')
16
16
 
17
- post = Hubs3D::API.post("/some/path", foo: "bar")
18
- post.must_equal({ "answer" => 42 })
17
+ post = described_class.post("/some/path", foo: "bar")
18
+ expect(post).to eq("answer" => 42)
19
19
  end
20
20
  end
21
21
  end
data/spec/cart_spec.rb CHANGED
@@ -1,13 +1,31 @@
1
1
  require "spec_helper"
2
2
  require "hubs3d/cart"
3
+ require "hubs3d/tip"
3
4
 
4
5
  describe Hubs3D::Cart do
5
- let(:cart) { Hubs3D::Cart.new }
6
- let(:item) { Minitest::Mock.new }
6
+ let(:designer_tip) { Hubs3D::Tip.new(amount: 42_00,
7
+ currency: "EUR",
8
+ uuid: 5,
9
+ mandatory: true) }
10
+ let(:cart) { described_class.new(designer_tip: designer_tip,
11
+ third_party_id: "foo0") }
12
+ let(:item) { double(:item, id: 42) }
13
+
14
+ describe "#designer_tip" do
15
+ it "returns the designer_tip" do
16
+ expect(cart.designer_tip).to eq(designer_tip)
17
+ end
18
+ end
19
+
20
+ describe "#third_party_id" do
21
+ it "returns the third_party_id" do
22
+ expect(cart.third_party_id).to eq("foo0")
23
+ end
24
+ end
7
25
 
8
26
  describe "#items" do
9
27
  it "defaults to empty" do
10
- cart.items.empty?.must_equal true
28
+ expect(cart.items.empty?).to eq(true)
11
29
  end
12
30
  end
13
31
 
@@ -15,22 +33,40 @@ describe Hubs3D::Cart do
15
33
  it "adds items" do
16
34
  cart << item
17
35
  cart << item
18
- cart.items.size.must_equal 2
36
+ expect(cart.items.size).to eq(2)
19
37
  end
20
38
  end
21
39
 
22
40
  describe "#url" do
41
+ let(:api_result) { { "url" => "http://example" } }
42
+
23
43
  before do
44
+ allow(Hubs3D::API).to receive(:post) { api_result }
24
45
  cart << item
25
- item.expect :id, 42
26
- item.expect :id, 42
27
46
  end
28
47
 
29
- it "calls the API" do
30
- returned = { "url" => "http://example" }
31
- Hubs3D::API.stub :post, returned do
32
- cart.url.must_equal "http://example"
33
- end
48
+ it "calls the API with the correct args" do
49
+ cart.url
50
+ args = {
51
+ items: {
52
+ 42 => {
53
+ modelId: 42,
54
+ quantity: 1,
55
+ },
56
+ },
57
+ designer_tip: {
58
+ amount: 42_00,
59
+ currency: "EUR",
60
+ uuid: 5,
61
+ mandatory: true
62
+ },
63
+ third_party_id: "foo0",
64
+ }
65
+ expect(Hubs3D::API).to have_received(:post).with("/cart", args)
66
+ end
67
+
68
+ it "returns the url from the API" do
69
+ expect(cart.url).to eq("http://example")
34
70
  end
35
71
  end
36
72
  end
data/spec/model_spec.rb CHANGED
@@ -2,7 +2,20 @@ require "spec_helper"
2
2
  require "hubs3d/model"
3
3
 
4
4
  describe Hubs3D::Model do
5
- # pending "#id"
6
- # pending "#name"
7
- # pending "#path"
5
+ let(:model) { described_class.new(name: "Foo", path: "example.stl") }
6
+
7
+ describe "#name" do
8
+ it "returns the name" do
9
+ expect(model.name).to eq("Foo")
10
+ end
11
+ end
12
+
13
+ describe "#path" do
14
+ it "returns the path" do
15
+ expect(model.path).to eq("example.stl")
16
+ end
17
+ end
18
+
19
+ pending "#id"
20
+ pending "#attachments"
8
21
  end
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,4 @@
1
- require "minitest/autorun"
2
- require "webmock/minitest"
1
+ require "webmock/rspec"
3
2
 
4
3
  require "hubs3d/configuration"
5
4
 
data/spec/tip_spec.rb ADDED
@@ -0,0 +1,33 @@
1
+ require "spec_helper"
2
+ require "hubs3d/model"
3
+
4
+ describe Hubs3D::Tip do
5
+ let(:model) { described_class.new(amount: 42_00,
6
+ currency: "EUR",
7
+ uuid: "51",
8
+ mandatory: false) }
9
+
10
+ describe "#amount" do
11
+ it "returns the amount" do
12
+ expect(model.amount).to eq(42_00)
13
+ end
14
+ end
15
+
16
+ describe "#currency" do
17
+ it "returns the currency" do
18
+ expect(model.currency).to eq("EUR")
19
+ end
20
+ end
21
+
22
+ describe "#uuid" do
23
+ it "returns the uuid" do
24
+ expect(model.uuid).to eq("51")
25
+ end
26
+ end
27
+
28
+ describe "#mandatory" do
29
+ it "returns the mandatory" do
30
+ expect(model.mandatory).to eq(false)
31
+ end
32
+ end
33
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hubs3d
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sunny Ripert
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-23 00:00:00.000000000 Z
11
+ date: 2015-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  description: Upload 3D Models and create carts on 3DHubs
70
84
  email:
71
85
  - sunny@sunfox.org
@@ -81,12 +95,14 @@ files:
81
95
  - lib/hubs3d/cart.rb
82
96
  - lib/hubs3d/configuration.rb
83
97
  - lib/hubs3d/model.rb
98
+ - lib/hubs3d/tip.rb
84
99
  - lib/hubs3d/version.rb
85
100
  - spec/api_spec.rb
86
101
  - spec/cart_spec.rb
87
102
  - spec/fixtures/example.stl
88
103
  - spec/model_spec.rb
89
104
  - spec/spec_helper.rb
105
+ - spec/tip_spec.rb
90
106
  homepage: http://github.com/sunny/hubs3d
91
107
  licenses:
92
108
  - MIT
@@ -117,3 +133,4 @@ test_files:
117
133
  - spec/fixtures/example.stl
118
134
  - spec/model_spec.rb
119
135
  - spec/spec_helper.rb
136
+ - spec/tip_spec.rb