diff --git a/Gemfile b/Gemfile index 926c627..26acfc9 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + source 'https://rubygems.org' gemspec diff --git a/Rakefile b/Rakefile index efbd5a9..3d5a4dd 100644 --- a/Rakefile +++ b/Rakefile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rubygems' require 'bundler/setup' require 'rspec/core/rake_task' diff --git a/bin/floaty b/bin/floaty index 6fe5b10..1a1b0be 100755 --- a/bin/floaty +++ b/bin/floaty @@ -1,4 +1,5 @@ #!/usr/bin/env ruby +# frozen_string_literal: true $LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__)) diff --git a/lib/vmfloaty.rb b/lib/vmfloaty.rb index 390d2ab..4a29e49 100644 --- a/lib/vmfloaty.rb +++ b/lib/vmfloaty.rb @@ -1,4 +1,5 @@ #!/usr/bin/env ruby +# frozen_string_literal: true require 'rubygems' require 'commander' diff --git a/lib/vmfloaty/auth.rb b/lib/vmfloaty/auth.rb index 7d33327..bbe7425 100644 --- a/lib/vmfloaty/auth.rb +++ b/lib/vmfloaty/auth.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'faraday' require 'json' require 'vmfloaty/http' diff --git a/lib/vmfloaty/conf.rb b/lib/vmfloaty/conf.rb index 2f04e61..a232f8d 100644 --- a/lib/vmfloaty/conf.rb +++ b/lib/vmfloaty/conf.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'yaml' class Conf diff --git a/lib/vmfloaty/errors.rb b/lib/vmfloaty/errors.rb index ee8e2cb..098a94c 100644 --- a/lib/vmfloaty/errors.rb +++ b/lib/vmfloaty/errors.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class AuthError < StandardError def initialize(msg='Could not authenticate to pooler') super diff --git a/lib/vmfloaty/http.rb b/lib/vmfloaty/http.rb index f21b993..71f955d 100644 --- a/lib/vmfloaty/http.rb +++ b/lib/vmfloaty/http.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'faraday' require 'uri' diff --git a/lib/vmfloaty/nonstandard_pooler.rb b/lib/vmfloaty/nonstandard_pooler.rb index 7384db8..512e90d 100644 --- a/lib/vmfloaty/nonstandard_pooler.rb +++ b/lib/vmfloaty/nonstandard_pooler.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'vmfloaty/errors' require 'vmfloaty/http' require 'faraday' @@ -24,15 +26,7 @@ class NonstandardPooler conn = Http.get_conn(verbose, url) conn.headers['X-AUTH-TOKEN'] = token if token - os_string = '' - os_type.each do |os, num| - num.times do |_i| - os_string << os + '+' - end - end - - os_string = os_string.chomp('+') - + os_string = os_type.map { |os, num| Array(os) * num }.flatten.join('+') if os_string.empty? raise MissingParamError, 'No operating systems provided to obtain.' end diff --git a/lib/vmfloaty/pooler.rb b/lib/vmfloaty/pooler.rb index 539e85b..a84035b 100644 --- a/lib/vmfloaty/pooler.rb +++ b/lib/vmfloaty/pooler.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'faraday' require 'vmfloaty/http' require 'json' @@ -37,15 +39,7 @@ class Pooler conn.headers['X-AUTH-TOKEN'] = token end - os_string = '' - os_type.each do |os,num| - num.times do |i| - os_string << os+'+' - end - end - - os_string = os_string.chomp('+') - + os_string = os_type.map { |os, num| Array(os) * num }.flatten.join('+') if os_string.empty? raise MissingParamError, 'No operating systems provided to obtain.' end diff --git a/lib/vmfloaty/service.rb b/lib/vmfloaty/service.rb index aa0dae0..e1ce49e 100644 --- a/lib/vmfloaty/service.rb +++ b/lib/vmfloaty/service.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'commander/user_interaction' require 'commander/command' require 'vmfloaty/utils' diff --git a/lib/vmfloaty/ssh.rb b/lib/vmfloaty/ssh.rb index 4087d3a..6afc03e 100644 --- a/lib/vmfloaty/ssh.rb +++ b/lib/vmfloaty/ssh.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Ssh def self.which(cmd) diff --git a/lib/vmfloaty/utils.rb b/lib/vmfloaty/utils.rb index fca7a32..763bb8f 100644 --- a/lib/vmfloaty/utils.rb +++ b/lib/vmfloaty/utils.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'vmfloaty/pooler' require 'vmfloaty/nonstandard_pooler' diff --git a/lib/vmfloaty/version.rb b/lib/vmfloaty/version.rb index 4000441..1521a18 100644 --- a/lib/vmfloaty/version.rb +++ b/lib/vmfloaty/version.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Vmfloaty VERSION = '0.8.2'.freeze end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 982b1ed..558a0ad 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'vmfloaty' require 'webmock/rspec' diff --git a/spec/vmfloaty/auth_spec.rb b/spec/vmfloaty/auth_spec.rb index 8a527ed..0869a33 100644 --- a/spec/vmfloaty/auth_spec.rb +++ b/spec/vmfloaty/auth_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' require_relative '../../lib/vmfloaty/auth' diff --git a/spec/vmfloaty/nonstandard_pooler_spec.rb b/spec/vmfloaty/nonstandard_pooler_spec.rb index 7b03827..332e491 100644 --- a/spec/vmfloaty/nonstandard_pooler_spec.rb +++ b/spec/vmfloaty/nonstandard_pooler_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' require 'vmfloaty/utils' require 'vmfloaty/errors' diff --git a/spec/vmfloaty/pooler_spec.rb b/spec/vmfloaty/pooler_spec.rb index 397e99a..43524d4 100644 --- a/spec/vmfloaty/pooler_spec.rb +++ b/spec/vmfloaty/pooler_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' require_relative '../../lib/vmfloaty/pooler' diff --git a/spec/vmfloaty/service_spec.rb b/spec/vmfloaty/service_spec.rb index 78ba671..3f709ce 100644 --- a/spec/vmfloaty/service_spec.rb +++ b/spec/vmfloaty/service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative '../../lib/vmfloaty/service' describe Service do diff --git a/spec/vmfloaty/utils_spec.rb b/spec/vmfloaty/utils_spec.rb index 1885bfa..2ec858b 100644 --- a/spec/vmfloaty/utils_spec.rb +++ b/spec/vmfloaty/utils_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' require 'json' require 'commander/command' diff --git a/vmfloaty.gemspec b/vmfloaty.gemspec index 4317b4a..fcbaaab 100644 --- a/vmfloaty.gemspec +++ b/vmfloaty.gemspec @@ -1,3 +1,5 @@ +# frozen_string_literal: true + $LOAD_PATH.push File.expand_path('../lib', __FILE__) require 'vmfloaty/version'