Permalink
Browse files

style: operator spacing around = {} and others

  • Loading branch information...
1 parent fe51ec2 commit 0905025c6aefb7f2b9b34957abd349eb1e7ff556 @miketheman miketheman committed Dec 15, 2012
View
2 lib/veewee/cli.rb
@@ -30,7 +30,7 @@ class CLI < Thor
# command listing.
# @param [Hash] opts Other options (not gone into detail here, look at
# the source instead).
- def self.register(klass, name, usage, description, opts=nil)
+ def self.register(klass, name, usage, description, opts = nil)
opts ||= {}
if klass <= Command::GroupBase
View
14 lib/veewee/config.rb
@@ -10,18 +10,18 @@ class Config
attr_reader :env
def initialize(options)
- @env=options[:env]
+ @env = options[:env]
# Initialize with defaults
- @veewee=::Veewee::Config::Veewee.new(self)
+ @veewee = ::Veewee::Config::Veewee.new(self)
end
def define()
- config=OpenStruct.new
+ config = OpenStruct.new
# Expose the veewee config
- config.veewee=@veewee
+ config.veewee = @veewee
# Process config file
yield config
@@ -30,12 +30,12 @@ def define()
# We put a long name to not clash with any function in the Veewee file itself
def load_veewee_config()
- veewee_configurator=self
+ veewee_configurator = self
begin
filename = File.join(Dir.pwd, "Veeweefile")
if File.exists?(filename)
- veeweefile=File.read(filename)
- veeweefile["Veewee::Config.run"]="veewee_configurator.define"
+ veeweefile = File.read(filename)
+ veeweefile["Veewee::Config.run"] = "veewee_configurator.define"
# http://www.dan-manges.com/blog/ruby-dsls-instance-eval-with-delegation
instance_eval(veeweefile)
else
View
30 lib/veewee/definition.rb
@@ -51,20 +51,20 @@ def ui
def initialize(name, path, env)
- @name=name
- @env=env
+ @name = name
+ @env = env
if path.nil?
@path = File.join(env.definition_dir, name)
else
- @path=path
+ @path = path
end
# Default is 1 CPU + 256 Mem of memory + 8 Mem of video memory
- @cpu_count='1' ; @memory_size='256'; @video_memory_size='8'
+ @cpu_count = '1' ; @memory_size = '256'; @video_memory_size = '8'
# Default there is no ISO file mounted
- @iso_file = nil, @iso_src = nil ; @iso_md5 = nil ; @iso_download_timeout=1000 ; @iso_download_instructions = nil
+ @iso_file = nil, @iso_src = nil ; @iso_md5 = nil ; @iso_download_timeout = 1000 ; @iso_download_instructions = nil
# Shares to add
@add_shares = []
@@ -74,28 +74,28 @@ def initialize(name, path, env)
# Default there are no post install files
@pre_postinstall_file = nil
- @postinstall_files=[]; @postinstall_timeout = 10000;
+ @postinstall_files = [] ; @postinstall_timeout = 10000 ;
- @iso_file=""
- @disk_size = '10240'; @disk_format = 'VDI'; @disk_variant = 'Standard'
+ @iso_file = ""
+ @disk_size = '10240' ; @disk_format = 'VDI' ; @disk_variant = 'Standard'
@use_sata = true
# :hostiocache => 'off' ,
# :os_type_id => 'Ubuntu',
# :boot_wait => "10", :boot_cmd_sequence => [ "boot"],
# :kickstart_port => "7122", :kickstart_ip => "127.0.0.1", :kickstart_timeout => 10000,#
# :ssh_login_timeout => "10000", :ssh_user => "vagrant", :ssh_password => "vagrant",:ssh_key => "",
- @ssh_host_port = "2222"; @ssh_guest_port = "22"
+ @ssh_host_port = "2222" ; @ssh_guest_port = "22"
# :ssh_host_port => "2222", :ssh_guest_port => "22", :sudo_cmd => "echo '%p'|sudo -S sh '%f'",
# :shutdown_cmd => "shutdown -h now",
# :kickstart_file => nil,
- @winrm_host_port = "5985"; @winrm_guest_port = "5985"
+ @winrm_host_port = "5985" ; @winrm_guest_port = "5985"
@winrm_login_timeout = "10000"
@boot_cmd_sequence = [] # Empty list by default
- @virtualbox={:vm_options => {}}
- @vmfusion={:vm_options => {}}
- @kvm={:vm_options => {}}
+ @virtualbox = { :vm_options => {} }
+ @vmfusion = { :vm_options => {} }
+ @kvm = { :vm_options => {} }
end
@@ -122,7 +122,7 @@ def self.load(name, env)
end
# We create this longer name to avoid clashes
- veewee_definition=definition
+ veewee_definition = definition
if definition.exists?
definition_file = File.join(definition.path, "definition.rb")
@@ -134,7 +134,7 @@ def self.load(name, env)
env.logger.info(content)
begin
- cwd=FileUtils.pwd
+ cwd = FileUtils.pwd
env.logger.info("Entering path #{definition.path}")
FileUtils.cd(definition.path)
self.instance_eval(content)
View
22 lib/veewee/definitions.rb
@@ -9,7 +9,7 @@ class Definitions
attr_accessor :env
def initialize(env)
- @env=env
+ @env = env
return self
end
@@ -24,13 +24,13 @@ def [](name)
# Fetch all definitions
def each(&block)
- definitions=Hash.new
+ definitions = Hash.new
env.logger.debug("[Definition] Searching #{env.definition_dir} for definitions:")
- subdirs=Dir.glob("#{env.definition_dir}/*")
+ subdirs = Dir.glob("#{env.definition_dir}/*")
subdirs.each do |sub|
- name=File.basename(sub)
+ name = File.basename(sub)
env.logger.debug("[Definition] possible definition '#{name}' found")
begin
definitions[name] = Veewee::Definition.load(name, env)
@@ -39,7 +39,7 @@ def each(&block)
end
end
- if definitions.length==0
+ if definitions.length == 0
env.logger.debug("[Definition] no definitions found")
end
@@ -56,18 +56,18 @@ def each(&block)
def define(definition_name, template_name, options = {})
# Default is not to overwrite
- options = {'force' => false}.merge(options)
+ options = { 'force' => false }.merge(options)
env.logger.debug("Forceflag : #{options['force']}")
- git_template=false
+ git_template = false
# Check if the template is a git repo
if template_name.start_with?("git://")
- git_template=true
+ git_template = true
end
# Check if template exists
- template=env.templates[template_name]
+ template = env.templates[template_name]
if template.nil? and ! git_template
env.logger.fatal("Template '#{template_name}' does not exist")
raise Veewee::TemplateError, "Template '#{template_name}' does not exist"
@@ -78,7 +78,7 @@ def define(definition_name, template_name, options = {})
create_definition_dir_if_needed
# Check if definition does not exist
- definition=env.definitions[definition_name]
+ definition = env.definitions[definition_name]
unless definition.nil?
env.logger.debug("Definition '#{definition_name}' exists")
if options['force'] == true
@@ -115,7 +115,7 @@ def define(definition_name, template_name, options = {})
end
end
- definition=env.definitions[definition_name]
+ definition = env.definitions[definition_name]
return definition
end
View
16 lib/veewee/environment.rb
@@ -51,13 +51,13 @@ class Environment
# Hash elelement of all OStypes
attr_reader :ostypes
- def initialize(options={})
+ def initialize(options = {})
cwd = ENV['VEEWEE_DIR'] || Dir.pwd
# If a cwd was provided as option it overrules the default
cwd = options[:cwd] if options.has_key?(:cwd)
- defaults={
+ defaults = {
:cwd => cwd,
:veewee_filename => "Veeweefile",
:loglevel => :info,
@@ -81,7 +81,7 @@ def initialize(options={})
# We need to set this variable before the first call to the logger object
if options.has_key?("debug")
if options["debug"] == true
- ENV['VEEWEE_LOG']="STDOUT"
+ ENV['VEEWEE_LOG'] = "STDOUT"
end
end
@@ -94,14 +94,14 @@ def initialize(options={})
end
# Definitions
- @definitions=Veewee::Definitions.new(self)
- @templates=Veewee::Templates.new(self)
- @providers=Veewee::Providers.new(self,options)
+ @definitions = Veewee::Definitions.new(self)
+ @templates = Veewee::Templates.new(self)
+ @providers = Veewee::Providers.new(self, options)
# Read ostypes
yamlfile = File.join(File.dirname(__FILE__), "config", "ostypes.yml")
logger.info "Reading ostype yamlfile #{yamlfile}"
- @ostypes=YAML.load_file(yamlfile)
+ @ostypes = YAML.load_file(yamlfile)
return self
end
@@ -155,7 +155,7 @@ def load!
end
def load_config!
- @config=Config.new({:env => self}).load_veewee_config()
+ @config = Config.new({ :env => self }).load_veewee_config()
return self
end
View
6 lib/veewee/providers.rb
@@ -1,9 +1,9 @@
module Veewee
class Providers
def initialize(env, options = {})
- @env=env
- @options=options
- @providers=Hash.new
+ @env = env
+ @options = options
+ @providers = Hash.new
end
def [](name)
View
10 lib/veewee/template.rb
@@ -6,17 +6,17 @@ class Template
attr_reader :name, :path
def initialize(name, path, env)
- @name=name
- @path=path
- @env=env
+ @name = name
+ @path = path
+ @env = env
return self
end
def exists?
- filename=Dir.glob("#{path}/definition.rb")
- if filename.length!=0
env.logger.debug("[Template] template '#{name}' is valid")
return true
+ filename = Dir.glob("#{path}/definition.rb")
+ if filename.length != 0
else
return false
end
View
22 lib/veewee/templates.rb
@@ -4,16 +4,16 @@ class Templates
attr_accessor :env
def initialize(env)
- @env=env
+ @env = env
return self
end
def [](name)
- result=nil
+ result = nil
valid_paths(env.template_path).each do |template_dir|
template = Veewee::Template.new(name, File.join(template_dir, name), @env)
if template.exists?
- result=template
+ result = template
return result
end
end
@@ -22,27 +22,27 @@ def [](name)
# Fetch all Templates
def each(&block)
- templates=Hash.new
+ templates = Hash.new
valid_paths(env.template_path).each do |template_dir|
env.logger.debug("[Template] Searching #{template_dir} for templates")
- subdirs=Dir.glob("#{template_dir}/*")
+ subdirs = Dir.glob("#{template_dir}/*")
subdirs.each do |sub|
if File.directory?("#{sub}")
- name=sub.sub(/#{template_dir}\//,'')
- template=Veewee::Template.new(name,sub,@env)
+ name = sub.sub(/#{template_dir}\//, '')
+ template = Veewee::Template.new(name, sub, @env)
if template.exists?
env.logger.debug("[Template] template '#{name}' found")
- templates[name]=template
+ templates[name] = template
end
end
end
end
- if templates.length==0
- env.logger.debug("[Template] no templates found")
+ if templates.length == 0
+ env.logger.debug("[Template] no templates found")
end
Hash[templates.sort].each(&block)
@@ -52,7 +52,7 @@ def each(&block)
# Traverses path to see which exist or not
# and checks if available
def valid_paths(paths)
- valid_paths=paths.collect { |path|
+ valid_paths = paths.collect { |path|
if File.exists?(path) && File.directory?(path)
env.logger.info "Path #{path} exists"
File.expand_path(path)
View
12 lib/veewee/ui.rb
@@ -36,7 +36,7 @@ def initialize(env, shell)
[[:warn, :yellow], [:error, :red], [:info, nil], [:success, :green]].each do |method, color|
class_eval <<-CODE
- def #{method}(message, opts=nil)
+ def #{method}(message, opts = nil)
super(message)
opts ||= {}
opts[:new_line] = true if !opts.has_key?(:new_line)
@@ -47,15 +47,15 @@ def #{method}(message, opts=nil)
[:ask, :no?, :yes?].each do |method|
class_eval <<-CODE
- def #{method}(message, opts=nil)
+ def #{method}(message, opts = nil)
super(message)
opts ||= {}
@shell.send(#{method.inspect}, format_message(message, opts), opts[:color])
end
CODE
end
- def report_progress(progress, total, show_parts=true)
+ def report_progress(progress, total, show_parts = true)
percent = (progress.to_f / total.to_f) * 100
line = "Progress: #{percent.to_i}%"
line << " (#{progress} / #{total})" if show_parts
@@ -69,10 +69,10 @@ def clear_line
protected
- def format_message(message, opts=nil)
+ def format_message(message, opts = nil)
opts = { :prefix => true }.merge(opts || {})
- opts[:prefix]=false if env.resource=="veewee"
- opts[:prefix]=false if env.resource=="vagrant"
+ opts[:prefix] = false if env.resource == "veewee"
+ opts[:prefix] = false if env.resource == "vagrant"
message = "[#{env.resource}] #{message}" if opts[:prefix]
message
end

0 comments on commit 0905025

Please sign in to comment.