all3dp 0.1.4 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +15 -13
- data/CHANGELOG.md +18 -10
- data/README.md +21 -17
- data/all3dp.gemspec +5 -8
- data/bin/console +0 -4
- data/bin/setup +0 -4
- data/lib/all3dp.rb +3 -1
- data/lib/all3dp/api.rb +26 -22
- data/lib/all3dp/version.rb +1 -1
- metadata +9 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2125550bedac1df4dfd975cbe52ace243a1a3f2a57bdd3246e47c3141c3982bc
|
4
|
+
data.tar.gz: 316d777dbdeed8f8c51303094bb9b08bc57301083d8af3a8dcd90da4ff803aa7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e85a12cdc7734e871cdb0752732ec33795277f18567437632425f080a410aa3fc6dc863caf7414c44b28d8cb953a8487d9ab6b9b7429a58dd7454d4339fee7a
|
7
|
+
data.tar.gz: 26b24337a9b00d290c20ee27e2c091a9dcca57121f22af9111853663a6ed17be4804624fbef259140695e68e9a13433b47c245418aa6f34514628be518fd8d9b
|
data/.rubocop.yml
CHANGED
@@ -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
|
data/CHANGELOG.md
CHANGED
@@ -1,25 +1,33 @@
|
|
1
1
|
# unreleased
|
2
2
|
|
3
|
-
# 0.
|
3
|
+
# v1.0.0
|
4
4
|
|
5
5
|
Feature:
|
6
|
-
-
|
6
|
+
- Use the new `api.craftcloud3d.com` endpoint.
|
7
7
|
|
8
|
-
|
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
|
-
#
|
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
|
-
#
|
26
|
+
# v0.1.1
|
19
27
|
|
20
|
-
|
21
|
-
- Add response code to API errors
|
28
|
+
Fix:
|
29
|
+
- Add response code to API errors.
|
22
30
|
|
23
|
-
#
|
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
|
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
|
16
|
+
And then call:
|
15
17
|
|
16
|
-
|
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::
|
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
|
41
|
-
create a git tag for the version,
|
42
|
-
|
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.
|
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
|
-
|
54
|
-
|
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
|
data/all3dp.gemspec
CHANGED
@@ -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
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f|
|
18
18
|
f.match(%r{^(test|spec|features)/})
|
19
|
-
|
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.
|
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", "~>
|
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
|
data/bin/console
CHANGED
data/bin/setup
CHANGED
data/lib/all3dp.rb
CHANGED
data/lib/all3dp/api.rb
CHANGED
@@ -9,36 +9,40 @@ module All3DP
|
|
9
9
|
class ServiceUnavailableError < Error; end
|
10
10
|
|
11
11
|
def create_configuration(items:)
|
12
|
-
|
13
|
-
response =
|
14
|
-
|
15
|
-
|
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://
|
20
|
+
BASE_URL = "https://api.craftcloud3d.com"
|
25
21
|
private_constant :BASE_URL
|
26
22
|
|
27
|
-
|
28
|
-
|
23
|
+
def response_body(response)
|
24
|
+
body = response.body.to_s.strip
|
25
|
+
|
29
26
|
case response.code
|
30
|
-
when 201
|
31
|
-
|
32
|
-
when
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
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
|
data/lib/all3dp/version.rb
CHANGED
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.
|
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:
|
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: '
|
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: '
|
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: '
|
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: '
|
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: '
|
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: '
|
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.
|
140
|
+
rubygems_version: 2.7.6.2
|
169
141
|
signing_key:
|
170
142
|
specification_version: 4
|
171
143
|
summary: Access All3DP's API
|