Move version to separate file

This commit is contained in:
Petr Korolev 2014-11-17 17:54:13 +02:00
parent fab1e28e3e
commit 07e0ec0cfb
4 changed files with 397 additions and 385 deletions

View File

@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = "github_changelog_generator"
s.version = "1.1.2"
s.version = GitHubChangelogGenerator::VERSION
s.default_executable = "github_changelog_generator"
s.required_ruby_version = '>= 1.9.3'

View File

@ -6,8 +6,8 @@ require 'httparty'
require 'colorize'
require_relative 'github_changelog_generator/parser'
class ChangelogGenerator
module GitHubChangelogGenerator
class ChangelogGenerator
attr_accessor :options, :all_tags, :github
@ -100,14 +100,14 @@ class ChangelogGenerator
def generate_log_for_all_tags
log = ''
@all_tags.each {|tag| self.get_time_of_tag(tag)}
@all_tags.each { |tag| self.get_time_of_tag(tag) }
if @options[:verbose]
puts "Sorting tags.."
end
@all_tags.sort_by! {|x| self.get_time_of_tag(x)}.reverse!
@all_tags.sort_by! { |x| self.get_time_of_tag(x) }.reverse!
if @options[:verbose]
puts "Generating log.."
@ -361,16 +361,18 @@ class ChangelogGenerator
end
if @options[:verbose]
puts "Filter issues with labels #{@options[:labels]}#{@options[:add_issues_wo_labels]? ' and w/o labels' : ''}: #{filtered_issues.count} issues"
puts "Filter issues with labels #{@options[:labels]}#{@options[:add_issues_wo_labels] ? ' and w/o labels' : ''}: #{filtered_issues.count} issues"
end
filtered_issues
end
end
end
if __FILE__ == $0
if __FILE__ == $0
changelog_generator = ChangelogGenerator.new
changelog_generator.compund_changelog
end
end

View File

@ -1,9 +1,11 @@
#!/usr/bin/env ruby
require 'optparse'
require_relative 'version'
class Parser
module GitHubChangelogGenerator
class Parser
def self.parse_options
options = {:tag1 => nil, :tag2 => nil, :format => '%d/%m/%y', :output => 'CHANGELOG.md', :labels => %w(bug enhancement), :pulls => true, :issues => true, :verbose => true, :add_issues_wo_labels => true, :merge_prefix => '*Merged pull-request:* ' }
options = {:tag1 => nil, :tag2 => nil, :format => '%d/%m/%y', :output => 'CHANGELOG.md', :labels => %w(bug enhancement), :pulls => true, :issues => true, :verbose => true, :add_issues_wo_labels => true, :merge_prefix => '*Merged pull-request:* '}
parser = OptionParser.new { |opts|
opts.banner = 'Usage: changelog_generator [options]'
@ -20,7 +22,7 @@ class Parser
puts opts
exit
end
opts.on('-v', '--[no-]verbose', 'Run verbosely. Default is true') do |v|
opts.on('--[no-]verbose', 'Run verbosely. Default is true') do |v|
options[:verbose] = v
end
opts.on('--[no-]issues', 'Include closed issues to changelog. Default is true') do |v|
@ -44,6 +46,10 @@ class Parser
opts.on('--labels x,y,z', Array, 'List of labels. Issues with that labels will be included to changelog. Default is \'bug,enhancement\'') do |list|
options[:labels] = list
end
opts.on('-v', '--version', 'Print version number') do |v|
puts "Version: #{GitHubChangelogGenerator::VERSION}"
exit
end
}
parser.parse!
@ -78,4 +84,5 @@ class Parser
options
end
end
end

View File

@ -0,0 +1,3 @@
module GitHubChangelogGenerator
VERSION = '1.1.2'
end