Docs
This commit is contained in:
		
							parent
							
								
									0b32484184
								
							
						
					
					
						commit
						6b64d4e4a2
					
				@ -3,22 +3,28 @@ require "pathname"
 | 
				
			|||||||
module GitHubChangelogGenerator
 | 
					module GitHubChangelogGenerator
 | 
				
			||||||
  ParserError = Class.new(StandardError)
 | 
					  ParserError = Class.new(StandardError)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  # ParserFile is a configuration file reader which sets options in the
 | 
				
			||||||
 | 
					  # given Hash.
 | 
				
			||||||
 | 
					  #
 | 
				
			||||||
 | 
					  # In your project's root, you can put a file named
 | 
				
			||||||
 | 
					  # <tt>.github_changelog_generator</tt> to override defaults:
 | 
				
			||||||
 | 
					  #
 | 
				
			||||||
 | 
					  # Example:
 | 
				
			||||||
 | 
					  #   header_label=# My Super Changelog
 | 
				
			||||||
 | 
					  #   future-release=5.0.0
 | 
				
			||||||
 | 
					  #   since-tag=1.0.0
 | 
				
			||||||
 | 
					  #
 | 
				
			||||||
 | 
					  # The configuration format is <tt>some-key=value</tt> or <tt>some_key=value</tt>.
 | 
				
			||||||
 | 
					  #
 | 
				
			||||||
  class ParserFile
 | 
					  class ParserFile
 | 
				
			||||||
    FILENAME = ".github_changelog_generator"
 | 
					    # @param options [Hash] options to be configured from file contents
 | 
				
			||||||
 | 
					    # @param file [nil,IO] configuration file handle, defaults to opening `.github_changelog_generator`
 | 
				
			||||||
    # @param options [Hash]
 | 
					 | 
				
			||||||
    # @param file [nil,IO]
 | 
					 | 
				
			||||||
    def initialize(options, file = read_default_file)
 | 
					    def initialize(options, file = read_default_file)
 | 
				
			||||||
      @options = options
 | 
					      @options = options
 | 
				
			||||||
      @file = file
 | 
					      @file = file
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def read_default_file
 | 
					    # Sets options using configuration file content
 | 
				
			||||||
      path = Pathname(File.expand_path(FILENAME))
 | 
					 | 
				
			||||||
      File.open(path) if path.exist?
 | 
					 | 
				
			||||||
    end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    # Set @options using configuration file lines.
 | 
					 | 
				
			||||||
    def parse!
 | 
					    def parse!
 | 
				
			||||||
      return unless @file
 | 
					      return unless @file
 | 
				
			||||||
      @file.each_with_index { |line, i| parse_line!(line, i + 1) }
 | 
					      @file.each_with_index { |line, i| parse_line!(line, i + 1) }
 | 
				
			||||||
@ -27,6 +33,13 @@ module GitHubChangelogGenerator
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    private
 | 
					    private
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    FILENAME = ".github_changelog_generator"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def read_default_file
 | 
				
			||||||
 | 
					      path = Pathname(File.expand_path(FILENAME))
 | 
				
			||||||
 | 
					      File.open(path) if path.exist?
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def parse_line!(line, line_number)
 | 
					    def parse_line!(line, line_number)
 | 
				
			||||||
      option_name, value = extract_pair(line)
 | 
					      option_name, value = extract_pair(line)
 | 
				
			||||||
      @options[option_key_for(option_name)] = convert_value(value, option_name)
 | 
					      @options[option_key_for(option_name)] = convert_value(value, option_name)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user