Class: Torque::Settings
- Inherits:
-
Object
- Object
- Torque::Settings
- Defined in:
- lib/torque/settings.rb
Overview
Stores all of the settings for a release notes generation
Instance Attribute Summary collapse
-
#accept_from ⇒ Object
readonly
The accept-from date.
-
#accept_to ⇒ Object
readonly
The accept-to date.
-
#current_notes_path ⇒ Object
readonly
The path to the most recently generated notes.
-
#custom_date_range ⇒ Object
readonly
True if a custom date range is being used (set manually through the command line), false if using the default one.
-
#email ⇒ Object
readonly
True if should send the notes to the email list after notes are generated, else false.
-
#email_address ⇒ Object
readonly
The email address from which to send notes.
-
#email_password ⇒ Object
readonly
The password to the email address from which to send notes.
-
#email_to ⇒ Object
readonly
A list of email addresses to send the notes to.
-
#last_run_path ⇒ Object
readonly
The path to the .last-run file in the records directory.
-
#output_dir ⇒ Object
readonly
The output directory to use.
-
#project ⇒ Object
readonly
The Pivotal Tracker project ID to use.
-
#record_path ⇒ Object
readonly
The path to the record file of the notes.
-
#root_dir ⇒ Object
readonly
The path to the root directory (the directory which contains a .torqueinfo.yaml file).
-
#silent ⇒ Object
readonly
True if should silence all output, else false.
-
#token ⇒ Object
readonly
The Pivotal Tracker api token to use to access the Pivotal project.
-
#torque_info_path ⇒ Object
readonly
The path to the .torqueinfo.yaml file.
-
#verbose ⇒ Object
readonly
True if should be verbose, else false.
Instance Method Summary collapse
-
#initialize(options = {}, fs = FileSystem.new) ⇒ Settings
constructor
Determines the project settings from the environment.
Constructor Details
#initialize(options = {}, fs = FileSystem.new) ⇒ Settings
Determines the project settings from the environment
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/torque/settings.rb', line 88 def initialize(={}, fs=FileSystem.new) = @fs = fs # Handles basic "true/false" options @email = [:email] || false @silent = [:silent] || false @verbose = [:verbose] || false # Initializes the root directory for Torque @root_dir = [:root_dir] || "." @root_dir = File.(@root_dir) # Parses and processes data from .torqueinfo.yaml @torque_info_path = "#{@root_dir}/.torqueinfo.yaml" torque_info = TorqueInfoParser.new(torque_info_path).parse @email_address = torque_info.email_address @email_password = torque_info.email_password @email_to = torque_info.email_to @output_dir = torque_info.output_dir @project = torque_info.project @token = torque_info.token raise MissingTokenError.new( "API token for Pivotal Tracker has not been set" ) if @token.blank? raise MissingProjectError.new( "Project ID for Pivotal Tracker has not been set" ) if @project.blank? @output_dir = "release_notes" if @output_dir.blank? @output_dir = "#{@root_dir}/#{@output_dir}" if @email_to.class == NilClass; @email_to = [] elsif @email_to.class == String; @email_to = [@email_to] elsif @email_to.class == Array; @email_to = @email_to else; raise "Unknown parsing error on .torqueinfo.yaml's 'email_to' field: #{@email_to}" end # Sets up the output directory, throwing an error if it cannot be found if !@fs.path_exist? @output_dir raise MissingOutputDirectoryError.new( "Could not find the output directory: #{@output_dir}" ) elsif !@fs.path_exist? "#{@output_dir}/previous" @fs.mkdir_p("#{@output_dir}/previous") end # The path to the last-run file for this project @last_run_path = "#{output_dir}/previous/.last-run-#{project}" # Determines the date range within which to accept stories date_settings = DateSettings.new(, @last_run_path, @fs) @accept_from, @accept_to = date_settings.get_dates @custom_date_range = date_settings.custom_date_range? # Sets the path to the main "release-notes.txt" file @current_notes_path = "#{output_dir}/release-notes.txt" # Determines the path name to use for the record of the output file record_pathname_settings = RecordPathnameSettings.new(@output_dir, @project, @custom_date_range, @fs) @record_path = record_pathname_settings.get_path end |
Instance Attribute Details
#accept_from ⇒ Object (readonly)
The accept-from date. All stories accepted on Pivotal Tracker before this date will be ignored
18 19 20 |
# File 'lib/torque/settings.rb', line 18 def accept_from @accept_from end |
#accept_to ⇒ Object (readonly)
The accept-to date. All stories accepted on Pivotal Tracker after this date will be ignored
22 23 24 |
# File 'lib/torque/settings.rb', line 22 def accept_to @accept_to end |
#current_notes_path ⇒ Object (readonly)
The path to the most recently generated notes
26 27 28 |
# File 'lib/torque/settings.rb', line 26 def current_notes_path @current_notes_path end |
#custom_date_range ⇒ Object (readonly)
True if a custom date range is being used (set manually through the command line), false if using the default one
30 31 32 |
# File 'lib/torque/settings.rb', line 30 def custom_date_range @custom_date_range end |
#email ⇒ Object (readonly)
True if should send the notes to the email list after notes are generated, else false
34 35 36 |
# File 'lib/torque/settings.rb', line 34 def email @email end |
#email_address ⇒ Object (readonly)
The email address from which to send notes
38 39 40 |
# File 'lib/torque/settings.rb', line 38 def email_address @email_address end |
#email_password ⇒ Object (readonly)
The password to the email address from which to send notes
42 43 44 |
# File 'lib/torque/settings.rb', line 42 def email_password @email_password end |
#email_to ⇒ Object (readonly)
A list of email addresses to send the notes to
46 47 48 |
# File 'lib/torque/settings.rb', line 46 def email_to @email_to end |
#last_run_path ⇒ Object (readonly)
The path to the .last-run file in the records directory
50 51 52 |
# File 'lib/torque/settings.rb', line 50 def last_run_path @last_run_path end |
#output_dir ⇒ Object (readonly)
The output directory to use
58 59 60 |
# File 'lib/torque/settings.rb', line 58 def output_dir @output_dir end |
#project ⇒ Object (readonly)
The Pivotal Tracker project ID to use
54 55 56 |
# File 'lib/torque/settings.rb', line 54 def project @project end |
#record_path ⇒ Object (readonly)
The path to the record file of the notes
62 63 64 |
# File 'lib/torque/settings.rb', line 62 def record_path @record_path end |
#root_dir ⇒ Object (readonly)
The path to the root directory (the directory which contains a .torqueinfo.yaml file)
66 67 68 |
# File 'lib/torque/settings.rb', line 66 def root_dir @root_dir end |
#silent ⇒ Object (readonly)
True if should silence all output, else false
70 71 72 |
# File 'lib/torque/settings.rb', line 70 def silent @silent end |
#token ⇒ Object (readonly)
The Pivotal Tracker api token to use to access the Pivotal project
74 75 76 |
# File 'lib/torque/settings.rb', line 74 def token @token end |
#torque_info_path ⇒ Object (readonly)
The path to the .torqueinfo.yaml file
78 79 80 |
# File 'lib/torque/settings.rb', line 78 def torque_info_path @torque_info_path end |
#verbose ⇒ Object (readonly)
True if should be verbose, else false
82 83 84 |
# File 'lib/torque/settings.rb', line 82 def verbose @verbose end |