Class: Pgai::Commander
- Inherits:
-
Object
- Object
- Pgai::Commander
- Extended by:
- Forwardable
- Includes:
- Singleton
- Defined in:
- lib/pgai/commander.rb
Instance Attribute Summary collapse
-
#verbosity ⇒ Object
Returns the value of attribute verbosity.
Class Method Summary collapse
Instance Method Summary collapse
- #check_access_token_presence! ⇒ Object
- #config ⇒ Object
- #configure {|_self| ... } ⇒ Object
-
#initialize ⇒ Commander
constructor
A new instance of Commander.
- #logger ⇒ Object
- #port_manager ⇒ Object
- #store ⇒ Object
- #with_env(env_name, &block) ⇒ Object
Constructor Details
#initialize ⇒ Commander
Returns a new instance of Commander.
27 28 29 |
# File 'lib/pgai/commander.rb', line 27 def initialize self.verbosity = :info end |
Instance Attribute Details
#verbosity ⇒ Object
Returns the value of attribute verbosity.
12 13 14 |
# File 'lib/pgai/commander.rb', line 12 def verbosity @verbosity end |
Class Method Details
.configure(options) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/pgai/commander.rb', line 15 def self.configure() instance.tap do |commander| if [:verbose] commander.verbosity = :debug end if [:quiet] commander.verbosity = :error end end end |
Instance Method Details
#check_access_token_presence! ⇒ Object
59 60 61 |
# File 'lib/pgai/commander.rb', line 59 def check_access_token_presence! raise "Access token is not set" unless config&.access_token end |
#config ⇒ Object
35 36 37 |
# File 'lib/pgai/commander.rb', line 35 def config @config ||= Pgai::Resources::Local::Configuration.default end |
#configure {|_self| ... } ⇒ Object
39 40 41 |
# File 'lib/pgai/commander.rb', line 39 def configure yield self end |
#logger ⇒ Object
51 52 53 |
# File 'lib/pgai/commander.rb', line 51 def logger @logger ||= TTY::Logger.new end |
#port_manager ⇒ Object
55 56 57 |
# File 'lib/pgai/commander.rb', line 55 def port_manager @port_manager ||= Port::Manager.new(logger: logger) end |
#store ⇒ Object
31 32 33 |
# File 'lib/pgai/commander.rb', line 31 def store @store ||= Pgai::Store.new end |
#with_env(env_name, &block) ⇒ Object
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/pgai/commander.rb', line 63 def with_env(env_name, &block) check_access_token_presence! env = Resources::Local::Environment.find(env_name) do |env| env.access_token = config.access_token env.clone_prefix = config.clone_prefix end env.prepare(&block) end |