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| Gem::Specification.new do |s|
s.name = "github_changelog_generator" s.name = "github_changelog_generator"
s.version = "1.1.2" s.version = GitHubChangelogGenerator::VERSION
s.default_executable = "github_changelog_generator" s.default_executable = "github_changelog_generator"
s.required_ruby_version = '>= 1.9.3' s.required_ruby_version = '>= 1.9.3'

View File

@ -6,8 +6,8 @@ require 'httparty'
require 'colorize' require 'colorize'
require_relative 'github_changelog_generator/parser' require_relative 'github_changelog_generator/parser'
module GitHubChangelogGenerator
class ChangelogGenerator class ChangelogGenerator
attr_accessor :options, :all_tags, :github attr_accessor :options, :all_tags, :github
@ -100,14 +100,14 @@ class ChangelogGenerator
def generate_log_for_all_tags def generate_log_for_all_tags
log = '' log = ''
@all_tags.each {|tag| self.get_time_of_tag(tag)} @all_tags.each { |tag| self.get_time_of_tag(tag) }
if @options[:verbose] if @options[:verbose]
puts "Sorting tags.." puts "Sorting tags.."
end 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] if @options[:verbose]
puts "Generating log.." puts "Generating log.."
@ -361,16 +361,18 @@ class ChangelogGenerator
end end
if @options[:verbose] 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 end
filtered_issues filtered_issues
end end
end end
if __FILE__ == $0 if __FILE__ == $0
changelog_generator = ChangelogGenerator.new changelog_generator = ChangelogGenerator.new
changelog_generator.compund_changelog changelog_generator.compund_changelog
end
end end

View File

@ -1,9 +1,11 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
require 'optparse' require 'optparse'
require_relative 'version'
class Parser module GitHubChangelogGenerator
class Parser
def self.parse_options 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| parser = OptionParser.new { |opts|
opts.banner = 'Usage: changelog_generator [options]' opts.banner = 'Usage: changelog_generator [options]'
@ -20,7 +22,7 @@ class Parser
puts opts puts opts
exit exit
end 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 options[:verbose] = v
end end
opts.on('--[no-]issues', 'Include closed issues to changelog. Default is true') do |v| 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| 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 options[:labels] = list
end end
opts.on('-v', '--version', 'Print version number') do |v|
puts "Version: #{GitHubChangelogGenerator::VERSION}"
exit
end
} }
parser.parse! parser.parse!
@ -78,4 +84,5 @@ class Parser
options options
end end
end
end end

View File

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