Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support search for ruby less than 2.4.0 #12

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
require "bundler/gem_tasks"
require "rspec/core/rake_task"
# frozen_string_literal: true

require 'bundler/gem_tasks'
require 'rspec/core/rake_task'

RSpec::Core::RakeTask.new(:spec)

task :default => :spec
task default: :spec
1 change: 1 addition & 0 deletions bin/console
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require 'bundler/setup'
require 'fakerbot'
Expand Down
2 changes: 1 addition & 1 deletion bin/fakerbot
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# frozen_string_literal: true

lib_path = File.expand_path('../lib', __dir__)
$:.unshift(lib_path) if !$:.include?(lib_path)
$LOAD_PATH.unshift(lib_path) unless $LOAD_PATH.include?(lib_path)
require 'fakerbot'

Signal.trap('INT') do
Expand Down
2 changes: 2 additions & 0 deletions lib/fakerbot.rb
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# frozen_string_literal: true

require_relative 'fakerbot/cli'
2 changes: 1 addition & 1 deletion lib/fakerbot/reflector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def all_descendants_with_methods
def search_descendants_matching_query
faker_descendants.each do |faker|
methods = faker.my_singleton_methods
matching = methods.select { |m| m.match?(/#{query}/i) }
matching = methods.select { |m| m.match(/#{query}/i) }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! 🏅

store(faker, matching)
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/fakerbot/renderer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def verbose?

def verbose_output(method, const, arr)
fake, message = faker_method(method, const)
arr << crayon.dim.white("=> #{fake.to_s}") << crayon.dim.magenta.bold("#{message}")
arr << crayon.dim.white("=> #{fake}") << crayon.dim.magenta.bold(message.to_s)
end

def faker_method(method, const)
Expand All @@ -78,7 +78,7 @@ def faker_method(method, const)
end

def ensure_method_is_supported(method, const)
const.respond_to?(:"_deprecated_#{method.to_s}") ? ' ( WILL BE DEPRECATED )' : ''
const.respond_to?(:"_deprecated_#{method}") ? ' ( WILL BE DEPRECATED )' : ''
end
end
end
4 changes: 3 additions & 1 deletion lib/fakerbot/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module FakerBot
VERSION = '0.4.1'.freeze
VERSION = '0.4.1'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's bump the version here to 0.4.2 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

end
2 changes: 1 addition & 1 deletion spec/integration/list_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
-v, [--verbose], [--no-verbose] # Include sample Faker output

List all Faker constants
OUT
OUT

expect(output).to match(expected_output)
end
Expand Down
2 changes: 1 addition & 1 deletion spec/integration/search_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
-v, [--verbose], [--no-verbose] # Include sample Faker output

Search Faker method(s)
OUT
OUT
expect(output).to match(expected_output)
end

Expand Down