-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add generators for random IDs and secrets
- Loading branch information
1 parent
4e3ff8c
commit f1abcb3
Showing
5 changed files
with
122 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require 'formatron/generators/util' | ||
|
||
class Formatron | ||
class CLI | ||
module Generators | ||
# CLI command for databag secret generator | ||
module DatabagSecret | ||
def databag_secret_action(c) | ||
c.action do |_args, _options| | ||
puts Formatron::Generators::Util.databag_secret | ||
end | ||
end | ||
|
||
def databag_secret_formatron_command | ||
command :'generate data bag secret' do |c| | ||
c.syntax = 'formatron generate data bag secret [options]' | ||
c.summary = 'Generate a random data bag secret' | ||
c.description = 'Generate a random data bag secret' | ||
databag_secret_action c | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require 'formatron/generators/util' | ||
|
||
class Formatron | ||
class CLI | ||
module Generators | ||
# CLI command for GUID generator | ||
module GUID | ||
def guid_action(c) | ||
c.action do |_args, _options| | ||
puts Formatron::Generators::Util.guid | ||
end | ||
end | ||
|
||
def guid_formatron_command | ||
command :'generate guid' do |c| | ||
c.syntax = 'formatron generate guid [options]' | ||
c.summary = 'Generate a random GUID' | ||
c.description = 'Generate a random GUID' | ||
guid_action c | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
require 'spec_helper' | ||
|
||
require 'formatron/cli' | ||
require 'formatron/cli/generators/databag_secret' | ||
|
||
describe Formatron::CLI::Generators::DatabagSecret do | ||
include FakeFS::SpecHelpers | ||
|
||
# Test harness | ||
class Test < Formatron::CLI | ||
include Formatron::CLI::Generators::DatabagSecret | ||
end | ||
|
||
before(:each) do | ||
allow(Commander::Runner).to receive(:instance) do | ||
@singleton ||= | ||
Commander::Runner.new [ | ||
'generate', | ||
'data', | ||
'bag', | ||
'secret', | ||
'-t' | ||
] | ||
end | ||
end | ||
|
||
it 'should print a data bag secret' do | ||
expect( | ||
Formatron::Generators::Util | ||
).to receive(:databag_secret).once.with( | ||
no_args | ||
) | ||
Test.new.run | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
require 'spec_helper' | ||
|
||
require 'formatron/cli' | ||
require 'formatron/cli/generators/guid' | ||
|
||
describe Formatron::CLI::Generators::GUID do | ||
include FakeFS::SpecHelpers | ||
|
||
# Test harness | ||
class Test < Formatron::CLI | ||
include Formatron::CLI::Generators::GUID | ||
end | ||
|
||
before(:each) do | ||
allow(Commander::Runner).to receive(:instance) do | ||
@singleton ||= | ||
Commander::Runner.new [ | ||
'generate', | ||
'guid', | ||
'-t' | ||
] | ||
end | ||
end | ||
|
||
it 'should print a GUID' do | ||
expect( | ||
Formatron::Generators::Util | ||
).to receive(:guid).once.with( | ||
no_args | ||
) | ||
Test.new.run | ||
end | ||
end |