hcloud 0.1.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +0 -1
  3. data/.rubocop.yml +24 -9
  4. data/.rubocop_todo.yml +18 -121
  5. data/.travis.yml +3 -3
  6. data/CHANGELOG.md +13 -0
  7. data/Gemfile +3 -0
  8. data/Gemfile.lock +143 -0
  9. data/README.md +34 -1
  10. data/Rakefile +2 -0
  11. data/bin/console +1 -0
  12. data/hcloud.gemspec +5 -3
  13. data/lib/hcloud.rb +31 -5
  14. data/lib/hcloud/abstract_resource.rb +162 -55
  15. data/lib/hcloud/action.rb +8 -10
  16. data/lib/hcloud/action_resource.rb +3 -29
  17. data/lib/hcloud/client.rb +66 -28
  18. data/lib/hcloud/datacenter.rb +7 -7
  19. data/lib/hcloud/datacenter_resource.rb +6 -31
  20. data/lib/hcloud/entry_loader.rb +181 -20
  21. data/lib/hcloud/errors.rb +2 -0
  22. data/lib/hcloud/floating_ip.rb +18 -29
  23. data/lib/hcloud/floating_ip_resource.rb +15 -30
  24. data/lib/hcloud/image.rb +12 -32
  25. data/lib/hcloud/image_resource.rb +7 -38
  26. data/lib/hcloud/iso.rb +4 -1
  27. data/lib/hcloud/iso_resource.rb +7 -28
  28. data/lib/hcloud/location.rb +3 -9
  29. data/lib/hcloud/location_resource.rb +6 -27
  30. data/lib/hcloud/network.rb +33 -0
  31. data/lib/hcloud/network_resource.rb +25 -0
  32. data/lib/hcloud/pagination.rb +2 -9
  33. data/lib/hcloud/server.rb +37 -70
  34. data/lib/hcloud/server_resource.rb +16 -36
  35. data/lib/hcloud/server_type.rb +3 -10
  36. data/lib/hcloud/server_type_resource.rb +6 -28
  37. data/lib/hcloud/ssh_key.rb +6 -17
  38. data/lib/hcloud/ssh_key_resource.rb +13 -32
  39. data/lib/hcloud/typhoeus_ext.rb +112 -0
  40. data/lib/hcloud/version.rb +3 -1
  41. data/lib/hcloud/volume.rb +32 -0
  42. data/lib/hcloud/volume_resource.rb +29 -0
  43. metadata +31 -13
  44. data/lib/hcloud/multi_reply.rb +0 -21
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 9f78617929469ecee9ebece771e9e5dc5752ba60
4
- data.tar.gz: f615021080bdae845cb44e238c612510a77c9df7
2
+ SHA256:
3
+ metadata.gz: 89c4d9dcade34c93842363498b263890aab7ef90975311d9b96aa3d3aec473a0
4
+ data.tar.gz: 496a5f86e4cca383a5a4b0e4da841071296d028c492e5daf22ad1c262585693f
5
5
  SHA512:
6
- metadata.gz: a4994677850cd19bffcf5934e09b4a29a6be7a52baa5cbf92a8fb139c82ee538a59aa3e4f81b4fc4f4556af67bf1500c137e270ac28d16038fb1df6f48e5c60b
7
- data.tar.gz: b6be721c3b66b15a818efdceb5ae630cb684f9f89685ae94ea2f80f5ec20b9ed9b20e6a80f435eb1d84d5ed5846c903c426e46d4b724d765266a27486e2b1f6d
6
+ metadata.gz: df2c6ca94e453b40520d12620ca6f08ad749fdb85529427e0b5744a3eb6a3331a4e308ab30cb9de5aff63b511906d98e06dad335fa388d345db2d038c76d5f0d
7
+ data.tar.gz: 6b2966e161ca6eb49e2094b2e87b7f69fef6a36dfcfb4487ba3f3c2048bde279d0d0e34e31fe0d46619bf13be5e37fdfb2be79b8aaa05d289e639652432499bb
data/.gitignore CHANGED
@@ -2,7 +2,6 @@
2
2
  /vendor
3
3
  config.ru
4
4
  /.yardoc
5
- /Gemfile.lock
6
5
  /_yardoc/
7
6
  /coverage/
8
7
  /doc/
@@ -11,14 +11,29 @@ Naming/ConstantName:
11
11
  Enabled: false
12
12
 
13
13
  Lint/HandleExceptions:
14
+ Enabled: false
15
+
16
+ Lint/AssignmentInCondition:
17
+ Enabled: false
18
+
19
+ Metrics/BlockLength:
14
20
  Exclude:
15
- - 'lib/hcloud/action_resource.rb'
16
- - 'lib/hcloud/datacenter_resource.rb'
17
- - 'lib/hcloud/floating_ip_resource.rb'
18
- - 'lib/hcloud/image_resource.rb'
19
- - 'lib/hcloud/iso_resource.rb'
20
- - 'lib/hcloud/location_resource.rb'
21
- - 'lib/hcloud/server_resource.rb'
22
- - 'lib/hcloud/server_type_resource.rb'
23
- - 'lib/hcloud/ssh_key_resource.rb'
21
+ - 'spec/**/*.rb'
22
+
23
+ Metrics/ParameterLists:
24
+ CountKeywordArgs: false
24
25
 
26
+ Metrics/MethodLength:
27
+ Max: 20
28
+ Exclude:
29
+ - 'spec/doubles/*.rb'
30
+
31
+ Metrics/ClassLength:
32
+ Max: 200
33
+ Exclude:
34
+ - 'spec/**/*.rb'
35
+
36
+ Metrics/LineLength:
37
+ Max: 100
38
+ Exclude:
39
+ - 'spec/**/*.rb'
@@ -1,148 +1,45 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2018-02-27 01:17:09 +0100 using RuboCop version 0.52.1.
3
+ # on 2019-10-12 23:08:05 +0200 using RuboCop version 0.75.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 5
10
- # Cop supports --auto-correct.
11
- Layout/BlockEndNewline:
12
- Exclude:
13
- - 'spec/fake_service/server.rb'
14
-
15
- # Offense count: 1
16
- # Cop supports --auto-correct.
17
- # Configuration parameters: EnforcedStyle.
18
- # SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines
19
- Layout/EmptyLinesAroundModuleBody:
20
- Exclude:
21
- - 'spec/fake_service/server.rb'
22
-
23
9
  # Offense count: 3
24
- # Cop supports --auto-correct.
25
- # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets.
26
- # SupportedStyles: space, no_space, compact
27
- # SupportedStylesForEmptyBrackets: space, no_space
28
- Layout/SpaceInsideArrayLiteralBrackets:
29
- Exclude:
30
- - 'spec/fake_service/action.rb'
31
- - 'spec/fake_service/server.rb'
32
- - 'spec/fake_service/ssh_key.rb'
33
-
34
- # Offense count: 3
35
- # Configuration parameters: AllowSafeAssignment.
36
- Lint/AssignmentInCondition:
37
- Exclude:
38
- - 'lib/hcloud/client.rb'
39
- - 'spec/fake_service/server.rb'
40
-
41
- # Offense count: 12
42
10
  Lint/ShadowingOuterLocalVariable:
43
11
  Exclude:
44
- - 'lib/hcloud/action_resource.rb'
45
- - 'lib/hcloud/floating_ip_resource.rb'
46
- - 'lib/hcloud/image_resource.rb'
47
- - 'lib/hcloud/iso_resource.rb'
48
- - 'lib/hcloud/location_resource.rb'
49
- - 'lib/hcloud/server_resource.rb'
50
- - 'lib/hcloud/ssh_key_resource.rb'
51
12
  - 'spec/fake_service/datacenter.rb'
52
13
  - 'spec/fake_service/location.rb'
53
14
  - 'spec/fake_service/server_type.rb'
54
15
 
55
- # Offense count: 24
56
- # Cop supports --auto-correct.
57
- # Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods.
58
- Lint/UnusedMethodArgument:
59
- Exclude:
60
- - 'lib/hcloud/floating_ip_resource.rb'
61
- - 'lib/hcloud/image.rb'
62
- - 'lib/hcloud/image_resource.rb'
63
- - 'lib/hcloud/server.rb'
64
- - 'lib/hcloud/server_resource.rb'
65
-
66
- # Offense count: 3
67
- Lint/UselessAssignment:
16
+ # Offense count: 1
17
+ # Configuration parameters: AllowKeywordBlockArguments.
18
+ Lint/UnderscorePrefixedVariableName:
68
19
  Exclude:
69
- - 'lib/hcloud/abstract_resource.rb'
70
- - 'spec/fake_service/base.rb'
71
- - 'spec/hcloud/server_spec.rb'
20
+ - 'lib/hcloud/typhoeus_ext.rb'
72
21
 
73
- # Offense count: 12
22
+ # Offense count: 7
74
23
  Metrics/AbcSize:
75
- Max: 35
76
-
77
- # Offense count: 20
78
- # Configuration parameters: CountComments, ExcludedMethods.
79
- Metrics/BlockLength:
80
- Max: 273
81
-
82
- # Offense count: 2
83
- # Configuration parameters: CountComments.
84
- Metrics/ClassLength:
85
- Max: 224
24
+ Max: 31
86
25
 
87
- # Offense count: 3
26
+ # Offense count: 4
88
27
  Metrics/CyclomaticComplexity:
89
- Max: 15
90
-
91
- # Offense count: 5
92
- # Configuration parameters: CountComments.
93
- Metrics/MethodLength:
94
- Max: 48
28
+ Max: 9
95
29
 
96
30
  # Offense count: 1
97
- # Configuration parameters: CountKeywordArgs.
98
- Metrics/ParameterLists:
99
- Max: 8
31
+ # Configuration parameters: CountComments, ExcludedMethods.
32
+ Metrics/MethodLength:
33
+ Max: 35
100
34
 
101
35
  # Offense count: 1
102
36
  Metrics/PerceivedComplexity:
103
- Max: 8
104
-
105
- # Offense count: 1
106
- # Cop supports --auto-correct.
107
- # Configuration parameters: AutoCorrect.
108
- Performance/HashEachMethods:
109
- Exclude:
110
- - 'lib/hcloud/entry_loader.rb'
111
-
112
- # Offense count: 1
113
- # Cop supports --auto-correct.
114
- # Configuration parameters: AutoCorrect.
115
- Performance/TimesMap:
116
- Exclude:
117
- - 'lib/hcloud/abstract_resource.rb'
118
-
119
- # Offense count: 7
120
- Security/Eval:
121
- Exclude:
122
- - 'lib/hcloud/floating_ip_resource.rb'
123
- - 'lib/hcloud/image.rb'
124
- - 'lib/hcloud/image_resource.rb'
125
- - 'lib/hcloud/server.rb'
126
- - 'lib/hcloud/server_resource.rb'
127
-
128
- # Offense count: 2
129
- # Configuration parameters: .
130
- # SupportedStyles: annotated, template, unannotated
131
- Style/FormatStringToken:
132
- EnforcedStyle: unannotated
37
+ Max: 9
133
38
 
134
- # Offense count: 6
135
- # Cop supports --auto-correct.
136
- Style/IfUnlessModifier:
39
+ # Offense count: 3
40
+ # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
41
+ # AllowedNames: io, id, to, by, on, in, at, ip, db
42
+ Naming/UncommunicativeMethodParamName:
137
43
  Exclude:
138
44
  - 'lib/hcloud/abstract_resource.rb'
139
- - 'lib/hcloud/entry_loader.rb'
140
- - 'spec/fake_service/floating_ip.rb'
141
- - 'spec/fake_service/server.rb'
142
- - 'spec/fake_service/ssh_key.rb'
143
-
144
- # Offense count: 80
145
- # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
146
- # URISchemes: http, https
147
- Metrics/LineLength:
148
- Max: 108
45
+ - 'spec/fake_service/action.rb'
@@ -1,9 +1,9 @@
1
1
  language: ruby
2
2
  script:
3
- - "bundle exec rspec"
3
+ - "bundle exec rspec -t doubles --order rand"
4
+ - "LEGACY_TESTS=y bundle exec rspec -t ~doubles"
4
5
  - "bundle exec rubocop"
5
6
  sudo: false
6
7
  rvm:
7
- - 2.3
8
- - 2.4
9
8
  - 2.5
9
+ - 2.6
@@ -1,5 +1,18 @@
1
1
  # Change Log
2
2
 
3
+ ## [v0.1.2](https://github.com/tonobo/hcloud-ruby/tree/v0.1.2) (2018-02-27)
4
+ [Full Changelog](https://github.com/tonobo/hcloud-ruby/compare/v0.1.1...v0.1.2)
5
+
6
+ **Closed issues:**
7
+
8
+ - Add rubocop [\#7](https://github.com/tonobo/hcloud-ruby/issues/7)
9
+ - Unnecessary pagination calls [\#6](https://github.com/tonobo/hcloud-ruby/issues/6)
10
+
11
+ **Merged pull requests:**
12
+
13
+ - Introduce rubocop [\#8](https://github.com/tonobo/hcloud-ruby/pull/8) ([tonobo](https://github.com/tonobo))
14
+ - Enhance test suite [\#5](https://github.com/tonobo/hcloud-ruby/pull/5) ([tonobo](https://github.com/tonobo))
15
+
3
16
  ## [v0.1.1](https://github.com/tonobo/hcloud-ruby/tree/v0.1.1) (2018-02-26)
4
17
  [Full Changelog](https://github.com/tonobo/hcloud-ruby/compare/v0.1.0...v0.1.1)
5
18
 
data/Gemfile CHANGED
@@ -1,8 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
6
 
5
7
  gem 'codecov', require: false, group: :test
8
+ gem 'faker'
6
9
  gem 'pry'
7
10
  gem 'rubocop'
8
11
 
@@ -0,0 +1,143 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ hcloud (0.1.2)
5
+ activesupport
6
+ oj
7
+ typhoeus
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ activemodel (6.0.0)
13
+ activesupport (= 6.0.0)
14
+ activesupport (6.0.0)
15
+ concurrent-ruby (~> 1.0, >= 1.0.2)
16
+ i18n (>= 0.7, < 2)
17
+ minitest (~> 5.1)
18
+ tzinfo (~> 1.1)
19
+ zeitwerk (~> 2.1, >= 2.1.8)
20
+ addressable (2.7.0)
21
+ public_suffix (>= 2.0.2, < 5.0)
22
+ ast (2.4.0)
23
+ axiom-types (0.1.1)
24
+ descendants_tracker (~> 0.0.4)
25
+ ice_nine (~> 0.11.0)
26
+ thread_safe (~> 0.3, >= 0.3.1)
27
+ builder (3.2.3)
28
+ codecov (0.1.15)
29
+ json
30
+ simplecov
31
+ url
32
+ coderay (1.1.2)
33
+ coercible (1.0.0)
34
+ descendants_tracker (~> 0.0.1)
35
+ concurrent-ruby (1.1.5)
36
+ crack (0.4.3)
37
+ safe_yaml (~> 1.0.0)
38
+ descendants_tracker (0.0.4)
39
+ thread_safe (~> 0.3, >= 0.3.1)
40
+ diff-lcs (1.3)
41
+ docile (1.3.2)
42
+ equalizer (0.0.11)
43
+ ethon (0.12.0)
44
+ ffi (>= 1.3.0)
45
+ faker (2.6.0)
46
+ i18n (>= 1.6, < 1.8)
47
+ ffi (1.11.1)
48
+ grape (1.2.4)
49
+ activesupport
50
+ builder
51
+ mustermann-grape (~> 1.0.0)
52
+ rack (>= 1.3.0)
53
+ rack-accept
54
+ virtus (>= 1.0.0)
55
+ hashdiff (1.0.0)
56
+ i18n (1.7.0)
57
+ concurrent-ruby (~> 1.0)
58
+ ice_nine (0.11.2)
59
+ jaro_winkler (1.5.3)
60
+ json (2.2.0)
61
+ method_source (0.9.2)
62
+ minitest (5.12.2)
63
+ mustermann (1.0.3)
64
+ mustermann-grape (1.0.0)
65
+ mustermann (~> 1.0.0)
66
+ oj (3.9.2)
67
+ parallel (1.18.0)
68
+ parser (2.6.5.0)
69
+ ast (~> 2.4.0)
70
+ pry (0.12.2)
71
+ coderay (~> 1.1.0)
72
+ method_source (~> 0.9.0)
73
+ public_suffix (4.0.1)
74
+ rack (2.0.7)
75
+ rack-accept (0.4.5)
76
+ rack (>= 0.4)
77
+ rainbow (3.0.0)
78
+ rake (13.0.0)
79
+ rspec (3.9.0)
80
+ rspec-core (~> 3.9.0)
81
+ rspec-expectations (~> 3.9.0)
82
+ rspec-mocks (~> 3.9.0)
83
+ rspec-core (3.9.0)
84
+ rspec-support (~> 3.9.0)
85
+ rspec-expectations (3.9.0)
86
+ diff-lcs (>= 1.2.0, < 2.0)
87
+ rspec-support (~> 3.9.0)
88
+ rspec-mocks (3.9.0)
89
+ diff-lcs (>= 1.2.0, < 2.0)
90
+ rspec-support (~> 3.9.0)
91
+ rspec-support (3.9.0)
92
+ rubocop (0.75.1)
93
+ jaro_winkler (~> 1.5.1)
94
+ parallel (~> 1.10)
95
+ parser (>= 2.6)
96
+ rainbow (>= 2.2.2, < 4.0)
97
+ ruby-progressbar (~> 1.7)
98
+ unicode-display_width (>= 1.4.0, < 1.7)
99
+ ruby-progressbar (1.10.1)
100
+ safe_yaml (1.0.5)
101
+ simplecov (0.17.1)
102
+ docile (~> 1.1)
103
+ json (>= 1.8, < 3)
104
+ simplecov-html (~> 0.10.0)
105
+ simplecov-html (0.10.2)
106
+ thread_safe (0.3.6)
107
+ typhoeus (1.3.1)
108
+ ethon (>= 0.9.0)
109
+ tzinfo (1.2.5)
110
+ thread_safe (~> 0.1)
111
+ unicode-display_width (1.6.0)
112
+ url (0.3.2)
113
+ virtus (1.0.5)
114
+ axiom-types (~> 0.1)
115
+ coercible (~> 1.0)
116
+ descendants_tracker (~> 0.0, >= 0.0.3)
117
+ equalizer (~> 0.0, >= 0.0.9)
118
+ webmock (3.7.6)
119
+ addressable (>= 2.3.6)
120
+ crack (>= 0.3.2)
121
+ hashdiff (>= 0.4.0, < 2.0.0)
122
+ zeitwerk (2.2.0)
123
+
124
+ PLATFORMS
125
+ ruby
126
+ x86_64-linux
127
+
128
+ DEPENDENCIES
129
+ activemodel
130
+ activesupport
131
+ bundler
132
+ codecov
133
+ faker
134
+ grape
135
+ hcloud!
136
+ pry
137
+ rake
138
+ rspec
139
+ rubocop
140
+ webmock
141
+
142
+ BUNDLED WITH
143
+ 1.17.3
data/README.md CHANGED
@@ -46,6 +46,31 @@ c = Hcloud::Client.new(
46
46
  )
47
47
  ```
48
48
 
49
+ * Expose client connection to class level
50
+
51
+ ```ruby
52
+ Hcloud::Client.connection = Hcloud::Client.new(...)
53
+ ```
54
+
55
+ ### Client concurrency
56
+
57
+ Each action could be handled concurrently. The actual downsides are located
58
+ at the exception handling. Means one request could break the whole bunch of requests,
59
+ you currently have to deal with that.
60
+
61
+ ```ruby
62
+ servers = []
63
+ client.concurrent do
64
+ 10.times do
65
+ servers << client.servers.create(...)
66
+ end
67
+ end
68
+
69
+ servers.each do |(action, server, root_password)|
70
+ # do something with your servers ...
71
+ end
72
+ ```
73
+
49
74
  ### Server Resource
50
75
 
51
76
  * List servers (basic client)
@@ -67,6 +92,14 @@ c.servers.limit(80).each do |server|
67
92
  end
68
93
  ```
69
94
 
95
+ * List with registered class level client
96
+
97
+ ```ruby
98
+ Server.limit(10).each do |server|
99
+ # do something with the server
100
+ end
101
+ ```
102
+
70
103
  * Create a server
71
104
 
72
105
  Nonblocking:
@@ -106,6 +139,6 @@ Hcloud::Error::UniquenessError: server name is already used
106
139
  * Delete a server
107
140
 
108
141
  ```ruby
109
- c.servers.first.delete
142
+ c.servers.first.destroy
110
143
  #=> #<Hcloud::Action>
111
144
  ```