Class: AutoTagger::Configuration
- Inherits:
-
Object
- Object
- AutoTagger::Configuration
- Defined in:
- lib/auto_tagger/configuration.rb
Defined Under Namespace
Classes: InvalidRefPath
Instance Method Summary collapse
- #date_separator ⇒ Object
- #dry_run? ⇒ Boolean
- #executable ⇒ Object
- #fetch_refs? ⇒ Boolean
- #file_settings ⇒ Object
-
#initialize(options = {}) ⇒ Configuration
constructor
A new instance of Configuration.
- #offline? ⇒ Boolean
- #opts_file ⇒ Object
- #push_refs? ⇒ Boolean
- #ref_path ⇒ Object
- #refs_to_keep ⇒ Object
- #remote ⇒ Object
- #settings ⇒ Object
- #stage ⇒ Object
- #stages ⇒ Object
- #verbose? ⇒ Boolean
- #working_directory ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Configuration
Returns a new instance of Configuration.
8 9 10 |
# File 'lib/auto_tagger/configuration.rb', line 8 def initialize( = {}) @options = end |
Instance Method Details
#date_separator ⇒ Object
43 44 45 |
# File 'lib/auto_tagger/configuration.rb', line 43 def date_separator settings[:date_separator] ||= "" end |
#dry_run? ⇒ Boolean
47 48 49 |
# File 'lib/auto_tagger/configuration.rb', line 47 def dry_run? settings.fetch(:dry_run, false) end |
#executable ⇒ Object
67 68 69 |
# File 'lib/auto_tagger/configuration.rb', line 67 def executable settings[:executable] || "git" end |
#fetch_refs? ⇒ Boolean
59 60 61 |
# File 'lib/auto_tagger/configuration.rb', line 59 def fetch_refs? !offline? && settings.fetch(:fetch_refs, true) end |
#file_settings ⇒ Object
21 22 23 24 25 26 |
# File 'lib/auto_tagger/configuration.rb', line 21 def file_settings return {} unless File.exists?(opts_file) args = File.read(opts_file).to_s.split("\n").map { |line| line.strip } args.reject! { |line| line == "" } AutoTagger::Options.from_file(args) end |
#offline? ⇒ Boolean
55 56 57 |
# File 'lib/auto_tagger/configuration.rb', line 55 def offline? settings.fetch(:offline, false) end |
#opts_file ⇒ Object
16 17 18 19 |
# File 'lib/auto_tagger/configuration.rb', line 16 def opts_file file = @options[:opts_file] || ".auto_tagger" File. File.join(working_directory, file) end |
#push_refs? ⇒ Boolean
63 64 65 |
# File 'lib/auto_tagger/configuration.rb', line 63 def push_refs? !offline? && settings.fetch(:push_refs, true) end |
#ref_path ⇒ Object
79 80 81 82 83 84 85 |
# File 'lib/auto_tagger/configuration.rb', line 79 def ref_path path = settings[:ref_path] || "tags" if ["heads", "remotes"].include?(path) raise InvalidRefPath, "#{path} is a reserved word in git. Please use something else." end path end |
#refs_to_keep ⇒ Object
71 72 73 |
# File 'lib/auto_tagger/configuration.rb', line 71 def refs_to_keep (settings[:refs_to_keep] || 1).to_i end |
#remote ⇒ Object
75 76 77 |
# File 'lib/auto_tagger/configuration.rb', line 75 def remote settings[:remote] || "origin" end |
#settings ⇒ Object
28 29 30 |
# File 'lib/auto_tagger/configuration.rb', line 28 def settings file_settings.merge(@options) end |
#stage ⇒ Object
38 39 40 41 |
# File 'lib/auto_tagger/configuration.rb', line 38 def stage stage = settings[:stage] || stages.last stage.nil? ? nil : stage.to_s end |
#stages ⇒ Object
32 33 34 35 36 |
# File 'lib/auto_tagger/configuration.rb', line 32 def stages stages = settings[:stages] || [] stages = stages.to_s.split(",").map { |stage| stage.strip } if stages.is_a?(String) stages.reject { |stage| stage.to_s == "" }.map {|stage| stage.to_s } end |
#verbose? ⇒ Boolean
51 52 53 |
# File 'lib/auto_tagger/configuration.rb', line 51 def verbose? settings.fetch(:verbose, false) end |
#working_directory ⇒ Object
12 13 14 |
# File 'lib/auto_tagger/configuration.rb', line 12 def working_directory File.(@options[:path] || Dir.pwd) end |