Skip to content

Commit

Permalink
Fix rubocop issues
Browse files Browse the repository at this point in the history
  • Loading branch information
dunkmann00 committed Feb 28, 2023
1 parent b5e9b62 commit 4bd70ed
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions lib/jekyll-github-metadata/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ def client_inspect
def pluck_auth_method
if ENV["JEKYLL_GITHUB_TOKEN"] || Octokit.access_token
{ :access_token => ENV["JEKYLL_GITHUB_TOKEN"] || Octokit.access_token }
elsif !ENV["NO_NETRC"] && File.exist?(File.join(ENV["HOME"], ".netrc")) && safe_require("netrc")
elsif !ENV["NO_NETRC"] && File.exist?(File.join(Dir.home, ".netrc")) && safe_require("netrc")
{ :netrc => true }
else
GitHubMetadata.log :warn, "No GitHub API authentication could be found." \
" Some fields may be missing or have incorrect data."
GitHubMetadata.log :warn, "No GitHub API authentication could be found. " \
"Some fields may be missing or have incorrect data."
{}.freeze
end
end
Expand Down
12 changes: 6 additions & 6 deletions lib/jekyll-github-metadata/pages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def custom_domains_enabled?
end

def env
env_var "PAGES_ENV", ENV["JEKYLL_ENV"]
env_var "PAGES_ENV", ENV.fetch("JEKYLL_ENV", nil)
end

def repo_pages_html_url_preview?
Expand All @@ -69,19 +69,19 @@ def github_url
end

def api_url
trim_last_slash env_var("PAGES_API_URL", ENV["API_URL"])
trim_last_slash env_var("PAGES_API_URL", ENV.fetch("API_URL", nil))
end

def help_url
trim_last_slash env_var("PAGES_HELP_URL", ENV["HELP_URL"])
trim_last_slash env_var("PAGES_HELP_URL", ENV.fetch("HELP_URL", nil))
end

def github_hostname
trim_last_slash env_var("PAGES_GITHUB_HOSTNAME", ENV["GITHUB_HOSTNAME"])
trim_last_slash env_var("PAGES_GITHUB_HOSTNAME", ENV.fetch("GITHUB_HOSTNAME", nil))
end

def pages_hostname
intermediate_default = ENV["PAGES_HOSTNAME"]
intermediate_default = ENV.fetch("PAGES_HOSTNAME", nil)
intermediate_default ||= "localhost:4000" if development?
trim_last_slash env_var("PAGES_PAGES_HOSTNAME", intermediate_default)
end
Expand All @@ -99,7 +99,7 @@ def configuration
private

def env_var(key, intermediate_default = nil)
!ENV[key].to_s.empty? ? ENV[key] : (intermediate_default || DEFAULTS[key])
!ENV[key].to_s.empty? ? ENV.fetch(key, nil) : (intermediate_default || DEFAULTS[key])
end

def trim_last_slash(url)
Expand Down
8 changes: 4 additions & 4 deletions lib/jekyll-github-metadata/repository_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ def nwo
nwo_from_git_origin_remote || \
proc do
raise NoRepositoryError, "No repo name found. " \
"Specify using PAGES_REPO_NWO environment variables, " \
"'repository' in your configuration, or set up an 'origin' " \
"git remote pointing to your github.com repository."
"Specify using PAGES_REPO_NWO environment variables, " \
"'repository' in your configuration, or set up an 'origin' " \
"git remote pointing to your github.com repository."
end.call
end
end

private

def nwo_from_env
ENV["PAGES_REPO_NWO"]
ENV.fetch("PAGES_REPO_NWO", nil)
end

def nwo_from_config
Expand Down
2 changes: 1 addition & 1 deletion spec/edit_link_tag_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

subject do
tag = described_class.parse(tag_name, markup, tokenizer, parse_context)
tag.instance_variable_set("@context", render_context)
tag.instance_variable_set(:@context, render_context)
tag
end

Expand Down
2 changes: 1 addition & 1 deletion spec/metadata_drop_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@

context "with fallback data" do
let(:fallback_data) { { "foo" => "bar" } }
before { subject.instance_variable_set("@fallback_data", fallback_data) }
before { subject.instance_variable_set(:@fallback_data, fallback_data) }

it "returns the mutated value via #[]" do
expect(subject["foo"]).to eql("bar")
Expand Down
2 changes: 1 addition & 1 deletion spec/repository_finder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@

context "when git doesn't exist" do
before(:each) do
@old_path = ENV["PATH"]
@old_path = ENV.fetch("PATH", nil)
ENV["PATH"] = ""
end
after(:each) { ENV["PATH"] = @old_path }
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helpers/env_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def with_env(*args)
env_hash = env_args_to_hash(*args)
old_env = {}
env_hash.each do |name, value|
old_env[name] = ENV[name]
old_env[name] = ENV.fetch(name, nil)
ENV[name] = value
end
yield
Expand Down

0 comments on commit 4bd70ed

Please sign in to comment.