gem_outdated 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bf04248cc03e25c8364cb4e42ca3cd1ca88bf209
4
+ data.tar.gz: ad977c75d9199f0fd8c2ca2b8c9a5a3fba4854da
5
+ SHA512:
6
+ metadata.gz: 0c7aa0c369d4fb8aa5a5ecf8a5e64c109645fa7e1c5b72ec75069f11fecbf43675be84426cd5922b3831ad44b8d2a6601ac5ea0aa084824d0f79745ad5c3926e
7
+ data.tar.gz: 03f28928fb97b38d96eba44c167d684e9121822a89c4d6fadd6a29fb47442918d0f7da0cbc05134bd8fa72cd310200774888fa260a5deca9c6ca6d1381a500aa
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,4 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.1
@@ -0,0 +1,9 @@
1
+ # CHANGELOG
2
+
3
+ ## Master
4
+
5
+ ## 1.0.0
6
+
7
+ 2017.09.10
8
+
9
+ - First version of GemOutdated
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in gem_outdated.gemspec
6
+ gemspec
7
+
8
+ gem "webmock"
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Juanito Fatas
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,51 @@
1
+ # GemOutdated
2
+
3
+ Find out if a given gem and version is outdated or not.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile then `bundle`:
8
+
9
+ ```ruby
10
+ gem "gem_outdated"
11
+ ```
12
+
13
+ Or install it yourself as:
14
+
15
+ ```
16
+ $ gem install gem_outdated
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ Suppose latest Rails is 5.1.4.
22
+
23
+ ```ruby
24
+ # Tells latest when asked a outdated version
25
+ GemOutdated.outdated?("rails", "5.1.2")
26
+ => "5.1.4"
27
+
28
+ # Already latest
29
+ GemOutdated.outdated?("rails", "5.1.4")
30
+ => false
31
+
32
+ # Newer than latest
33
+ GemOutdated.outdated?("rails", "5.1.5.rc1")
34
+ => false
35
+
36
+ # returns false when Version not exists
37
+ GemOutdated.outdated?("rails", "1.2.3.4")
38
+ => false
39
+
40
+ # Gem not exists raises an error
41
+ GemOutdated.outdated?("greatest_rails", "1.0.0")
42
+ => GemOutdated::RubygemsAPI::GemNotFound
43
+ ```
44
+
45
+ ## License, Contributor's Guidelines
46
+
47
+ - MIT license
48
+ - [Moya Contributors Guidelines][moya] which TLDR: means we give out push access easily and often.
49
+
50
+ [mit]: https://opensource.org/licenses/MIT
51
+ [moya]: https://github.com/Moya/contributors
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "gem_outdated"
5
+
6
+ require "pry"
7
+ Pry.start
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "gem_outdated/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "gem_outdated"
8
+ spec.version = GemOutdated::VERSION
9
+ spec.authors = ["Juanito Fatas"]
10
+ spec.email = ["katehuang0320@gmail.com"]
11
+
12
+ spec.summary = %(Find if your gem is outdated.)
13
+ spec.description = spec.summary
14
+ spec.homepage = "https://github.com/JuanitoFatas/gem_outdated"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "pry"
25
+ spec.add_development_dependency "rspec", "~> 3.0"
26
+
27
+ spec.add_dependency "http"
28
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "gem_outdated/version"
4
+ require_relative "gem_outdated/rubygems_api"
5
+
6
+ class GemOutdated
7
+ def self.outdated?(gem_name, version)
8
+ new(gem_name, version).outdated?
9
+ end
10
+
11
+ def initialize(gem_name, version)
12
+ @gem_name = gem_name
13
+ @version = version
14
+ end
15
+
16
+ def outdated?
17
+ if gem_is_outdated?
18
+ latest_version
19
+ else
20
+ false
21
+ end
22
+ end
23
+
24
+ private
25
+ attr_reader :gem_name, :version
26
+
27
+ def latest_version
28
+ @_latest_version ||= RubygemsAPI.new(gem_name).latest_version
29
+ end
30
+
31
+ def gem_is_outdated?
32
+ Gem::Version.new(latest_version) > Gem::Version.new(version)
33
+ end
34
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "http"
4
+
5
+ class GemOutdated
6
+ class RubygemsAPI
7
+ GemNotFound = Class.new(RuntimeError)
8
+
9
+ def initialize(gem_name)
10
+ @gem_name = gem_name
11
+
12
+ gem_exists?
13
+ end
14
+
15
+ def latest_version
16
+ endpoint = File.join(API_ENDPOINT, "versions", gem_name, "latest.json")
17
+ HTTP.get(endpoint).parse["version"]
18
+ end
19
+
20
+ private
21
+ attr_reader :gem_name
22
+
23
+ API_ENDPOINT = "https://rubygems.org/api/v1"
24
+
25
+ def gem_exists?
26
+ endpoint = File.join(API_ENDPOINT, "gems", "#{gem_name}.json")
27
+ code = HTTP.get(endpoint).code
28
+ code == 404 ? raise(GemNotFound) : true
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ class GemOutdated
4
+ VERSION = "1.0.0"
5
+ end
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gem_outdated
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Juanito Fatas
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-09-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pry
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: http
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Find if your gem is outdated.
56
+ email:
57
+ - katehuang0320@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - ".travis.yml"
65
+ - CHANGELOG.md
66
+ - Gemfile
67
+ - LICENSE.txt
68
+ - README.md
69
+ - Rakefile
70
+ - bin/hack
71
+ - gem_outdated.gemspec
72
+ - lib/gem_outdated.rb
73
+ - lib/gem_outdated/rubygems_api.rb
74
+ - lib/gem_outdated/version.rb
75
+ homepage: https://github.com/JuanitoFatas/gem_outdated
76
+ licenses:
77
+ - MIT
78
+ metadata: {}
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubyforge_project:
95
+ rubygems_version: 2.6.12
96
+ signing_key:
97
+ specification_version: 4
98
+ summary: Find if your gem is outdated.
99
+ test_files: []