Compare commits

...

5 Commits

Author SHA1 Message Date
Petr Korolev
3450250a02 remove unused puts 2016-07-21 17:47:05 +03:00
Petr Korolev
6f9200e018 add missing test 2016-07-21 17:47:05 +03:00
Petr Korolev
6fc06a2d3d rename methods to match of it's actions 2016-07-21 17:47:05 +03:00
John Keiser
85f8ccae03 Constrain JSON to < 2.0 so we can test on ruby 1.9 2016-07-21 17:47:04 +03:00
John Keiser
5ac411c177 Don't constrain runtime deps.
Since we are a development dependency of many projects,
constraining our runtime deps can cause their Gemfiles to downgrade
dependencies they share with us, which is never desirable.
2016-07-21 17:47:04 +03:00
7 changed files with 58 additions and 49 deletions

View File

@ -10,4 +10,6 @@ group :test do
gem "coveralls", "~>0.8", require: false
gem "simplecov", "~>0.10", require: false
gem "codeclimate-test-reporter", "~>0.4"
# JSON 2.0.1 is ruby 2.0+
gem "json", "< 2.0"
end

View File

@ -2,23 +2,23 @@ PATH
remote: .
specs:
github_changelog_generator (1.13.0)
colorize (~> 0.7)
github_api (~> 0.12)
colorize (>= 0.7)
github_api (>= 0.12)
rake (>= 10.0)
GEM
remote: https://rubygems.org/
specs:
addressable (2.4.0)
ast (2.2.0)
ast (2.3.0)
childprocess (0.5.9)
ffi (~> 1.0, >= 1.0.11)
codeclimate-test-reporter (0.5.0)
codeclimate-test-reporter (0.6.0)
simplecov (>= 0.7.1, < 1.0.0)
colorize (0.7.7)
coveralls (0.8.13)
json (~> 1.8)
simplecov (~> 0.11.0)
colorize (0.8.1)
coveralls (0.8.14)
json (>= 1.8, < 3)
simplecov (~> 0.12.0)
term-ansicolor (~> 1.3)
thor (~> 0.19.1)
tins (~> 1.6.0)
@ -28,59 +28,58 @@ GEM
docile (1.1.5)
faraday (0.9.2)
multipart-post (>= 1.2, < 3)
ffi (1.9.10)
github_api (0.13.1)
ffi (1.9.14)
github_api (0.14.4)
addressable (~> 2.4.0)
descendants_tracker (~> 0.0.4)
faraday (~> 0.8, < 0.10)
hashie (>= 3.4)
multi_json (>= 1.7.5, < 2.0)
oauth2
oauth2 (~> 1.0.0)
hashie (3.4.4)
iniparse (1.4.2)
json (1.8.3)
jwt (1.5.1)
multi_json (1.12.0)
jwt (1.5.4)
multi_json (1.12.1)
multi_xml (0.5.5)
multipart-post (2.0.0)
oauth2 (1.1.0)
oauth2 (1.0.0)
faraday (>= 0.8, < 0.10)
jwt (~> 1.0, < 1.5.2)
jwt (~> 1.0)
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (>= 1.2, < 3)
overcommit (0.33.0)
rack (~> 1.2)
overcommit (0.34.2)
childprocess (~> 0.5.8)
iniparse (~> 1.4)
parser (2.3.1.0)
parser (2.3.1.2)
ast (~> 2.2)
powerpack (0.1.1)
rack (1.6.4)
rainbow (2.1.0)
rake (11.1.2)
rspec (3.4.0)
rspec-core (~> 3.4.0)
rspec-expectations (~> 3.4.0)
rspec-mocks (~> 3.4.0)
rspec-core (3.4.4)
rspec-support (~> 3.4.0)
rspec-expectations (3.4.0)
rake (11.2.2)
rspec (3.5.0)
rspec-core (~> 3.5.0)
rspec-expectations (~> 3.5.0)
rspec-mocks (~> 3.5.0)
rspec-core (3.5.1)
rspec-support (~> 3.5.0)
rspec-expectations (3.5.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.4.0)
rspec-mocks (3.4.1)
rspec-support (~> 3.5.0)
rspec-mocks (3.5.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.4.0)
rspec-support (3.4.1)
rubocop (0.39.0)
parser (>= 2.3.0.7, < 3.0)
rspec-support (~> 3.5.0)
rspec-support (3.5.0)
rubocop (0.41.2)
parser (>= 2.3.1.1, < 3.0)
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-progressbar (1.8.0)
simplecov (0.11.2)
ruby-progressbar (1.8.1)
simplecov (0.12.0)
docile (~> 1.1.0)
json (~> 1.8)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.0)
term-ansicolor (1.3.2)
@ -88,7 +87,7 @@ GEM
thor (0.19.1)
thread_safe (0.3.5)
tins (1.6.0)
unicode-display_width (1.0.5)
unicode-display_width (1.1.0)
PLATFORMS
ruby
@ -98,6 +97,7 @@ DEPENDENCIES
codeclimate-test-reporter (~> 0.4)
coveralls (~> 0.8)
github_changelog_generator!
json (< 2.0)
overcommit
rake
rspec (>= 3.2)

View File

@ -24,11 +24,11 @@ Gem::Specification.new do |spec|
spec.require_paths = ["lib"]
spec.add_runtime_dependency "rake", ">= 10.0"
spec.add_runtime_dependency("github_api", ["~> 0.12"])
spec.add_runtime_dependency("colorize", ["~> 0.7"])
spec.add_runtime_dependency "github_api", ">= 0.12"
spec.add_runtime_dependency "colorize", ">= 0.7"
spec.add_development_dependency("overcommit", ">= 0.31")
spec.add_development_dependency("rspec", ">= 3.2")
spec.add_development_dependency "overcommit", ">= 0.31"
spec.add_development_dependency "rspec", ">= 3.2"
spec.add_development_dependency "bundler", ">= 1.7"
spec.add_development_dependency("rubocop", ">= 0.31")
spec.add_development_dependency "rubocop", ">= 0.31"
end

View File

@ -14,7 +14,7 @@ module GitHubChangelogGenerator
parser = setup_parser(options)
parser.parse!
user_and_project_from_git(options)
fetch_user_and_project(options)
abort(parser.banner) unless options[:user] && options[:project]
@ -208,14 +208,17 @@ module GitHubChangelogGenerator
end
# If `:user` or `:project` not set in options, try setting them
def self.user_and_project_from_git(options)
# Valid unnamed parameters:
# 1) in 1 param: repo_name/project
# 2) in 2 params: repo name project
def self.fetch_user_and_project(options)
if options[:user].nil? || options[:project].nil?
detect_user_and_project(options, ARGV[0], ARGV[1])
user_and_project_from_git(options, ARGV[0], ARGV[1])
end
end
# Sets `:user` and `:project` in `options` from CLI arguments or `git remote`
def self.detect_user_and_project(options, arg0 = nil, arg1 = nil)
def self.user_and_project_from_git(options, arg0 = nil, arg1 = nil)
options[:user], options[:project] = user_project_from_option(arg0, arg1, options[:github_site])
return if options[:user] && options[:project]
@ -245,7 +248,6 @@ module GitHubChangelogGenerator
if arg0 && !arg1
# this match should parse strings such "https://github.com/skywinder/Github-Changelog-Generator" or
# "skywinder/Github-Changelog-Generator" to user and name
puts arg0
match = /(?:.+#{Regexp.escape(github_site)}\/)?(.+)\/(.+)/.match(arg0)
begin

View File

@ -46,7 +46,7 @@ module GitHubChangelogGenerator
# mimick parse_options
options = Parser.default_options
Parser.user_and_project_from_git(options)
Parser.fetch_user_and_project(options)
OPTIONS.each do |o|
v = instance_variable_get("@#{o}")

View File

@ -48,7 +48,7 @@ describe GitHubChangelogGenerator::ParserFile do
header: "=== Changelog ==="))
end
context "turns exclude-labels into an Array", bug: '#327' do
context "turns exclude-labels into an Array", bug: "#327" do
let(:file) do
StringIO.new(<<EOF
exclude-labels=73a91042-da6f-11e5-9335-1040f38d7f90,7adf83b4-da6f-11e5-ae18-1040f38d7f90

View File

@ -56,5 +56,10 @@ describe GitHubChangelogGenerator::Parser do
it { is_expected.to be_a(Array) }
it { is_expected.to match_array([nil, nil]) }
end
context "when all args is not nil" do
subject { GitHubChangelogGenerator::Parser.user_project_from_option("skywinder/ActionSheetPicker-3.0", "blah", "https://codeclimate.com") }
it { is_expected.to be_a(Array) }
it { is_expected.to match_array([nil, nil]) }
end
end
end