Class: Abt::Providers::Harvest::Configuration
- Inherits:
-
Object
- Object
- Abt::Providers::Harvest::Configuration
- Defined in:
- lib/abt/providers/harvest/configuration.rb
Instance Attribute Summary collapse
-
#cli ⇒ Object
Returns the value of attribute cli.
Instance Method Summary collapse
- #access_token ⇒ Object
- #account_id ⇒ Object
- #clear_global(verbose: true) ⇒ Object
- #clear_local(verbose: true) ⇒ Object
-
#initialize(cli:) ⇒ Configuration
constructor
A new instance of Configuration.
- #local_available? ⇒ Boolean
- #path ⇒ Object
- #path=(new_path) ⇒ Object
- #user_id ⇒ Object
Constructor Details
#initialize(cli:) ⇒ Configuration
Returns a new instance of Configuration.
9 10 11 |
# File 'lib/abt/providers/harvest/configuration.rb', line 9 def initialize(cli:) @cli = cli end |
Instance Attribute Details
#cli ⇒ Object
Returns the value of attribute cli.
7 8 9 |
# File 'lib/abt/providers/harvest/configuration.rb', line 7 def cli @cli end |
Instance Method Details
#access_token ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/abt/providers/harvest/configuration.rb', line 33 def access_token return git_global["accessToken"] unless git_global["accessToken"].nil? git_global["accessToken"] = cli.prompt.text([ "Please provide your personal access token for Harvest.", "If you don't have one, create one here: https://id.getharvest.com/developers", "", "Enter access token" ].join("\n")) end |
#account_id ⇒ Object
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/abt/providers/harvest/configuration.rb', line 44 def account_id return git_global["accountId"] unless git_global["accountId"].nil? git_global["accountId"] = cli.prompt.text([ "Please provide harvest account id.", "This information is shown next to your generated access token", "", "Enter account id" ].join("\n")) end |
#clear_global(verbose: true) ⇒ Object
29 30 31 |
# File 'lib/abt/providers/harvest/configuration.rb', line 29 def clear_global(verbose: true) git_global.clear(output: verbose ? cli.err_output : nil) end |
#clear_local(verbose: true) ⇒ Object
25 26 27 |
# File 'lib/abt/providers/harvest/configuration.rb', line 25 def clear_local(verbose: true) git.clear(output: verbose ? cli.err_output : nil) end |
#local_available? ⇒ Boolean
13 14 15 |
# File 'lib/abt/providers/harvest/configuration.rb', line 13 def local_available? git.available? end |
#path ⇒ Object
17 18 19 |
# File 'lib/abt/providers/harvest/configuration.rb', line 17 def path Path.new((local_available? && git["path"]) || cli.directory_config.dig("harvest", "path") || "") end |
#path=(new_path) ⇒ Object
21 22 23 |
# File 'lib/abt/providers/harvest/configuration.rb', line 21 def path=(new_path) git["path"] = new_path end |
#user_id ⇒ Object
55 56 57 58 59 |
# File 'lib/abt/providers/harvest/configuration.rb', line 55 def user_id return git_global["userId"] unless git_global["userId"].nil? git_global["userId"] = api.get("users/me")["id"].to_s end |