Skip to content

Commit

Permalink
adding many more syntax fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
anth1y committed Dec 8, 2023
1 parent 680f1b9 commit ef8cc2a
Show file tree
Hide file tree
Showing 42 changed files with 60 additions and 24 deletions.
2 changes: 1 addition & 1 deletion bin/octofacts-updater
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env ruby
# frozen_literal_string: true
# frozen_string_literal: true
#
require "bundler/setup"
require "octofacts_updater"
Expand Down
2 changes: 1 addition & 1 deletion lib/octofacts.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_literal_string: true
# frozen_string_literal: true
require "octofacts/constructors/from_file"
require "octofacts/constructors/from_index"
require "octofacts/manipulators"
Expand Down
2 changes: 1 addition & 1 deletion lib/octofacts/backends/base.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_literal_string: true
# frozen_string_literal: true
module Octofacts
module Backends
# This is a template class to define the minimum API to be implemented
Expand Down
2 changes: 1 addition & 1 deletion lib/octofacts/backends/index.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_literal_string: true
# frozen_string_literal: true
require "yaml"
require "set"

Expand Down
2 changes: 1 addition & 1 deletion lib/octofacts/backends/yaml_file.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_literal_string: true
# frozen_string_literal: true
#
require "yaml"

Expand Down
1 change: 1 addition & 0 deletions lib/octofacts/constructors/from_index.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Octofacts
# Octofacts.from_index(options) - Construct Octofacts::Facts from an index file.
#
Expand Down
2 changes: 1 addition & 1 deletion lib/octofacts/manipulators/base.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# # frozen_string_literal: true
# frozen_string_literal: true
module Octofacts
class Manipulators
# Delete a fact from a hash.
Expand Down
1 change: 1 addition & 0 deletions lib/octofacts_updater/service/enc.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
# This class contains methods to interact with an external node classifier.

require "open3"
Expand Down
1 change: 1 addition & 0 deletions lib/octofacts_updater/service/local_file.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
# This class reads a YAML file from the local file system so that it can be used as a source
# in octofacts-updater. This was originally intended for a quickstart tutorial, since it requires
# no real configuration. However it could also be used in production, if the user wants to create
Expand Down
1 change: 1 addition & 0 deletions lib/octofacts_updater/service/puppetdb.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
# This class interacts with puppetdb to pull the facts from the recent
# run of Puppet on a given node. This uses octocatalog-diff on the back end to
# pull the facts from puppetdb.
Expand Down
1 change: 1 addition & 0 deletions lib/octofacts_updater/service/ssh.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
# This class interacts with a puppetserver to obtain facts from that server's YAML cache.
# This is achieved by SSH-ing to the server and obtaining the fact file directly from the
# puppetserver's cache. This can also be used to SSH to an actual node and run a command,
Expand Down
1 change: 1 addition & 0 deletions lib/octofacts_updater/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module OctofactsUpdater
VERSION = File.read(File.expand_path("../../.version", File.dirname(__FILE__))).strip
end
1 change: 1 addition & 0 deletions octofacts-updater.gemspec
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
# coding: utf-8

Gem::Specification.new do |spec|
Expand Down
1 change: 1 addition & 0 deletions octofacts.gemspec
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
# coding: utf-8

Gem::Specification.new do |spec|
Expand Down
2 changes: 1 addition & 1 deletion rake/gem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
## 3. Commit changes, PR, and merge to master
## 4. Check out master branch locally
## 5. Run `bundle exec rake gem:release`

# frozen_string_literal: true
require "fileutils"
require "open3"
require "shellwords"
Expand Down
1 change: 1 addition & 0 deletions script/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 "octofacts"
Expand Down
3 changes: 2 additions & 1 deletion spec/integration/modules/test/spec/classes/test_one_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require_relative "../../../../spec/spec_helper"

describe "test::one" do
Expand All @@ -7,7 +8,7 @@
let(:facts) do
{
ec2: true,
ec2_metadata: { placement: { :"availability-zone" => "us-foo-1a" } },
ec2_metadata: { placement: { :"availability-zone" : "us-foo-1a" } },
gid: "root",
id: "root"
}
Expand Down
1 change: 1 addition & 0 deletions spec/integration/spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
# spec_helper for rspec-puppet fixture

require_relative "../../../lib/octofacts"
Expand Down
1 change: 1 addition & 0 deletions spec/octofacts/backends/index_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "spec_helper"

describe Octofacts::Backends::Index do
Expand Down
1 change: 1 addition & 0 deletions spec/octofacts/backends/yaml_file_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "spec_helper"

describe Octofacts::Backends::YamlFile do
Expand Down
1 change: 1 addition & 0 deletions spec/octofacts/constructors/from_file_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "spec_helper"

describe Octofacts do
Expand Down
1 change: 1 addition & 0 deletions spec/octofacts/examples_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
# Make sure the examples in the README document actually work. :-)

require "spec_helper"
Expand Down
1 change: 1 addition & 0 deletions spec/octofacts/facts_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "spec_helper"

describe Octofacts::Facts do
Expand Down
1 change: 1 addition & 0 deletions spec/octofacts/manipulators/base_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "spec_helper"

describe Octofacts::Manipulators do
Expand Down
1 change: 1 addition & 0 deletions spec/octofacts/manipulators/replace_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "spec_helper"
require "yaml"

Expand Down
1 change: 1 addition & 0 deletions spec/octofacts/manipulators_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "spec_helper"

describe Octofacts::Manipulators do
Expand Down
2 changes: 2 additions & 0 deletions spec/octofacts/octofacts_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true
#
require "spec_helper"

# FIXME: Remove when real specs are added
Expand Down
1 change: 1 addition & 0 deletions spec/octofacts/octofacts_spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Octofacts
class Spec
def self.fixture_root
Expand Down
1 change: 1 addition & 0 deletions spec/octofacts/util/config_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "spec_helper"

describe Octofacts::Util::Config do
Expand Down
5 changes: 3 additions & 2 deletions spec/octofacts/util/keys_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
describe Octofacts::Util::Keys do
describe "#downcase_keys!" do
let(:facts) do
Expand All @@ -7,8 +8,8 @@
it "should work" do
f = facts
result = described_class.downcase_keys!(f)
expect(f).to eq({"foo" => "foo-value", baz: "baz-value", "bar" => "bar-value", buzz: "buzz-value"})
expect(result).to eq({"foo" => "foo-value", baz: "baz-value", "bar" => "bar-value", buzz: "buzz-value"})
expect(f).to eq({"foo": "foo-value", baz: "baz-value", "bar": "bar-value", buzz: "buzz-value"})
expect(result).to eq({"foo": "foo-value", baz: "baz-value", "bar": "bar-value", buzz: "buzz-value"})
end
end

Expand Down
1 change: 1 addition & 0 deletions spec/octofacts_updater/fact_index_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "spec_helper"

describe OctofactsUpdater::FactIndex do
Expand Down
1 change: 1 addition & 0 deletions spec/octofacts_updater/fact_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "spec_helper"

describe OctofactsUpdater::Fact do
Expand Down
7 changes: 4 additions & 3 deletions spec/octofacts_updater/fixture_spec.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# frozen_string_literal: true
require "spec_helper"

describe OctofactsUpdater::Fixture do
describe "#make" do
let(:hostname) { "HostName" }
let(:config) {{ "enc" => { "path" => "/foo" }, "puppetdb" => { "url" => "https://puppetdb.example.com:8081" } }}
let(:enc_return) {{ "parameters" => { "fizz" => "buzz" }, "classes" => ["class1", "class2"] }}
let(:fact_hash_with_values) {{ "name" => hostname, "values" => { "foo" => "bar" } }}
let(:config) { { "enc" => { "path" => "/foo" }, "puppetdb" => { "url" => "https://puppetdb.example.com:8081" } } }
let(:enc_return) { { "parameters" => { "fizz" => "buzz" }, "classes" => ["class1", "class2"] } }
let(:fact_hash_with_values) { { "name" => hostname, "values" => { "foo" => "bar" } } }

it "should instantiate and return a fixture object with the given facts" do
expect(OctofactsUpdater::Service::ENC).to receive(:run_enc).with(hostname, config).and_return(enc_return)
Expand Down
1 change: 1 addition & 0 deletions spec/octofacts_updater/octofacts_updater_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "spec_helper"

describe OctofactsUpdater::VERSION do
Expand Down
1 change: 1 addition & 0 deletions spec/octofacts_updater/plugin_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "spec_helper"

describe OctofactsUpdater::Plugin do
Expand Down
1 change: 1 addition & 0 deletions spec/octofacts_updater/plugins/ip_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "spec_helper"
require "ipaddr"

Expand Down
3 changes: 2 additions & 1 deletion spec/octofacts_updater/plugins/ssh_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# frozen_string_literal: true
require "spec_helper"

describe "sshfp_randomize plugin" do
let(:plugin) { OctofactsUpdater::Plugin.plugins[:sshfp_randomize] }
let(:value) { "SSHFP 1 1 0123456789abcdef0123456789abcdef01234567\nSSHFP 1 2 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" }
let(:args) {{ "plugin" => "sshfp_randomize" }}
let(:args) { { "plugin" => "sshfp_randomize" } }

it "should be defined" do
expect(plugin).to be_a_kind_of(Proc)
Expand Down
3 changes: 2 additions & 1 deletion spec/octofacts_updater/plugins/static_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "spec_helper"

describe "delete plugin" do
Expand Down Expand Up @@ -112,7 +113,7 @@
describe "randomize_long_string plugin" do
let(:plugin) { OctofactsUpdater::Plugin.plugins[:randomize_long_string] }
let(:value) { "1234567890abcdef" }
let(:args) {{ "plugin" => "randomize_long_string" }}
let(:args) { { "plugin" => "randomize_long_string" } }

it "should be defined" do
expect(plugin).to be_a_kind_of(Proc)
Expand Down
1 change: 1 addition & 0 deletions spec/octofacts_updater/service/github_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "spec_helper"

require "ostruct"
Expand Down
9 changes: 5 additions & 4 deletions spec/octofacts_updater/service/local_file_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "spec_helper"

describe OctofactsUpdater::Service::LocalFile do
Expand All @@ -8,12 +9,12 @@
context "when localfile is not configured" do
it "should raise ArgumentError when localfile is undefined" do
config = {}
expect{ described_class.facts(node, config) }.to raise_error(ArgumentError, /requires localfile section/)
expect { described_class.facts(node, config) }.to raise_error(ArgumentError, /requires localfile section/)
end

it "should raise ArgumentError when localfile is not a hash" do
config = {"localfile" => :do_it}
expect{ described_class.facts(node, config) }.to raise_error(ArgumentError, /requires localfile section/)
expect { described_class.facts(node, config) }.to raise_error(ArgumentError, /requires localfile section/)
end
end

Expand All @@ -22,12 +23,12 @@

it "should raise error if the path is undefined" do
config = { "localfile" => {} }
expect{ described_class.facts(node, config) }.to raise_error(ArgumentError, /requires 'path' in the localfile section/)
expect { described_class.facts(node, config) }.to raise_error(ArgumentError, /requires 'path' in the localfile section/)
end

it "should raise error if the path does not exist" do
config = { "localfile" => { "path" => File.join(file_path, "missing.yaml") } }
expect{ described_class.facts(node, config) }.to raise_error(Errno::ENOENT, /LocalFile cannot find a file at/)
expect { described_class.facts(node, config) }.to raise_error(Errno::ENOENT, /LocalFile cannot find a file at/)
end

it "should return the proper object from the parsed file" do
Expand Down
11 changes: 6 additions & 5 deletions spec/octofacts_updater/service/ssh_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "spec_helper"

describe OctofactsUpdater::Service::SSH do
Expand All @@ -8,19 +9,19 @@
context "when ssh is not configured" do
it "should raise ArgumentError when ssh is undefined" do
config = {}
expect{ described_class.facts(node, config) }.to raise_error(ArgumentError, /requires ssh section/)
expect { described_class.facts(node, config) }.to raise_error(ArgumentError, /requires ssh section/)
end

it "should raise ArgumentError when ssh is not a hash" do
config = {"ssh" => :do_it}
expect{ described_class.facts(node, config) }.to raise_error(ArgumentError, /requires ssh section/)
expect { described_class.facts(node, config) }.to raise_error(ArgumentError, /requires ssh section/)
end
end

context "when ssh is configured" do
it "should raise error if no server is configured" do
config = { "ssh" => {} }
expect{ described_class.facts(node, config) }.to raise_error(ArgumentError, /requires 'server' in the ssh section/)
expect { described_class.facts(node, config) }.to raise_error(ArgumentError, /requires 'server' in the ssh section/)
end

context "when user is unspecified" do
Expand All @@ -38,14 +39,14 @@

it "should raise error if no user is configured" do
config = { "ssh" => { "server" => "puppetserver.example.net" } }
expect{ described_class.facts(node, config) }.to raise_error(ArgumentError, /requires 'user' in the ssh section/)
expect { described_class.facts(node, config) }.to raise_error(ArgumentError, /requires 'user' in the ssh section/)
end

it "should use USER from environment if no user is configured" do
ENV["USER"] = "ssh-user-from-env"
config = { "ssh" => { "server" => "puppetserver.example.net" } }
expect(Net::SSH).to receive(:start).with("puppetserver.example.net", "ssh-user-from-env", {}).and_raise(custom_exception)
expect{ described_class.facts(node, config) }.to raise_error(custom_exception)
expect { described_class.facts(node, config) }.to raise_error(custom_exception)
end
end

Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
if ENV["SPEC_NAME"]
require "simplecov"
require "simplecov-json"
Expand Down

0 comments on commit ef8cc2a

Please sign in to comment.