Move all variables to constants.rb

Add example file to git
This commit is contained in:
Petr Korolev 2014-11-04 17:28:39 +02:00
parent cf741d9a7c
commit 6775e9808d
3 changed files with 25 additions and 23 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
output.txt output.txt
constants.rb

View File

@ -3,14 +3,7 @@
require 'github_api' require 'github_api'
require 'json' require 'json'
require_relative 'constants'
@project_path = '/Users/petrkorolev/repo/ActionSheetPicker-3.0'
@github_user = 'skywinder'
@github_repo_name = 'ActionSheetPicker-3.0'
tag1 = '1.1.21'
tag2 = '1.2.0'
def print_json(json) def print_json(json)
puts JSON.pretty_generate(json) puts JSON.pretty_generate(json)
@ -22,13 +15,13 @@ end
def findPrevTagDate def findPrevTagDate
value1 = exec_command "git log --tags --simplify-by-decoration --pretty=\"format:%ci %d\" | grep tag" value1 = exec_command "git log --tags --simplify-by-decoration --pretty=\"format:%ci %d\" | grep tag"
unless value1 unless value1
puts 'not found this tag' puts 'not found this tag'
exit exit
end end
scan_results = value1.scan(/.*tag.*/) scan_results = value1.scan(/.*tag.*/)
prev_tag = scan_results[1] prev_tag = scan_results[1]
@ -44,20 +37,25 @@ end
def getAllClosedPullRequests def getAllClosedPullRequests
github = Github.new oauth_token: '8587bb22f6bf125454768a4a19dbcc774ea68d48'
issues = github.pull_requests.list 'skywinder', 'ActionSheetPicker-3.0', :state => 'closed'
json = issues.body
json.each { |dict| if @oauth_token.length
# print_json dict github = Github.new oauth_token: @oauth_token
# puts "##{dict[:number]} - #{dict[:title]} (#{dict[:closed_at]})" else
} github = Github.new
end
issues = github.pull_requests.list @github_user, @github_repo_name, :state => 'closed'
json = issues.body
json.each { |dict|
# print_json dict
# puts "##{dict[:number]} - #{dict[:title]} (#{dict[:closed_at]})"
}
json
json
end end
def compund_changelog(tag_time, pull_requests)
def compund_changelog (tag_time, pull_requests)
log = '' log = ''
last_tag = exec_command('git describe --abbrev=0 --tags').strip last_tag = exec_command('git describe --abbrev=0 --tags').strip
log += "## [#{last_tag}] (https://github.com/#{@github_user}/#{@github_repo_name}/tree/#{last_tag})\n" log += "## [#{last_tag}] (https://github.com/#{@github_user}/#{@github_repo_name}/tree/#{last_tag})\n"
@ -67,7 +65,7 @@ def compund_changelog (tag_time, pull_requests)
pull_requests.each { |dict| pull_requests.each { |dict|
merge = "#{dict[:title]} ([\\##{dict[:number]}](https://github.com/#{@github_user}/#{@github_repo_name}/pull/#{dict[:number]}))\n" merge = "#{dict[:title]} ([\\##{dict[:number]}](https://github.com/#{@github_user}/#{@github_repo_name}/pull/#{dict[:number]}))\n"
log += "- #{merge}" log += "- #{merge}"
} }
puts log puts log
@ -84,5 +82,4 @@ pull_requests.delete_if { |req|
t < tag_time t < tag_time
} }
compund_changelog tag_time, pull_requests
compund_changelog(tag_time, pull_requests)

4
dummy_constants.rb Normal file
View File

@ -0,0 +1,4 @@
@project_path = '/path/to/project'
@github_user = 'login'
@github_repo_name = 'projectName'
@oauth_token = 'your40digitGitHubToken'