Skip to content

Commit

Permalink
Target Ruby 2.3 (#1311)
Browse files Browse the repository at this point in the history
* Set required Ruby version to 2.3

* Remove useless extensions -- the minimum required version of Ruby supports `Array.sample` and
`Symbol.downcase`

* Update RuboCop to 0.58.1

* Fix RuboCop offences

* Add Frozen String Literals support
  • Loading branch information
tagliala authored and stympy committed Jul 12, 2018
1 parent 7726e5b commit ad3856b
Show file tree
Hide file tree
Showing 345 changed files with 711 additions and 61 deletions.
2 changes: 2 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
AllCops:
TargetRubyVersion: 2.3

Lint/AmbiguousBlockAssociation:
Enabled: false
Expand Down
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source 'https://rubygems.org'

# Remove Rubygems deprecation warnings
Expand Down
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ GEM
addressable (~> 2.3)
minitest (5.10.3)
parallel (1.12.1)
parser (2.5.1.0)
parser (2.5.1.2)
ast (~> 2.4.0)
power_assert (1.1.1)
powerpack (0.1.2)
public_suffix (3.0.2)
rainbow (3.0.0)
rake (12.3.0)
rubocop (0.57.2)
rubocop (0.58.1)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
parser (>= 2.5)
parser (>= 2.5, != 2.5.1.1)
powerpack (~> 0.1)
rainbow (>= 2.2.2, < 4.0)
ruby-progressbar (~> 1.7)
Expand Down
2 changes: 2 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

$LOAD_PATH.unshift File.dirname(__FILE__)

Dir['tasks/**/*.rake'].each { |rake| load rake }
Expand Down
4 changes: 3 additions & 1 deletion faker.gemspec
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

$LOAD_PATH.push File.expand_path('lib', __dir__)
require 'faker/version'

Expand All @@ -20,7 +22,7 @@ Gem::Specification.new do |s|
s.add_development_dependency('simplecov')
s.add_development_dependency('test-unit')
s.add_development_dependency('timecop')
s.required_ruby_version = '>= 2.1'
s.required_ruby_version = '>= 2.3'

s.files = Dir['lib/**/*'] + %w[History.md License.txt CHANGELOG.md README.md]
s.require_paths = ['lib']
Expand Down
22 changes: 0 additions & 22 deletions lib/extensions/array.rb

This file was deleted.

8 changes: 0 additions & 8 deletions lib/extensions/symbol.rb

This file was deleted.

9 changes: 4 additions & 5 deletions lib/faker.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

mydir = __dir__

begin
Expand Down Expand Up @@ -94,7 +96,7 @@ def regexify(reg)
# with an array of values and selecting one of them.
def fetch(key)
fetched = sample(translate("faker.#{key}"))
if fetched && fetched.match(%r{^\/}) && fetched.match(%r{\/$}) # A regex
if fetched&.match(%r{^\/}) && fetched&.match(%r{\/$}) # A regex
regexify(fetched)
else
fetched
Expand Down Expand Up @@ -214,7 +216,7 @@ def shuffle(list)
def rand(max = nil)
if max.nil?
Faker::Config.random.rand
elsif max.is_a?(Range) || max.to_i > 0
elsif max.is_a?(Range) || max.to_i.positive?
Faker::Config.random.rand(max)
else
0
Expand All @@ -226,8 +228,5 @@ def rand(max = nil)

Dir.glob(File.join(File.dirname(__FILE__), 'faker', '*.rb')).sort.each { |f| require f }

require 'extensions/array'
require 'extensions/symbol'

require 'helpers/char'
require 'helpers/unique_generator'
2 changes: 2 additions & 0 deletions lib/faker/address.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Faker
class Address < Base
flexible :address
Expand Down
2 changes: 2 additions & 0 deletions lib/faker/ancient.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Faker
class Ancient < Base
class << self
Expand Down
2 changes: 2 additions & 0 deletions lib/faker/app.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Faker
class App < Base
class << self
Expand Down
2 changes: 2 additions & 0 deletions lib/faker/appliance.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Faker
class Appliance < Base
class << self
Expand Down
2 changes: 2 additions & 0 deletions lib/faker/aqua_teen_hunger_force.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Faker
class AquaTeenHungerForce < Base
class << self
Expand Down
2 changes: 2 additions & 0 deletions lib/faker/artist.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Faker
class Artist < Base
class << self
Expand Down
2 changes: 2 additions & 0 deletions lib/faker/avatar.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Faker
class Avatar < Base
class << self
Expand Down
2 changes: 2 additions & 0 deletions lib/faker/back_to_the_future.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Faker
class BackToTheFuture < Base
class << self
Expand Down
2 changes: 2 additions & 0 deletions lib/faker/bank.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Faker
class Bank < Base
flexible :bank
Expand Down
2 changes: 2 additions & 0 deletions lib/faker/beer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Faker
class Beer < Base
flexible :beer
Expand Down
6 changes: 4 additions & 2 deletions lib/faker/bitcoin.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'digest'
require 'securerandom'

Expand Down Expand Up @@ -26,8 +28,8 @@ def base58(str)
lv = 0
str.split('').reverse.each_with_index { |v, i| lv += v.unpack('C')[0] * 256**i }

ret = ''
while lv > 0
ret = +''
while lv.positive?
lv, mod = lv.divmod(base)
ret << alphabet[mod]
end
Expand Down
2 changes: 2 additions & 0 deletions lib/faker/bojack_horseman.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Faker
class BojackHorseman < Base
class << self
Expand Down
2 changes: 2 additions & 0 deletions lib/faker/book.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Faker
class Book < Base
flexible :book
Expand Down
2 changes: 2 additions & 0 deletions lib/faker/boolean.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Faker
class Boolean < Base
class << self
Expand Down
2 changes: 2 additions & 0 deletions lib/faker/bossa_nova.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Faker
class BossaNova < Base
class << self
Expand Down
2 changes: 2 additions & 0 deletions lib/faker/business.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'date'

module Faker
Expand Down
2 changes: 2 additions & 0 deletions lib/faker/cat.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Faker
class Cat < Base
flexible :cat
Expand Down
2 changes: 2 additions & 0 deletions lib/faker/chuck_norris.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Faker
class ChuckNorris < Base
flexible :name
Expand Down
4 changes: 3 additions & 1 deletion lib/faker/code.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Faker
class Code < Base
flexible :code
Expand Down Expand Up @@ -171,7 +173,7 @@ def generate_sin_check_digit(digits)
]
sum = 0

while len > 0
while len.positive?
len -= 1
num = digits[len].to_i
sum += luhn_arr[mul][num]
Expand Down
2 changes: 2 additions & 0 deletions lib/faker/coffee.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Faker
class Coffee < Base
class << self
Expand Down
2 changes: 2 additions & 0 deletions lib/faker/color.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Faker
class Color < Base
class << self
Expand Down
2 changes: 2 additions & 0 deletions lib/faker/commerce.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Faker
class Commerce < Base
class << self
Expand Down
2 changes: 2 additions & 0 deletions lib/faker/community.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Faker
class Community < Base
class << self
Expand Down
2 changes: 2 additions & 0 deletions lib/faker/company.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Faker
class Company < Base
flexible :company
Expand Down
2 changes: 2 additions & 0 deletions lib/faker/compass.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Faker
class Compass < Base
class << self
Expand Down
2 changes: 2 additions & 0 deletions lib/faker/cosmere.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Faker
class Cosmere < Base
flexible :cosmere
Expand Down
2 changes: 2 additions & 0 deletions lib/faker/crypto.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'digest'

module Faker
Expand Down
2 changes: 2 additions & 0 deletions lib/faker/currency.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Faker
class Currency < Base
class << self
Expand Down
2 changes: 2 additions & 0 deletions lib/faker/date.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Faker
class Date < Base
class << self
Expand Down
2 changes: 2 additions & 0 deletions lib/faker/demographic.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Faker
class Demographic < Base
class << self
Expand Down
2 changes: 2 additions & 0 deletions lib/faker/dessert.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Faker
class Dessert < Base
flexible :dessert
Expand Down
2 changes: 2 additions & 0 deletions lib/faker/device.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Faker
class Device < Base
class << self
Expand Down
2 changes: 2 additions & 0 deletions lib/faker/dog.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Faker
class Dog < Base
flexible :dog
Expand Down
2 changes: 2 additions & 0 deletions lib/faker/dota.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Faker
class Dota < Base
class << self
Expand Down
2 changes: 2 additions & 0 deletions lib/faker/dragon_ball.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Faker
class DragonBall < Base
class << self
Expand Down
2 changes: 2 additions & 0 deletions lib/faker/dumb_and_dumber.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Faker
class DumbAndDumber < Base
class << self
Expand Down
6 changes: 4 additions & 2 deletions lib/faker/dune.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Faker
class Dune < Base
class << self
Expand All @@ -22,7 +24,7 @@ def quote(character = nil)
if character.nil?
character = sample(quoted_characters).to_s
else
character.to_s.downcase!
character = character.to_s.downcase

unless quoted_characters.include?(character.to_sym)
raise ArgumentError,
Expand All @@ -39,7 +41,7 @@ def saying(source = nil)
if source.nil?
source = sample(sourced_sayings).to_s
else
source.to_s.downcase!
source = source.to_s.downcase

unless sourced_sayings.include?(source.to_sym)
raise ArgumentError,
Expand Down
2 changes: 2 additions & 0 deletions lib/faker/educator.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Faker
class Educator < Base
flexible :educator
Expand Down
2 changes: 2 additions & 0 deletions lib/faker/elder_scrolls.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Faker
class ElderScrolls < Base
class << self
Expand Down
2 changes: 2 additions & 0 deletions lib/faker/electrical_components.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Faker
class ElectricalComponents < Base
flexible :electrical_components
Expand Down
Loading

0 comments on commit ad3856b

Please sign in to comment.