Rspec and README

This commit is contained in:
Dlani Mendes
2015-09-15 15:38:41 -03:00
committed by Petr Korolev
parent 31b4294ed6
commit ba7c565374
8 changed files with 65 additions and 12 deletions
+3 -3
View File
@@ -9,12 +9,12 @@ module GitHubChangelogGenerator
def self.parse_options
options = get_default_options
parser_file = ParserFile.new options
parser_file.parse!
parser = setup_parser(options)
parser.parse!
parser_file = ParseFile.new options
parser_file.parse!
if options[:user].nil? || options[:project].nil?
detect_user_and_project(options, ARGV[0], ARGV[1])
end
+16 -8
View File
@@ -1,15 +1,15 @@
module GitHubChangelogGenerator
class ParseFile
class ParserFile
def initialize(options)
@options = options
end
def file
File.expand_path(".github_changelog_generator")
File.expand_path(@options[:params_file] || ".github_changelog_generator")
end
def has_file?
File.exists?(file)
def file?
File.exist?(file)
end
def file_open
@@ -17,12 +17,20 @@ module GitHubChangelogGenerator
end
def parse!
return false unless has_file?
return unless file?
file_open.each do |line|
key, value = line.split("=")
key_sym = key.sub('-', '_').to_sym
@options[key_sym] = value.gsub(/[\n\r]+/, '')
begin
key, value = line.split("=")
key_sym = key.sub("-", "_").to_sym
value = value.gsub(/[\n\r]+/, "")
value = true if value =~ (/^(true|t|yes|y|1)$/i)
value = false if value =~ (/^(false|f|no|n|0)$/i)
@options[key_sym] = value
rescue
raise "File #{file} is incorrect in line \"#{line.gsub(/[\n\r]+/, '')}\""
end
end
@options
end
end
end