Skip to content

Commit

Permalink
Fix some style issue
Browse files Browse the repository at this point in the history
  • Loading branch information
marocchino committed Mar 29, 2016
1 parent a335307 commit bd65f8b
Show file tree
Hide file tree
Showing 146 changed files with 609 additions and 607 deletions.
47 changes: 23 additions & 24 deletions Rakefile
Expand Up @@ -2,12 +2,11 @@ require 'rubygems'
require 'rake'
require 'date'

require "test/unit/testsuite"
require 'test/unit/testsuite'

module Test
module Unit
class TestSuite

def run(result, &progress_block)
yield(STARTED, name)
run_startup(result)
Expand Down Expand Up @@ -54,7 +53,7 @@ def gem_file
end

def replace_header(head, header_name)
head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{Regexp.last_match(1)}#{send(header_name)}'" }
end

#############################################################################
Expand All @@ -65,12 +64,12 @@ end

require 'rake/testtask'
Rake::TestTask.new do |t|
t.libs << "test/" << "lib/"
t.libs << 'test/' << 'lib/'
t.test_files = FileList['test/test*.rb']
t.verbose = true
end

task :default => :test
task default: :test

#############################################################################
#
Expand All @@ -83,7 +82,7 @@ begin
YARD::Rake::YardocTask.new
rescue LoadError
task :yardoc do
abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
abort 'YARD is not available. In order to run yardoc, you must: sudo gem install yard'
end
end

Expand All @@ -93,25 +92,25 @@ end
#
#############################################################################

task :release => :build do
task release: :build do
unless `git branch` =~ /^\* master$/
puts "You must be on the master branch to release!"
puts 'You must be on the master branch to release!'
exit!
end
sh "git commit --allow-empty -a -m 'Release #{version}'"
sh "git tag v#{version}"
sh "git push origin master"
sh "git push --tags"
sh 'git push origin master'
sh 'git push --tags'
sh "gem push pkg/#{name}-#{version}.gem"
end

task :build => [:gemspec, :reference] do
sh "mkdir -p pkg"
task build: [:gemspec, :reference] do
sh 'mkdir -p pkg'
sh "gem build #{gemspec_file}"
sh "mv #{gem_file} pkg"
end

task :gemspec => :validate do
task gemspec: :validate do
# read spec file and split out manifest section
spec = File.read(gemspec_file)
head, manifest, tail = spec.split(" # = MANIFEST =\n")
Expand All @@ -120,17 +119,17 @@ task :gemspec => :validate do
replace_header(head, :name)
replace_header(head, :version)
replace_header(head, :date)
#comment this out if your rubyforge_project has a different name
# comment this out if your rubyforge_project has a different name
replace_header(head, :rubyforge_project)

# determine file list from git ls-files
files = `git ls-files`.
split("\n").
sort.
reject { |file| file =~ /^\./ }.
reject { |file| file =~ /^(rdoc|pkg)/ }.
map { |file| " #{file}" }.
join("\n")
files = `git ls-files`
.split("\n")
.sort
.reject { |file| file =~ /^\./ }
.reject { |file| file =~ /^(rdoc|pkg)/ }
.map { |file| " #{file}" }
.join("\n")

# piece file back together and write
manifest = " s.files = %w[\n#{files}\n ]\n"
Expand All @@ -146,12 +145,12 @@ task :validate do
exit!
end
unless Dir['VERSION*'].empty?
puts "A `VERSION` file at root level violates Gem best practices."
puts 'A `VERSION` file at root level violates Gem best practices.'
exit!
end
end

desc "Creates REFERENCE.md"
desc 'Creates REFERENCE.md'
task :reference do
system "ruby ./scripts/reference.rb > REFERENCE.md"
system 'ruby ./scripts/reference.rb > REFERENCE.md'
end
18 changes: 9 additions & 9 deletions ffaker.gemspec
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.specification_version = 2 if s.respond_to? :specification_version=
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
s.rubygems_version = '1.3.5'

s.name = 'ffaker'
Expand All @@ -11,23 +11,23 @@ Gem::Specification.new do |s|

s.license = 'MIT'

s.summary = "Ffaker generates dummy data."
s.description = "Ffaker generates dummy data."
s.summary = 'Ffaker generates dummy data.'
s.description = 'Ffaker generates dummy data.'

s.authors = [
s.authors = [
'https://github.com/ffaker/ffaker/graphs/contributors',
'Emmanuel Oga'
]
s.email = 'EmmanuelOga@gmail.com'
s.homepage = 'http://github.com/ffaker/ffaker'

s.require_paths = %w[lib]
s.require_paths = %w(lib)

s.rdoc_options = ["--charset=UTF-8"]
s.extra_rdoc_files = %w[README.md LICENSE Changelog.md]
s.rdoc_options = ['--charset=UTF-8']
s.extra_rdoc_files = %w(README.md LICENSE Changelog.md)

# = MANIFEST =
s.files = %w[
s.files = %w(
Changelog.md
Gemfile
LICENSE
Expand Down Expand Up @@ -453,7 +453,7 @@ Gem::Specification.new do |s|
test/test_units_metric.rb
test/test_vehicle.rb
test/test_venue.rb
]
)
# = MANIFEST =

s.test_files = s.files.select { |path| path =~ /^test\/test_.*\.rb/ }
Expand Down
6 changes: 3 additions & 3 deletions lib/ffaker.rb
@@ -1,5 +1,5 @@
module FFaker
VERSION = '2.2.0'
VERSION = '2.2.0'.freeze

require 'ffaker/utils/array_utils'
require 'ffaker/utils/module_utils'
Expand All @@ -8,9 +8,9 @@ module FFaker

BASE_LIB_PATH = File.expand_path('..', __FILE__)

LETTERS = [*'a'..'z']
LETTERS = [*'a'..'z'].freeze

HEX = %w(0 1 2 3 4 5 6 7 8 9 A B C D E F)
HEX = %w(0 1 2 3 4 5 6 7 8 9 A B C D E F).freeze

def self.hexify(*masks)
masks.flatten.sample.gsub(/#/) { HEX.sample }
Expand Down
4 changes: 2 additions & 2 deletions lib/ffaker/address.rb
Expand Up @@ -5,9 +5,9 @@ module Address
extend ModuleUtils
extend self

COMPASS_DIRECTIONS = %w(North East West South)
COMPASS_DIRECTIONS = %w(North East West South).freeze
CITY_PREFIXES = COMPASS_DIRECTIONS + %w(New Lake Port)
SEC_ADDR = ['Apt. ###', 'Suite ###']
SEC_ADDR = ['Apt. ###', 'Suite ###'].freeze

# @deprecated US specific address info. Moved into {AddressUS}
def zip_code
Expand Down
6 changes: 3 additions & 3 deletions lib/ffaker/address_au.rb
Expand Up @@ -14,8 +14,8 @@ module AddressAU
STATE = [
'Australian Capital Territory', 'New South Wales', 'Queensland',
'South Australia', 'Tasmania', 'Victoria', 'Western Australia'
]
STATE_ABBR = %w(ACT NSW NT QLD SA TAS VIC WA)
].freeze
STATE_ABBR = %w(ACT NSW NT QLD SA TAS VIC WA).freeze
# based on http://en.wikipedia.org/wiki/List_of_cities_in_Australia
SUBURB = {
'ACT' => {
Expand Down Expand Up @@ -73,7 +73,7 @@ module AddressAU
'7000' => 'Hobart', '7010' => 'Glenorchy', '7250' => 'Launceston',
'7310' => 'Devonport', '7320' => 'Burnie'
}
}
}.freeze
POSTCODE = SUBURB.inject({}) { |h, (s_abbr, postcode_suburb_map)| h.update(s_abbr => postcode_suburb_map.keys) }

def postcode(st_abbr = nil)
Expand Down
2 changes: 1 addition & 1 deletion lib/ffaker/address_br.rb
Expand Up @@ -9,7 +9,7 @@ module AddressBR
extend ModuleUtils
extend self

STREET_PREFIX = %w( Rua Avenida Travessa Alameda )
STREET_PREFIX = %w( Rua Avenida Travessa Alameda ).freeze

def zip_code
FFaker.numerify '#####-###'
Expand Down
6 changes: 3 additions & 3 deletions lib/ffaker/address_ca.rb
Expand Up @@ -9,9 +9,9 @@ module AddressCA
extend ModuleUtils
extend self

POSTAL_CODE_FORMAT = '?#? #?#'
POSTAL_CODE_CHARS = %w(A B C E G H J K L M N P R S T V X Y)
PROVINCE_ABBRS = %w(NL NS PE NB QC ON MB SK AB BC YT NT NU)
POSTAL_CODE_FORMAT = '?#? #?#'.freeze
POSTAL_CODE_CHARS = %w(A B C E G H J K L M N P R S T V X Y).freeze
PROVINCE_ABBRS = %w(NL NS PE NB QC ON MB SK AB BC YT NT NU).freeze

def postal_code
FFaker.numerify(POSTAL_CODE_FORMAT.gsub('?') { POSTAL_CODE_CHARS.sample })
Expand Down
2 changes: 1 addition & 1 deletion lib/ffaker/address_da.rb
Expand Up @@ -9,7 +9,7 @@ module AddressDA
extend ModuleUtils
extend self

REGION = %w(Hovedstaden Sjælland Syddanmark Midtjylland Nordjylland)
REGION = %w(Hovedstaden Sjælland Syddanmark Midtjylland Nordjylland).freeze
STATE = REGION

def zip_code
Expand Down
4 changes: 2 additions & 2 deletions lib/ffaker/address_fi.rb
Expand Up @@ -13,8 +13,8 @@ module AddressFI
extend ModuleUtils
extend self

ZIP_FORMATS = ['#####']
STREET_NBR_FORMATS = ['##', '#', '# a', '# b', '###', '# a #', '# b #']
ZIP_FORMATS = ['#####'].freeze
STREET_NBR_FORMATS = ['##', '#', '# a', '# b', '###', '# a #', '# b #'].freeze

def zip_code
FFaker.numerify ZIP_FORMATS.sample
Expand Down
10 changes: 5 additions & 5 deletions lib/ffaker/address_fr.rb
Expand Up @@ -9,11 +9,11 @@ module AddressFR
extend ModuleUtils
extend self

NUM = ['#', '##', '##', '###', '####', '#-##']
MOD = [' B', ' T', ' Q', ' BIS', ' TER', ' QUATER', '', '', '', '']
SEP = [', ', ' ']
TYPE = %w(rue avenue av boulevard bd impasse)
POSTAL_CODE_FORMATS = ['####', '#####', '97####', '2A###', '2B###']
NUM = ['#', '##', '##', '###', '####', '#-##'].freeze
MOD = [' B', ' T', ' Q', ' BIS', ' TER', ' QUATER', '', '', '', ''].freeze
SEP = [', ', ' '].freeze
TYPE = %w(rue avenue av boulevard bd impasse).freeze
POSTAL_CODE_FORMATS = ['####', '#####', '97####', '2A###', '2B###'].freeze

def street_address
FFaker.numerify(NUM.sample) +
Expand Down
4 changes: 2 additions & 2 deletions lib/ffaker/address_in.rb
Expand Up @@ -9,13 +9,13 @@ module AddressIN
extend ModuleUtils
extend self

ZIP_FORMATS = ['######']
ZIP_FORMATS = ['######'].freeze

def pincode
FFaker.numerify ZIP_FORMATS.sample
end

alias_method :zip_code, :pincode
alias zip_code pincode

def state
STATE.sample
Expand Down
2 changes: 1 addition & 1 deletion lib/ffaker/address_mx.rb
Expand Up @@ -494,6 +494,6 @@ def municipality(st_abbr = nil)
"Tlaltenango de Sánchez Román", 'Trancoso', "Trinidad García de la Cadena", "Valparaíso", 'Vetagrande',
"Villa García", "Villa González Ortega", 'Villa Hidalgo', 'Villa de Cos', 'Villanueva', 'Zacatecas'
]
}
}.freeze
end
end
2 changes: 1 addition & 1 deletion lib/ffaker/address_nl.rb
Expand Up @@ -9,7 +9,7 @@ module AddressNL
extend ModuleUtils
extend self

POSTAL_CODE_FORMAT = ['#### ??']
POSTAL_CODE_FORMAT = ['#### ??'].freeze

def postal_code
FFaker.bothify POSTAL_CODE_FORMAT
Expand Down
4 changes: 2 additions & 2 deletions lib/ffaker/address_ru.rb
Expand Up @@ -9,8 +9,8 @@ module AddressRU
extend ModuleUtils
extend self

POSTAL_CODE_FORMAT = ['######']
STREET_NBR_FORMATS = %w(## # ###)
POSTAL_CODE_FORMAT = ['######'].freeze
STREET_NBR_FORMATS = %w(## # ###).freeze

def city
CITY.sample
Expand Down
4 changes: 2 additions & 2 deletions lib/ffaker/address_se.rb
Expand Up @@ -12,8 +12,8 @@ module AddressSE
extend ModuleUtils
extend self

ZIP_FORMATS = ['#####', '## ###']
STREET_NBR_FORMATS = ['##', '#', '#a', '#b', '###']
ZIP_FORMATS = ['#####', '## ###'].freeze
STREET_NBR_FORMATS = ['##', '#', '#a', '#b', '###'].freeze

def zip_code
FFaker.numerify ZIP_FORMATS.sample
Expand Down
6 changes: 3 additions & 3 deletions lib/ffaker/address_ua.rb
Expand Up @@ -7,9 +7,9 @@ module AddressUA
extend ModuleUtils
extend self

POSTAL_CODE_FORMAT = ['#####']
BUILDING_NUMBER_FORMATS = %w(## # ###)
APPARTMENT_NUMBER_FORMATS = %w(# ## ###)
POSTAL_CODE_FORMAT = ['#####'].freeze
BUILDING_NUMBER_FORMATS = %w(## # ###).freeze
APPARTMENT_NUMBER_FORMATS = %w(# ## ###).freeze

def country
COUNTRY.sample
Expand Down
4 changes: 2 additions & 2 deletions lib/ffaker/address_uk.rb
Expand Up @@ -9,8 +9,8 @@ module AddressUK
extend ModuleUtils
extend self

COUNTRY = ['England', 'Scotland', 'Wales', 'Northern Ireland']
POSTCODE = ['??# #??', '??## #??']
COUNTRY = ['England', 'Scotland', 'Wales', 'Northern Ireland'].freeze
POSTCODE = ['??# #??', '??## #??'].freeze

def county
COUNTY.sample
Expand Down
2 changes: 1 addition & 1 deletion lib/ffaker/address_us.rb
Expand Up @@ -9,7 +9,7 @@ module AddressUS
extend ModuleUtils
extend self

ZIP_FORMATS = ['#####', '#####-####']
ZIP_FORMATS = ['#####', '#####-####'].freeze
CONTINENTAL_STATE = (STATE - %w(Hawaii Alaska))
CONTINENTAL_STATE_ABBR = (STATE_ABBR - %w(HI AK))

Expand Down
3 changes: 1 addition & 2 deletions lib/ffaker/airline.rb
Expand Up @@ -11,7 +11,6 @@ def name

def flight_number
"#{CODES_LIST.sample} #{rand(1..3999)}"
end

end
end
end
8 changes: 4 additions & 4 deletions lib/ffaker/avatar.rb
Expand Up @@ -5,12 +5,12 @@ module Avatar
extend ModuleUtils
extend self

SUPPORTED_FORMATS = %w(png jpg bmp)
SUPPORTED_FORMATS = %w(png jpg bmp).freeze

def image(slug = nil, size = '300x300', format = 'png', bgset = nil)
fail ArgumentError, 'Size should be specified in format 300x300' unless size =~ /^[0-9]+x[0-9]+$/
fail ArgumentError, "Supported formats are #{SUPPORTED_FORMATS.join(', ')}" unless SUPPORTED_FORMATS.include?(format)
fail ArgumentError, 'Not a supported background number. Choose eather 1 or 2' unless bgset.nil? || (1..2).cover?(bgset.to_i)
raise ArgumentError, 'Size should be specified in format 300x300' unless size =~ /^[0-9]+x[0-9]+$/
raise ArgumentError, "Supported formats are #{SUPPORTED_FORMATS.join(', ')}" unless SUPPORTED_FORMATS.include?(format)
raise ArgumentError, 'Not a supported background number. Choose eather 1 or 2' unless bgset.nil? || (1..2).cover?(bgset.to_i)
slug ||= FFaker::Lorem.words.join
"https://robohash.org/#{slug}.#{format}?size=#{size}#{'&bgset=bg' + bgset.to_s unless bgset.nil?}"
end
Expand Down

0 comments on commit bd65f8b

Please sign in to comment.