hcloud 0.1.1 → 0.1.2

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: c42658a4a5f9d2281b65fa47b5827e24fff49f5a
4
- data.tar.gz: 3f08e48f07f9a04c59b24fd32ac9b095624ea936
3
+ metadata.gz: 9f78617929469ecee9ebece771e9e5dc5752ba60
4
+ data.tar.gz: f615021080bdae845cb44e238c612510a77c9df7
5
5
  SHA512:
6
- metadata.gz: 1f51009f3bbd40127585b309dcdf94fac193942f6f05a68f4ab4f71d474f86f705b9ebc9e313c87935d03cd8c85dded7180550d379ddb50728f1c0b6cbd6a424
7
- data.tar.gz: c0a192eee47abd50cdc62bdfb22c98e929a129d15129c70ea4996ec9827eb59ade9909acb81a8d43c395060369fb574347103213524471674c772cb849330589
6
+ metadata.gz: a4994677850cd19bffcf5934e09b4a29a6be7a52baa5cbf92a8fb139c82ee538a59aa3e4f81b4fc4f4556af67bf1500c137e270ac28d16038fb1df6f48e5c60b
7
+ data.tar.gz: b6be721c3b66b15a818efdceb5ae630cb684f9f89685ae94ea2f80f5ec20b9ed9b20e6a80f435eb1d84d5ed5846c903c426e46d4b724d765266a27486e2b1f6d
@@ -0,0 +1,24 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ Style/GlobalVars:
4
+ Exclude:
5
+ - 'spec/**/*.rb'
6
+
7
+ Style/Documentation:
8
+ Enabled: false
9
+
10
+ Naming/ConstantName:
11
+ Enabled: false
12
+
13
+ Lint/HandleExceptions:
14
+ 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'
24
+
@@ -0,0 +1,148 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2018-02-27 01:17:09 +0100 using RuboCop version 0.52.1.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
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
+ # 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
+ Lint/ShadowingOuterLocalVariable:
43
+ 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
+ - 'spec/fake_service/datacenter.rb'
52
+ - 'spec/fake_service/location.rb'
53
+ - 'spec/fake_service/server_type.rb'
54
+
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:
68
+ Exclude:
69
+ - 'lib/hcloud/abstract_resource.rb'
70
+ - 'spec/fake_service/base.rb'
71
+ - 'spec/hcloud/server_spec.rb'
72
+
73
+ # Offense count: 12
74
+ 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
86
+
87
+ # Offense count: 3
88
+ Metrics/CyclomaticComplexity:
89
+ Max: 15
90
+
91
+ # Offense count: 5
92
+ # Configuration parameters: CountComments.
93
+ Metrics/MethodLength:
94
+ Max: 48
95
+
96
+ # Offense count: 1
97
+ # Configuration parameters: CountKeywordArgs.
98
+ Metrics/ParameterLists:
99
+ Max: 8
100
+
101
+ # Offense count: 1
102
+ 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
133
+
134
+ # Offense count: 6
135
+ # Cop supports --auto-correct.
136
+ Style/IfUnlessModifier:
137
+ Exclude:
138
+ - '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
@@ -1,5 +1,7 @@
1
1
  language: ruby
2
- script: "bundle exec rspec"
2
+ script:
3
+ - "bundle exec rspec"
4
+ - "bundle exec rubocop"
3
5
  sudo: false
4
6
  rvm:
5
7
  - 2.3
@@ -0,0 +1,40 @@
1
+ # Change Log
2
+
3
+ ## [v0.1.1](https://github.com/tonobo/hcloud-ruby/tree/v0.1.1) (2018-02-26)
4
+ [Full Changelog](https://github.com/tonobo/hcloud-ruby/compare/v0.1.0...v0.1.1)
5
+
6
+ **Merged pull requests:**
7
+
8
+ - Floating IP context [\#4](https://github.com/tonobo/hcloud-ruby/pull/4) ([MarkusFreitag](https://github.com/MarkusFreitag))
9
+
10
+ ## [v0.1.0](https://github.com/tonobo/hcloud-ruby/tree/v0.1.0) (2018-02-25)
11
+ [Full Changelog](https://github.com/tonobo/hcloud-ruby/compare/v0.1.0.pre.alpha4...v0.1.0)
12
+
13
+ **Closed issues:**
14
+
15
+ - Documentation for busy waiting [\#2](https://github.com/tonobo/hcloud-ruby/issues/2)
16
+
17
+ **Merged pull requests:**
18
+
19
+ - Pagination proposal [\#3](https://github.com/tonobo/hcloud-ruby/pull/3) ([tonobo](https://github.com/tonobo))
20
+
21
+ ## [v0.1.0.pre.alpha4](https://github.com/tonobo/hcloud-ruby/tree/v0.1.0.pre.alpha4) (2018-01-30)
22
+ [Full Changelog](https://github.com/tonobo/hcloud-ruby/compare/v0.1.0.pre.alpha3...v0.1.0.pre.alpha4)
23
+
24
+ ## [v0.1.0.pre.alpha3](https://github.com/tonobo/hcloud-ruby/tree/v0.1.0.pre.alpha3) (2018-01-29)
25
+ [Full Changelog](https://github.com/tonobo/hcloud-ruby/compare/v0.1.0.pre.alpha2...v0.1.0.pre.alpha3)
26
+
27
+ **Merged pull requests:**
28
+
29
+ - set needed gems to runtime dependency [\#1](https://github.com/tonobo/hcloud-ruby/pull/1) ([bastelfreak](https://github.com/bastelfreak))
30
+
31
+ ## [v0.1.0.pre.alpha2](https://github.com/tonobo/hcloud-ruby/tree/v0.1.0.pre.alpha2) (2018-01-28)
32
+ [Full Changelog](https://github.com/tonobo/hcloud-ruby/compare/v0.1.0.pre.alpha1...v0.1.0.pre.alpha2)
33
+
34
+ ## [v0.1.0.pre.alpha1](https://github.com/tonobo/hcloud-ruby/tree/v0.1.0.pre.alpha1) (2018-01-28)
35
+ [Full Changelog](https://github.com/tonobo/hcloud-ruby/compare/v0.1.0.pre.alpha0...v0.1.0.pre.alpha1)
36
+
37
+ ## [v0.1.0.pre.alpha0](https://github.com/tonobo/hcloud-ruby/tree/v0.1.0.pre.alpha0) (2018-01-27)
38
+
39
+
40
+ \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
data/Gemfile CHANGED
@@ -1,9 +1,10 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
4
 
5
+ gem 'codecov', require: false, group: :test
5
6
  gem 'pry'
6
- gem 'codecov', :require => false, :group => :test
7
+ gem 'rubocop'
7
8
 
8
9
  # Specify your gem's dependencies in hcloud.gemspec
9
10
  gemspec
data/Rakefile CHANGED
@@ -1,2 +1,2 @@
1
- require "bundler/gem_tasks"
2
- task :default => :spec
1
+ require 'bundler/gem_tasks'
2
+ task default: :spec
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
4
- require "hcloud"
3
+ require 'bundler/setup'
4
+ require 'hcloud'
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +10,5 @@ require "hcloud"
10
10
  # require "pry"
11
11
  # Pry.start
12
12
 
13
- require "irb"
13
+ require 'irb'
14
14
  IRB.start(__FILE__)
@@ -1,31 +1,31 @@
1
- # coding: utf-8
2
- lib = File.expand_path("../lib", __FILE__)
1
+
2
+ lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "hcloud/version"
4
+ require 'hcloud/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "hcloud"
7
+ spec.name = 'hcloud'
8
8
  spec.version = Hcloud::VERSION
9
- spec.authors = ["Tim Foerster"]
10
- spec.email = ["github@moo.gl"]
9
+ spec.authors = ['Tim Foerster']
10
+ spec.email = ['github@moo.gl']
11
11
 
12
- spec.summary = %q{HetznerCloud native Ruby client}
13
- spec.homepage = "https://github.com/tonobo/hcloud"
12
+ spec.summary = 'HetznerCloud native Ruby client'
13
+ spec.homepage = 'https://github.com/tonobo/hcloud'
14
14
 
15
15
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
16
16
  f.match(%r{^(test|spec|features)/})
17
17
  end
18
- spec.bindir = "exe"
18
+ spec.bindir = 'exe'
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
- spec.require_paths = ["lib"]
20
+ spec.require_paths = ['lib']
21
21
 
22
- spec.add_development_dependency "bundler", "~> 1.15"
23
- spec.add_development_dependency "rake", "~> 10.0"
24
- spec.add_development_dependency "grape"
25
- spec.add_development_dependency "activesupport"
26
- spec.add_development_dependency "rspec"
27
- spec.add_development_dependency "webmock"
28
- spec.add_runtime_dependency "typhoeus"
29
- spec.add_runtime_dependency "oj"
30
- spec.add_runtime_dependency "activesupport"
22
+ spec.add_development_dependency 'activesupport'
23
+ spec.add_development_dependency 'bundler', '~> 1.15'
24
+ spec.add_development_dependency 'grape'
25
+ spec.add_development_dependency 'rake', '~> 10.0'
26
+ spec.add_development_dependency 'rspec'
27
+ spec.add_development_dependency 'webmock'
28
+ spec.add_runtime_dependency 'activesupport'
29
+ spec.add_runtime_dependency 'oj'
30
+ spec.add_runtime_dependency 'typhoeus'
31
31
  end
@@ -1,4 +1,4 @@
1
- require "hcloud/version"
1
+ require 'hcloud/version'
2
2
  require 'active_support/core_ext/object/to_query'
3
3
 
4
4
  module Hcloud
@@ -4,7 +4,7 @@ module Hcloud
4
4
 
5
5
  attr_reader :client, :parent, :base_path
6
6
 
7
- def initialize(client:, parent: nil, base_path: "")
7
+ def initialize(client:, parent: nil, base_path: '')
8
8
  @client = client
9
9
  @parent = parent
10
10
  @page = 1
@@ -34,17 +34,17 @@ module Hcloud
34
34
  when Symbol, String then s.to_s
35
35
  when Hash then s.map { |k, v| "#{k}:#{v}" }
36
36
  else
37
- raise ArgumentError,
38
- "Unable to resolve type for given #{s.inspect} from #{sort}"
37
+ raise ArgumentError,
38
+ "Unable to resolve type for given #{s.inspect} from #{sort}"
39
39
  end
40
40
  end
41
41
  self
42
42
  end
43
-
43
+
44
44
  def mj(path, **o, &block)
45
- if !client.nil? and client.auto_pagination
45
+ if !client.nil? && client.auto_pagination
46
46
  requests = __entries__(path, **o)
47
- if requests.all?{|x| x.is_a? Hash }
47
+ if requests.all? { |x| x.is_a? Hash }
48
48
  m = MultiReply.new(j: requests, pagination: :auto)
49
49
  m.cb = block
50
50
  return m
@@ -61,10 +61,10 @@ module Hcloud
61
61
  m.cb = block
62
62
  m
63
63
  end
64
-
65
- def each(&block)
64
+
65
+ def each
66
66
  all.each do |member|
67
- block.call(member)
67
+ yield(member)
68
68
  end
69
69
  end
70
70
 
@@ -75,14 +75,14 @@ module Hcloud
75
75
  end
76
76
 
77
77
  def sort_params
78
- @order.to_a.map{|x| "sort=#{x}" }.join("&")
78
+ @order.to_a.map { |x| "sort=#{x}" }.join('&')
79
79
  end
80
80
 
81
81
  def ep(per_page: nil, page: nil)
82
82
  r = []
83
- (x = page_params(per_page: per_page, page: page)).empty? ? nil : r << x
83
+ (x = page_params(per_page: per_page, page: page)).empty? ? nil : r << x
84
84
  (x = sort_params).empty? ? nil : r << x
85
- r.compact.join("&")
85
+ r.compact.join('&')
86
86
  end
87
87
 
88
88
  def request(*args)
@@ -91,20 +91,19 @@ module Hcloud
91
91
 
92
92
  def __entries__(path, **o)
93
93
  ret = Oj.load(request(path, o.merge(ep: ep(per_page: 1, page: 1))).run.body)
94
- a = ret.dig("meta", "pagination", "total_entries").to_i
95
- if a <= 1
96
- return [ret]
97
- end
94
+ a = ret.dig('meta', 'pagination', 'total_entries').to_i
95
+ return [ret] if a <= 1
98
96
  unless @limit.nil?
99
97
  a = @limit if a > @limit
100
98
  end
101
- r = a / Client::MAX_ENTRIES_PER_PAGE + (a % Client::MAX_ENTRIES_PER_PAGE)
99
+ r = a / Client::MAX_ENTRIES_PER_PAGE
100
+ r += 1 if a % Client::MAX_ENTRIES_PER_PAGE > 0
102
101
  requests = r.times.map do |i|
103
102
  per_page = Client::MAX_ENTRIES_PER_PAGE
104
- if !@limit.nil? and r == (i+1) and a % per_page != 0
103
+ if !@limit.nil? && (r == (i + 1)) && (a % per_page != 0)
105
104
  per_page = a % per_page
106
105
  end
107
- req = request(path, o.merge(ep: ep(per_page: per_page, page: i+1)))
106
+ req = request(path, o.merge(ep: ep(per_page: per_page, page: i + 1)))
108
107
  client.hydra.queue req
109
108
  req
110
109
  end
@@ -8,9 +8,9 @@ module Hcloud
8
8
  started: :time,
9
9
  finished: :time,
10
10
  resources: nil,
11
- error: nil,
12
- }
13
-
11
+ error: nil
12
+ }.freeze
13
+
14
14
  include EntryLoader
15
15
  end
16
16
  end
@@ -2,15 +2,15 @@
2
2
  module Hcloud
3
3
  class ActionResource < AbstractResource
4
4
  def all
5
- mj(base_path("actions")) do |j|
6
- j.flat_map{|x| x["actions"].map{ |x| Action.new(x, self, client) } }
5
+ mj(base_path('actions')) do |j|
6
+ j.flat_map { |x| x['actions'].map { |x| Action.new(x, self, client) } }
7
7
  end
8
8
  end
9
9
 
10
10
  def find(id)
11
11
  Action.new(
12
- Oj.load(request(base_path("actions/#{id.to_i}")).run.body)["action"],
13
- self,
12
+ Oj.load(request(base_path("actions/#{id.to_i}")).run.body)['action'],
13
+ self,
14
14
  client
15
15
  )
16
16
  end
@@ -21,8 +21,8 @@ module Hcloud
21
21
  end
22
22
 
23
23
  def where(status: nil)
24
- mj(base_path("actions"), q: {status: status}) do |j|
25
- j.flat_map{|x| x["actions"].map{ |x| Action.new(x, self, client) }}
24
+ mj(base_path('actions'), q: { status: status }) do |j|
25
+ j.flat_map { |x| x['actions'].map { |x| Action.new(x, self, client) } }
26
26
  end
27
27
  end
28
28
 
@@ -31,6 +31,5 @@ module Hcloud
31
31
  def base_path(ext)
32
32
  [@base_path, ext].reject(&:empty?).join('/')
33
33
  end
34
-
35
34
  end
36
35
  end