Class: Gerd::CLI
- Inherits:
-
Thor
- Object
- Thor
- Gerd::CLI
- Defined in:
- lib/gerd/cli.rb
Instance Method Summary collapse
- #apply(organisation) ⇒ Object
- #audit(organisation) ⇒ Object
- #exec(script) ⇒ Object
- #validate(organisation) ⇒ Object
Instance Method Details
#apply(organisation) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/gerd/cli.rb', line 47 def apply(organisation) token = [:token] if [:token] client = Gerd::GHClient.create(token) auditor = Gerd::Audit.new(client, organisation) expected_state = Gerd::Model::GithubState.from_json(File.read([:file])) actual_state = Gerd::Model::GithubState.new(auditor.full_audit) validator = Gerd::Validation::Validator.new(expected_state, actual_state) actions = validator.collect_actions.flatten actions.each do | action | action.invoke(client, ) end end |
#audit(organisation) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/gerd/cli.rb', line 18 def audit(organisation) token = [:token] if [:token] client = Gerd::GHClient.create(token) auditor = Gerd::Audit.new(client, organisation) content = auditor.full_audit formatter = Gerd::Formatters.find_formatter([:file]) formatter.print(content, ) end |
#exec(script) ⇒ Object
63 64 65 66 67 68 69 70 71 |
# File 'lib/gerd/cli.rb', line 63 def exec(script) current_state = Gerd::Model::GithubState.from_json(File.read([:input])) script = File.read(script) exec_helper = Gerd::Helpers::Exec.new(script) exec_helper.exec(current_state) formatter = Gerd::Formatters.find_formatter([:output]) formatter.print(current_state.serialize, ) end |
#validate(organisation) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/gerd/cli.rb', line 31 def validate(organisation) token = [:token] if [:token] client = Gerd::GHClient.create(token) auditor = Gerd::Audit.new(client, organisation) expected_state = Gerd::Model::GithubState.from_json(File.read([:expected])) actual_state = Gerd::Model::GithubState.new(auditor.full_audit) validator = Gerd::Validation::Validator.new(expected_state, actual_state) content = validator.validate formatter = Gerd::Formatters.find_formatter([:file]) formatter.print(content, ) end |