Class: WhatsupGithub::Config
- Inherits:
-
Object
- Object
- WhatsupGithub::Config
- Includes:
- Singleton
- Defined in:
- lib/whatsup_github/config_reader.rb
Overview
Creates readable objects from confirurarion files
Constant Summary collapse
- @@filename =
''
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Class Method Summary collapse
Instance Method Summary collapse
- #base_branch ⇒ Object
- #enterprise ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #labels ⇒ Object
- #magic_word ⇒ Object
- #membership ⇒ Object
- #optional_labels ⇒ Object
- #output_format ⇒ Object
- #read ⇒ Object
- #repos ⇒ Object
- #required_labels ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
20 21 22 23 |
# File 'lib/whatsup_github/config_reader.rb', line 20 def initialize @file = @@filename @config = {} end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
10 11 12 |
# File 'lib/whatsup_github/config_reader.rb', line 10 def config @config end |
Class Method Details
.filename=(filename) ⇒ Object
16 17 18 |
# File 'lib/whatsup_github/config_reader.rb', line 16 def self.filename=(filename) @@filename = filename end |
Instance Method Details
#base_branch ⇒ Object
40 41 42 |
# File 'lib/whatsup_github/config_reader.rb', line 40 def base_branch read['base_branch'] end |
#enterprise ⇒ Object
74 75 76 |
# File 'lib/whatsup_github/config_reader.rb', line 74 def enterprise read['enterprise'] end |
#labels ⇒ Object
48 49 50 |
# File 'lib/whatsup_github/config_reader.rb', line 48 def labels required_labels + optional_labels end |
#magic_word ⇒ Object
70 71 72 |
# File 'lib/whatsup_github/config_reader.rb', line 70 def magic_word read['magic_word'] end |
#membership ⇒ Object
66 67 68 |
# File 'lib/whatsup_github/config_reader.rb', line 66 def membership read['membership'] end |
#optional_labels ⇒ Object
59 60 61 62 63 64 |
# File 'lib/whatsup_github/config_reader.rb', line 59 def optional_labels res = read.dig 'labels', 'optional' return [] unless res res end |
#output_format ⇒ Object
44 45 46 |
# File 'lib/whatsup_github/config_reader.rb', line 44 def output_format read['output_format'] end |
#read ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/whatsup_github/config_reader.rb', line 25 def read unless File.exist?(@file) dist_file = File.("../template/#{@file}", __dir__) FileUtils.cp dist_file, @file end @config = YAML.load_file @file return {} unless @config @config end |
#repos ⇒ Object
36 37 38 |
# File 'lib/whatsup_github/config_reader.rb', line 36 def repos read['repos'] end |
#required_labels ⇒ Object
52 53 54 55 56 57 |
# File 'lib/whatsup_github/config_reader.rb', line 52 def required_labels res = read.dig 'labels', 'required' return [] unless res res end |