all3dp 0.1.4 → 1.0.0

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
- SHA1:
3
- metadata.gz: b0d9b8991308469a783565f55407edb1c92e8b1b
4
- data.tar.gz: e049dc0d67624b0c04930c3494b1cd0a685f8efe
2
+ SHA256:
3
+ metadata.gz: 2125550bedac1df4dfd975cbe52ace243a1a3f2a57bdd3246e47c3141c3982bc
4
+ data.tar.gz: 316d777dbdeed8f8c51303094bb9b08bc57301083d8af3a8dcd90da4ff803aa7
5
5
  SHA512:
6
- metadata.gz: 7ac68bdc12d3faf60fc4aad30b759626f09c1fa721fed2af32d10173b43922226d3c5cb1b0eb13213ddb4b2d09896473e96e8130d1c72c3de0232d903027f1d8
7
- data.tar.gz: 9090014f0a4cd835360549acfcbe306d2810bcfeda560df59da9e4ec2a1ec4d424fa51c29a9de254b03d2b3b7341812f819d804000fc23d3802492507b925481
6
+ metadata.gz: 6e85a12cdc7734e871cdb0752732ec33795277f18567437632425f080a410aa3fc6dc863caf7414c44b28d8cb953a8487d9ab6b9b7429a58dd7454d4339fee7a
7
+ data.tar.gz: 26b24337a9b00d290c20ee27e2c091a9dcca57121f22af9111853663a6ed17be4804624fbef259140695e68e9a13433b47c245418aa6f34514628be518fd8d9b
@@ -16,19 +16,6 @@ Style/TrailingCommaInHashLiteral:
16
16
  Style/TrailingCommaInArguments:
17
17
  EnforcedStyleForMultiline: consistent_comma
18
18
 
19
- Style/BlockDelimiters:
20
- EnforcedStyle: semantic
21
- FunctionalMethods:
22
- - before
23
- - let
24
- - let!
25
- - subject
26
- - watch
27
- - expect
28
- - git_source
29
-
30
- EnforcedStyleForMultiline: consistent_comma
31
-
32
19
  Style/BlockDelimiters:
33
20
  EnforcedStyle: semantic
34
21
  FunctionalMethods:
@@ -43,3 +30,18 @@ Style/BlockDelimiters:
43
30
  Metrics/BlockLength:
44
31
  Exclude:
45
32
  - spec/**/*
33
+
34
+ Lint/RaiseException:
35
+ Enabled: true
36
+
37
+ Lint/StructNewOverride:
38
+ Enabled: true
39
+
40
+ Style/HashEachMethods:
41
+ Enabled: true
42
+
43
+ Style/HashTransformKeys:
44
+ Enabled: true
45
+
46
+ Style/HashTransformValues:
47
+ Enabled: true
@@ -1,25 +1,33 @@
1
1
  # unreleased
2
2
 
3
- # 0.1.4
3
+ # v1.0.0
4
4
 
5
5
  Feature:
6
- - Raise a `All3DP::API::ServiceUnavailableError` on 503s
6
+ - Use the new `api.craftcloud3d.com` endpoint.
7
7
 
8
- # 0.1.3
8
+ Fix:
9
+ - Drop `http` gem dependency.
10
+
11
+ # v0.1.4
12
+
13
+ Feature:
14
+ - Raise a `All3DP::API::ServiceUnavailableError` on 503s.
15
+
16
+ # v0.1.3
9
17
 
10
18
  Feature:
11
- - Raise a `All3DP::API::GatewayTimeoutError` on 504s
19
+ - Raise a `All3DP::API::GatewayTimeoutError` on 504s.
12
20
 
13
- # 0.1.2
21
+ # v0.1.2
14
22
 
15
23
  Feature:
16
- - Raise a `All3DP::API::BadGatewayError` on 502s
24
+ - Raise a `All3DP::API::BadGatewayError` on 502s.
17
25
 
18
- # 0.1.1
26
+ # v0.1.1
19
27
 
20
- Patch:
21
- - Add response code to API errors
28
+ Fix:
29
+ - Add response code to API errors.
22
30
 
23
- # 0.1.0
31
+ # v0.1.0
24
32
 
25
33
  First version!
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # All3DP
2
2
 
3
- Ruby gem to send 3D files to the All3DP API.
3
+ Ruby gem to send 3D files to All3DP's
4
+ [Craftcloud](https://craftcloud3d.com/) 3D Printing Price Comparison
5
+ Service API.
4
6
 
5
7
  ## Installation
6
8
 
@@ -11,47 +13,49 @@ Add these line to your application's Gemfile:
11
13
  gem "all3dp"
12
14
  ```
13
15
 
14
- And then execute:
16
+ And then call:
15
17
 
16
- $ bundle
18
+ ```sh
19
+ $ bundle
20
+ ```
17
21
 
18
22
  ## Usage
19
23
 
20
24
  Give URLs of STL files to the API:
21
25
 
22
26
  ```rb
23
- configuration = All3DP::API.Configuration.create(
27
+ configuration = All3DP::Configuration.create(
24
28
  model_urls: ["http://wtf.sunfox.org/cults-logo.stl"],
25
29
  )
26
- configuration.url # => "https://print.all3dp.com/configuration/f00b4r…"
27
30
  ```
28
31
 
29
- You can then redirect your users to the given URL.
32
+ You can then redirect your users to the given URL:
33
+
34
+ ```rb
35
+ configuration.url # => "https://print.all3dp.com/configuration/f00b4r…"
36
+ ```
30
37
 
31
38
  ## Development
32
39
 
33
40
  After checking out the repo, run `bin/setup` to install dependencies. Then,
34
41
  run `rake` to run the tests and linter. You can also run `bin/console` for an
35
- interactive prompt that will allow you to experiment.
42
+ interactive prompt that will allow you to experiment with the API.
36
43
 
37
44
  ## Release
38
45
 
39
46
  To release a new version, update the version number in `version.rb`, update
40
- the `CHANGELOG.md`, commit, and then run `bundle exec rake release`, which will
41
- create a git tag for the version, push git commits and tags, and push the
42
- `.gem` file to [rubygems.org](https://rubygems.org).
47
+ the `CHANGELOG.md`, commit with a message like "v42.0.0", and then run
48
+ `bundle exec rake release`, which will create a git tag for the version,
49
+ push git commits and tags, and push the gem to
50
+ [rubygems.org](https://rubygems.org).
43
51
 
44
52
  ## Contributing
45
53
 
46
54
  Bug reports and pull requests are welcome on GitHub at
47
- https://github.com/sunny/all3dp. This project is intended to be a safe,
48
- welcoming space for collaboration, and contributors are expected to adhere
49
- to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
50
-
51
- ## Code of Conduct
55
+ https://github.com/sunny/all3dp.
52
56
 
53
- Everyone interacting in the All3dp project’s codebases, issue trackers,
54
- chat rooms and mailing lists is expected to follow the
57
+ This project is intended to be a safe, welcoming space for collaboration, and
58
+ contributors are expected to adhere to the
55
59
  [code of conduct](https://github.com/sunny/all3dp/blob/master/CODE_OF_CONDUCT.md).
56
60
 
57
61
  ## License
@@ -14,20 +14,17 @@ Gem::Specification.new do |spec|
14
14
  spec.description = "Send 3D files to the All3DP API"
15
15
  spec.homepage = "http://github.com/sunny/all3dp"
16
16
 
17
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f|
18
18
  f.match(%r{^(test|spec|features)/})
19
- end
19
+ }
20
20
  spec.bindir = "exe"
21
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
22
  spec.require_paths = ["lib"]
23
23
 
24
- spec.add_dependency "http", "2.0.0"
25
-
26
- spec.add_development_dependency "bundler", "~> 1.16"
27
- spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "bundler", "~> 2.0"
25
+ spec.add_development_dependency "rake", "~> 13.0"
28
26
  spec.add_development_dependency "rspec", "~> 3.0"
29
- spec.add_development_dependency "webmock", "~> 2.1"
27
+ spec.add_development_dependency "webmock", "~> 3.6"
30
28
  spec.add_development_dependency "rubocop", "~> 0.55"
31
29
  spec.add_development_dependency "httplog", "~> 1.0"
32
- spec.add_development_dependency "pry", "~> 0.11"
33
30
  end
@@ -11,7 +11,3 @@ HttpLog.configure do |config|
11
11
  config.log_headers = true
12
12
  config.color = { color: :yellow }
13
13
  end
14
-
15
- # Start console
16
- require "pry"
17
- Pry.start
data/bin/setup CHANGED
@@ -1,8 +1,4 @@
1
1
  #!/usr/bin/env bash
2
2
  set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
3
 
6
4
  bundle install
7
-
8
- # Do any other automated setup that you need to do here
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "http"
3
+ require "net/http"
4
+ require "uri"
5
+ require "json"
4
6
 
5
7
  require "all3dp/version"
6
8
  require "all3dp/api"
@@ -9,36 +9,40 @@ module All3DP
9
9
  class ServiceUnavailableError < Error; end
10
10
 
11
11
  def create_configuration(items:)
12
- url = "#{BASE_URL}/configuration"
13
- response = HTTP.post(
14
- url,
15
- headers: { "use-model-urls" => true },
16
- json: { items: items },
17
- )
18
-
19
- parse_response(response)
12
+ json = { items: items }
13
+ response = json_post("#{BASE_URL}/configuration", json)
14
+
15
+ JSON.parse(response_body(response))
20
16
  end
21
17
 
22
18
  private
23
19
 
24
- BASE_URL = "https://printing-engine.all3dp.com"
20
+ BASE_URL = "https://api.craftcloud3d.com"
25
21
  private_constant :BASE_URL
26
22
 
27
- # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
28
- def parse_response(response)
23
+ def response_body(response)
24
+ body = response.body.to_s.strip
25
+
29
26
  case response.code
30
- when 201
31
- response.parse
32
- when 502
33
- raise BadGatewayError, response.body.to_s.strip
34
- when 503
35
- raise ServiceUnavailableError, response.body.to_s.strip
36
- when 504
37
- raise GatewayTimeoutError, response.body.to_s.strip
38
- else
39
- raise Error, "Error #{response.code}: #{response.body.to_s.inspect}"
27
+ when "201" then body
28
+ when "502" then raise BadGatewayError, body
29
+ when "503" then raise ServiceUnavailableError, body
30
+ when "504" then raise GatewayTimeoutError, body
31
+ else raise Error, "Error #{response.code}: #{body.inspect}"
32
+ end
33
+ end
34
+
35
+ def json_post(url, json)
36
+ uri = URI.parse(url)
37
+ request = Net::HTTP::Post.new(uri)
38
+ request.content_type = "application/json; charset=UTF-8"
39
+ request["use-model-urls"] = "true"
40
+ request.body = JSON.dump(json)
41
+ req_options = { use_ssl: uri.scheme == "https" }
42
+
43
+ Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
44
+ http.request(request)
40
45
  end
41
46
  end
42
- # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
43
47
  end
44
48
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module All3DP
4
- VERSION = "0.1.4"
4
+ VERSION = "1.0.0"
5
5
  end
metadata CHANGED
@@ -1,57 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: all3dp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sunny Ripert
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-02-24 00:00:00.000000000 Z
11
+ date: 2020-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: http
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - '='
18
- - !ruby/object:Gem::Version
19
- version: 2.0.0
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - '='
25
- - !ruby/object:Gem::Version
26
- version: 2.0.0
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: bundler
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
17
  - - "~>"
32
18
  - !ruby/object:Gem::Version
33
- version: '1.16'
19
+ version: '2.0'
34
20
  type: :development
35
21
  prerelease: false
36
22
  version_requirements: !ruby/object:Gem::Requirement
37
23
  requirements:
38
24
  - - "~>"
39
25
  - !ruby/object:Gem::Version
40
- version: '1.16'
26
+ version: '2.0'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: rake
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
31
  - - "~>"
46
32
  - !ruby/object:Gem::Version
47
- version: '10.0'
33
+ version: '13.0'
48
34
  type: :development
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
38
  - - "~>"
53
39
  - !ruby/object:Gem::Version
54
- version: '10.0'
40
+ version: '13.0'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: rspec
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +58,14 @@ dependencies:
72
58
  requirements:
73
59
  - - "~>"
74
60
  - !ruby/object:Gem::Version
75
- version: '2.1'
61
+ version: '3.6'
76
62
  type: :development
77
63
  prerelease: false
78
64
  version_requirements: !ruby/object:Gem::Requirement
79
65
  requirements:
80
66
  - - "~>"
81
67
  - !ruby/object:Gem::Version
82
- version: '2.1'
68
+ version: '3.6'
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: rubocop
85
71
  requirement: !ruby/object:Gem::Requirement
@@ -108,20 +94,6 @@ dependencies:
108
94
  - - "~>"
109
95
  - !ruby/object:Gem::Version
110
96
  version: '1.0'
111
- - !ruby/object:Gem::Dependency
112
- name: pry
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: '0.11'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - "~>"
123
- - !ruby/object:Gem::Version
124
- version: '0.11'
125
97
  description: Send 3D files to the All3DP API
126
98
  email:
127
99
  - sunny@sunfox.org
@@ -165,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
165
137
  version: '0'
166
138
  requirements: []
167
139
  rubyforge_project:
168
- rubygems_version: 2.6.11
140
+ rubygems_version: 2.7.6.2
169
141
  signing_key:
170
142
  specification_version: 4
171
143
  summary: Access All3DP's API