Class: Jirify::Config
- Inherits:
-
Object
- Object
- Jirify::Config
- Defined in:
- lib/jirify/config.rb
Constant Summary collapse
- CONFIG_FOLDER =
"#{Dir.home}/.jirify".freeze
- CONFIG_FILE =
"#{CONFIG_FOLDER}/.jirify".freeze
Class Method Summary collapse
- .always_verbose ⇒ Object
- .atlassian_url ⇒ Object
- .client_options ⇒ Object
- .config_file ⇒ Object
- .config_folder ⇒ Object
- .copy_bash_completion! ⇒ Object
- .initialize! ⇒ Object
- .initialized? ⇒ Boolean
- .issue_browse_url ⇒ Object
- .options ⇒ Object
- .projects ⇒ Object
- .projects=(value) ⇒ Object
- .statuses ⇒ Object
- .transitions ⇒ Object
- .username ⇒ Object
- .verbose=(value) ⇒ Object
- .write(config) ⇒ Object
Class Method Details
.always_verbose ⇒ Object
72 73 74 |
# File 'lib/jirify/config.rb', line 72 def always_verbose ['verbose'] end |
.atlassian_url ⇒ Object
76 77 78 |
# File 'lib/jirify/config.rb', line 76 def atlassian_url ['site'] end |
.client_options ⇒ Object
127 128 129 130 131 132 133 134 135 |
# File 'lib/jirify/config.rb', line 127 def { username: ['username'], password: ['token'], site: atlassian_url, context_path: '', auth_type: :basic } end |
.config_file ⇒ Object
15 16 17 18 |
# File 'lib/jirify/config.rb', line 15 def config_file initialize! unless initialized? @config_file ||= CONFIG_FILE end |
.config_folder ⇒ Object
10 11 12 13 |
# File 'lib/jirify/config.rb', line 10 def config_folder initialize! unless initialized? @config_folder ||= CONFIG_FOLDER end |
.copy_bash_completion! ⇒ Object
30 31 32 |
# File 'lib/jirify/config.rb', line 30 def copy_bash_completion! FileUtils.cp "#{File.('..', File.dirname(__dir__))}/jirify.bash_completion.sh", CONFIG_FOLDER end |
.initialize! ⇒ Object
24 25 26 27 28 |
# File 'lib/jirify/config.rb', line 24 def initialize! FileUtils.mkdir_p CONFIG_FOLDER FileUtils.touch CONFIG_FILE copy_bash_completion! end |
.initialized? ⇒ Boolean
20 21 22 |
# File 'lib/jirify/config.rb', line 20 def initialized? File.directory?(CONFIG_FOLDER) && File.exist?(CONFIG_FILE) end |
.issue_browse_url ⇒ Object
88 89 90 |
# File 'lib/jirify/config.rb', line 88 def issue_browse_url "#{atlassian_url}/browse/" end |
.options ⇒ Object
63 64 65 66 67 68 69 70 |
# File 'lib/jirify/config.rb', line 63 def unless initialized? puts ColorizedString['ERROR: You must initialize Jirify first!'].white.on_red.bold exit(0) end @options ||= YAML.load_file(config_file)['options'] end |
.projects ⇒ Object
84 85 86 |
# File 'lib/jirify/config.rb', line 84 def projects ['projects'] end |
.projects=(value) ⇒ Object
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/jirify/config.rb', line 41 def projects=(value) unless initialized? puts ColorizedString['ERROR: You must initialize Jirify first!'].white.on_red.bold exit(0) end config = YAML.load_file(config_file) config['options']['projects'] = value write(config) end |
.statuses ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/jirify/config.rb', line 92 def statuses default = { 'blocked' => 'Blocked', 'todo' => 'To Do', 'in_progress' => 'In Progress', 'in_review' => 'In Review', 'done' => 'Closed' } if initialized? ['statuses'] || default else default end end |
.transitions ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/jirify/config.rb', line 108 def transitions default = { 'block' => 'Blocked', 'unblock' => 'Unblock', 'start' => 'Start Progress', 'stop' => 'Stop Progress', 'start_review' => 'Code Review', 'stop_review' => 'Back to In Progress', 'close' => 'Close', 'reopen' => 'Reopen' } if initialized? ['transitions'] || default else default end end |
.username ⇒ Object
80 81 82 |
# File 'lib/jirify/config.rb', line 80 def username ['username'] end |
.verbose=(value) ⇒ Object
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/jirify/config.rb', line 52 def verbose=(value) unless initialized? puts ColorizedString['ERROR: You must initialize Jirify first!'].white.on_red.bold exit(0) end config = YAML.load_file(config_file) config['options']['verbose'] = value write(config) end |
.write(config) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/jirify/config.rb', line 34 def write(config) puts 'Writing config:' puts config.to_yaml File.write(config_file, config.to_yaml) end |