gem_version_check 0.4.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8bd1db58cde70224f31f4d0a283f08627dda7602
4
- data.tar.gz: a7d84e09918e55442450d5dafda05030544cddfe
3
+ metadata.gz: ca4555e0f6aa6c50880e033511160aff7734589e
4
+ data.tar.gz: 920cf30fe393e38b8c5ce21cb5bd33f2e1442d43
5
5
  SHA512:
6
- metadata.gz: 94256027ad6cbea743156b41bdceeaefa543a5c3e0c306acf5fa1754525577a86bb5b4132135b01d92ef38cc3853c3c4e8d00ba5b363067c1b48d402a60fbcab
7
- data.tar.gz: bf51efe889c24d9733d7a77f4923b5f14f19a91986bea636e0953fecac2e3c569d14666b6e8056a27457ad9e92b5fddcac4185f623441733eb99d8698584e320
6
+ metadata.gz: 9469d853daa9133b2febff950eb91631b6b3e3d70084841acee92dda12b342eda56c408b2d472b4ac7151754566eb254bed924dc20c91da4fd0a2f9383d47231
7
+ data.tar.gz: e78b2e6557f2d8260981a297ce417eaa6c0c4730fbe8874091cc8b911d0bb50cffbaca1711bab57d1d8fb219f3da442b257c2f3bdb8ea0894cc937ad98d23b14
data/Rakefile CHANGED
@@ -10,5 +10,5 @@ Bundler::GemHelper.install_tasks
10
10
 
11
11
  require 'rspec/core/rake_task'
12
12
 
13
- RSpec::Core::RakeTask.new
14
- task :default => :spec
13
+ RSpec::Core::RakeTask.new
14
+ task :default => :spec
@@ -1,4 +1,6 @@
1
- require "optparse"
1
+ # frozen_string_literal: true
2
+
3
+ require 'optparse'
2
4
 
3
5
  module GemVersionCheck
4
6
  module Cli
@@ -6,10 +8,10 @@ module GemVersionCheck
6
8
 
7
9
  def run(params)
8
10
  project_names, options = parse(params)
9
- if project_names.size > 0
11
+ if !project_names.empty?
10
12
  generate_report(project_names, options)
11
13
  else
12
- puts "Missing params: gem_version_check my-gh-name/my-project gem1 gem2 gem3"
14
+ puts 'Missing params: gem_version_check my-gh-name/my-project gem1 gem2 gem3'
13
15
  exit(1)
14
16
  end
15
17
  end
@@ -20,49 +22,53 @@ module GemVersionCheck
20
22
  options = {}
21
23
  option_parser = nil
22
24
  project_names = OptionParser.new do |opts|
23
- opts.banner = "Usage: gem_version_check project [options]"
25
+ opts.banner = 'Usage: gem_version_check project [options]'
24
26
 
25
- opts.separator ""
26
- opts.separator "Specific options:"
27
+ opts.separator ''
28
+ opts.separator 'Specific options:'
27
29
 
28
- opts.on("--only gem1,gem2,gem3", Array, "List of ruby gems") do |list|
30
+ opts.on('--only gem1,gem2,gem3', Array, 'List of ruby gems') do |list|
29
31
  options[:only] = list
30
32
  end
31
33
 
32
- opts.on("--except gem1,gem2,gem3", Array, "List of ruby gems") do |list|
34
+ opts.on('--except gem1,gem2,gem3', Array, 'List of ruby gems') do |list|
33
35
  options[:except] = list
34
36
  end
35
37
 
36
- opts.on("--host github.com", String, "Github host name") do |host|
38
+ opts.on('--host github.com', String, 'Github host name') do |host|
37
39
  options[:host] = host
38
40
  end
39
41
 
40
- opts.on("--sources my.gems.org,rubygems.org", String, "Sources to check for new gems versions") do |sources|
42
+ opts.on('--token access-token', String, 'Github access token') do |token|
43
+ options[:token] = token
44
+ end
45
+
46
+ opts.on('--sources my.gems.org,rubygems.org', String, 'Sources to check for new gems versions') do |sources|
41
47
  options[:sources] = sources
42
48
  end
43
49
 
44
- opts.on("--disable-progress-bar", "Disable progress bar") do |disable_progress_bar|
50
+ opts.on('--disable-progress-bar', 'Disable progress bar') do |disable_progress_bar|
45
51
  options[:disable_progress_bar] = disable_progress_bar
46
52
  end
47
53
 
48
- opts.on("--ignore-major-version-change", "Ignore changes of the major version") do |ignore_major_version_change|
54
+ opts.on('--ignore-major-version-change', 'Ignore changes of the major version') do |ignore_major_version_change|
49
55
  options[:ignore_major_version_change] = ignore_major_version_change
50
56
  end
51
57
 
52
- opts.on("--allow-prerelease-dependencies", "Allow dependencies to be prereleases") do |allow_prerelease_dependencies|
58
+ opts.on('--allow-prerelease-dependencies', 'Allow dependencies to be prereleases') do |allow_prerelease_dependencies|
53
59
  options[:allow_prerelease_dependencies] = allow_prerelease_dependencies
54
60
  end
55
61
 
56
- opts.on("--output-format FORMAT", %w(json pretty), "Output format") do |output_format|
62
+ opts.on('--output-format FORMAT', %w[json pretty], 'Output format') do |output_format|
57
63
  options[:output_format] = output_format
58
64
  end
59
65
 
60
- opts.on_tail("--version", "Show version") do
66
+ opts.on_tail('--version', 'Show version') do
61
67
  puts GemVersionCheck::VERSION
62
68
  exit
63
69
  end
64
70
 
65
- opts.on_tail("-h", "--help", "Show this message") do
71
+ opts.on_tail('-h', '--help', 'Show this message') do
66
72
  puts opts
67
73
  exit
68
74
  end
@@ -71,11 +77,12 @@ module GemVersionCheck
71
77
  end.parse!(params)
72
78
 
73
79
  GemVersionCheck.configuration = {
74
- :github_host => options[:host],
75
- :sources => options[:sources],
76
- :show_progress_bar => !options[:disable_progress_bar],
77
- :ignore_major_version_change => options[:ignore_major_version_change],
78
- :allow_prerelease_dependencies => options[:allow_prerelease_dependencies]
80
+ github_host: options[:host],
81
+ sources: options[:sources],
82
+ show_progress_bar: !options[:disable_progress_bar],
83
+ ignore_major_version_change: options[:ignore_major_version_change],
84
+ allow_prerelease_dependencies: options[:allow_prerelease_dependencies],
85
+ token: options[:token]
79
86
  }
80
87
 
81
88
  [Array(project_names), options]
@@ -89,7 +96,7 @@ module GemVersionCheck
89
96
  report = Report.new(project_names, options)
90
97
 
91
98
  case options[:output_format]
92
- when "json"
99
+ when 'json'
93
100
  puts Formatter::JSON.new(report.generate).format
94
101
  else
95
102
  puts Formatter::PrettyPrint.new(report.generate).format
@@ -100,6 +107,5 @@ module GemVersionCheck
100
107
  puts "Can't find Gemfile.lock for #{e}"
101
108
  exit(1)
102
109
  end
103
-
104
110
  end
105
111
  end
@@ -1,13 +1,14 @@
1
1
  module GemVersionCheck
2
2
  class Configuration
3
- attr_reader :github_host, :sources, :show_progress_bar, :ignore_major_version_change, :allow_prerelease_dependencies
3
+ attr_reader :github_host, :sources, :show_progress_bar, :ignore_major_version_change, :allow_prerelease_dependencies, :token
4
4
 
5
5
  def initialize(settings = {})
6
- @github_host = settings[:github_host] || "github.com"
7
- @sources = settings[:sources]
8
- @show_progress_bar = settings[:show_progress_bar] || false
9
- @ignore_major_version_change = settings[:ignore_major_version_change] || false
6
+ @github_host = settings[:github_host] || "github.com"
7
+ @sources = settings[:sources]
8
+ @show_progress_bar = settings[:show_progress_bar] || false
9
+ @ignore_major_version_change = settings[:ignore_major_version_change] || false
10
10
  @allow_prerelease_dependencies = settings[:allow_prerelease_dependencies] || false
11
+ @token = settings[:token]
11
12
  end
12
13
  end
13
14
  end
@@ -28,10 +28,11 @@ module GemVersionCheck
28
28
  # github enterprise does not redirect
29
29
  # TODO: change if github enterprise redirects too
30
30
  def gemfile_lock_url
31
+ host = GemVersionCheck.configuration.github_host
31
32
  if GemVersionCheck.configuration.github_host == "github.com"
32
- "https://raw.#{GemVersionCheck.configuration.github_host}/#{@project}/master/Gemfile.lock"
33
+ "https://raw.#{host}/#{@project}/master/Gemfile.lock"
33
34
  else
34
- "https://#{GemVersionCheck.configuration.github_host}/raw/#{@project}/master/Gemfile.lock"
35
+ "https://#{host}/raw/#{@project}/master/Gemfile.lock"
35
36
  end
36
37
  end
37
38
 
@@ -39,6 +40,9 @@ module GemVersionCheck
39
40
  http = Net::HTTP.new(uri.host, uri.port)
40
41
  http.use_ssl = true if uri.scheme == 'https'
41
42
  request = Net::HTTP::Get.new(uri.request_uri)
43
+ if token = GemVersionCheck.configuration.token
44
+ request.basic_auth token, 'x-oauth-basic'
45
+ end
42
46
  response = http.request(request)
43
47
  if response.code == "200"
44
48
  response.body
@@ -1,3 +1,3 @@
1
1
  module GemVersionCheck
2
- VERSION = "0.4.1"
2
+ VERSION = "0.5.2"
3
3
  end
@@ -5,14 +5,15 @@ module GemVersionCheck
5
5
  describe Configuration do
6
6
  after do
7
7
  end
8
-
8
+
9
9
  it "returns github.com as default github_host" do
10
10
  GemVersionCheck.configuration.github_host.should == "github.com"
11
11
  end
12
12
 
13
13
  it "returns specified value if set" do
14
- GemVersionCheck.configuration = { :github_host => "test" }
14
+ GemVersionCheck.configuration = { :github_host => "test", token: 'teeest' }
15
15
  GemVersionCheck.configuration.github_host.should == "test"
16
+ GemVersionCheck.configuration.token.should == 'teeest'
16
17
  end
17
18
  end
18
- end
19
+ end
@@ -1,7 +1,5 @@
1
- # encoding: utf-8
2
-
3
- require "gem_version_check"
4
- require "mocha/api"
1
+ require 'gem_version_check'
2
+ require 'mocha/api'
5
3
 
6
4
  def lock_file_content(filename)
7
5
  IO.read(File.expand_path("../stubs/#{filename}", __FILE__))
@@ -10,6 +8,6 @@ end
10
8
  RSpec.configure do |config|
11
9
  config.mock_framework = :mocha
12
10
  config.before do
13
- GemVersionCheck.configuration = { :github_host => "github.com" }
11
+ GemVersionCheck.configuration = { github_host: 'github.com', token: 'testtoken' }
14
12
  end
15
13
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gem_version_check
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frederik Dietz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-18 00:00:00.000000000 Z
11
+ date: 2017-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
136
  version: '0'
137
137
  requirements: []
138
138
  rubyforge_project:
139
- rubygems_version: 2.6.7
139
+ rubygems_version: 2.6.14
140
140
  signing_key:
141
141
  specification_version: 4
142
142
  summary: Check your gem dependencies