travis_check_rubies 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +14 -0
- data/.travis.yml +14 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +20 -0
- data/README.markdown +46 -0
- data/bin/travis_check_rubies +24 -0
- data/lib/travis_check_rubies/version.rb +109 -0
- data/lib/travis_check_rubies.rb +4 -0
- data/travis_check_rubies.gemspec +16 -0
- metadata +55 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZjA1NTQ3ZjAwMjE4YmI4MzBkZGE2MGMxOWZiZmY0MDZiNzA3YWNjZQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
YzMyMGIwYzk2NzM4NzI3NjUxMGE0MmU0NmVkOTEzN2U3NmU4YzkwOQ==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MTk2MDVjYTJmYjY0MDA2MzdiMDFjZTE3Nzc5NjI3MzA2ZWVkMzkwNjc2MzJj
|
10
|
+
MTE3YmI3NjkxYzE2YjBlYzg5ZjFjYzQyZjVlZmJmYTViMGRiODUxNjg1MGRj
|
11
|
+
YWQ4Mzk0YmFjNDgzMDZlMDAyOGUyZmZhNzEyMWQxMWYzMmY3OWU=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NWM2YzI5YTExMzdkZmEyM2Y4ZTdjOGY5NjBkZDk4Mzc0YzJhNGFhMjc5NzE1
|
14
|
+
MmI4YTU2MTZjNGJmZDM5NDdhMWNiMGZmZGFjNTBjZjRhODQxOGVjNjI3YTNl
|
15
|
+
NmVlNTEzMWQwMjBiNmY1MTIzMzk5NzJjNmViODhmMjdjNjdjOWY=
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2017 Ivan Kuchin
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
[![Gem Version](https://img.shields.io/gem/v/travis_check_rubies.svg?style=flat)](https://rubygems.org/gems/travis_check_rubies)
|
2
|
+
[![Build Status](https://img.shields.io/travis/toy/travis_check_rubies/master.svg?style=flat)](https://travis-ci.org/toy/travis_check_rubies)
|
3
|
+
|
4
|
+
# travis\_check\_rubies
|
5
|
+
|
6
|
+
Check if `.travis.yml` specifies latest available rubies from listed on http://rubies.travis-ci.org and propose changes.
|
7
|
+
|
8
|
+
## Gem installation
|
9
|
+
|
10
|
+
```sh
|
11
|
+
gem install travis_check_rubies
|
12
|
+
```
|
13
|
+
|
14
|
+
### Bundler
|
15
|
+
|
16
|
+
Add to your `Gemfile`:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
gem 'travis_check_rubies'
|
20
|
+
```
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
### Travis CI
|
25
|
+
|
26
|
+
Merge into your `.travis.yml`:
|
27
|
+
|
28
|
+
```yaml
|
29
|
+
matrix:
|
30
|
+
include:
|
31
|
+
- env: CHECK_RUBIES=✓
|
32
|
+
rvm: '2'
|
33
|
+
script: bundle exec travis_check_rubies
|
34
|
+
```
|
35
|
+
|
36
|
+
### Locally
|
37
|
+
|
38
|
+
```sh
|
39
|
+
travis_check_rubies
|
40
|
+
|
41
|
+
bundle exec travis_check_rubies
|
42
|
+
```
|
43
|
+
|
44
|
+
## Copyright
|
45
|
+
|
46
|
+
Copyright (c) 2017 Ivan Kuchin. See [LICENSE.txt](LICENSE.txt) for details.
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'travis_check_rubies/version'
|
4
|
+
|
5
|
+
matches = TravisCheckRubies::Version.matches
|
6
|
+
if matches.values.any?
|
7
|
+
ansi_red = `tput setaf 1 2>/dev/null`
|
8
|
+
ansi_green = `tput setaf 2 2>/dev/null`
|
9
|
+
ansi_reset = `tput sgr0 2>/dev/null`
|
10
|
+
puts 'Suggested changes:'
|
11
|
+
matches.each do |version, matched_versions|
|
12
|
+
if !matched_versions || matched_versions.include?(version)
|
13
|
+
puts " #{version}"
|
14
|
+
else
|
15
|
+
puts "#{ansi_red}-#{version}#{ansi_reset}"
|
16
|
+
end
|
17
|
+
if matched_versions
|
18
|
+
(matched_versions - [version]).each do |matched_version|
|
19
|
+
puts "#{ansi_green}+#{matched_version}#{ansi_reset}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
abort
|
24
|
+
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'set'
|
3
|
+
require 'uri'
|
4
|
+
require 'yaml'
|
5
|
+
|
6
|
+
module TravisCheckRubies
|
7
|
+
class Version
|
8
|
+
class << self
|
9
|
+
ROOT_URL = 'http://rubies.travis-ci.org/'
|
10
|
+
|
11
|
+
def available
|
12
|
+
@available ||= begin
|
13
|
+
index_urls.select do |url|
|
14
|
+
url.start_with?(base_url)
|
15
|
+
end.map do |url|
|
16
|
+
new(url[%r{([^/]+)\.tar\.(?:gz|bz2)$}, 1])
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def selected
|
22
|
+
@selected ||= begin
|
23
|
+
Array(YAML.load_file('.travis.yml')['rvm']).map do |string|
|
24
|
+
new(string)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def matches
|
30
|
+
matches = {}
|
31
|
+
deduplicate = Set.new
|
32
|
+
available_versioned = available.select(&:version_parts).sort.reverse
|
33
|
+
selected.select(&:version_parts).sort.reverse.each do |version|
|
34
|
+
matches[version] = (0..version.version_parts.length).map do |n|
|
35
|
+
available_versioned.find{ |v| version.match?(v, n) }
|
36
|
+
end.reverse.select{ |v| deduplicate.add?(v) }
|
37
|
+
end
|
38
|
+
Hash[selected.map do |v|
|
39
|
+
[v, [v] == matches[v] ? nil : matches[v]]
|
40
|
+
end]
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def index_urls
|
46
|
+
@index_urls ||= Net::HTTP.get(URI(ROOT_URL + 'index.txt')).split("\n")
|
47
|
+
end
|
48
|
+
|
49
|
+
def base_url
|
50
|
+
@base_url ||= if ENV['TRAVIS']
|
51
|
+
sys_path = `rvm debug`[/system:\s*"(.*?)"/, 1]
|
52
|
+
"#{ROOT_URL}#{sys_path}/"
|
53
|
+
else
|
54
|
+
base_ubuntu_url = "#{ROOT_URL}ubuntu/"
|
55
|
+
first_ubuntu_url = index_urls.sort.find{ |url| url.start_with?(base_ubuntu_url) }
|
56
|
+
fail "First ubuntu url not fount out of:\n#{index_urls.join("\n")}" unless first_ubuntu_url
|
57
|
+
first_ubuntu_url[%r{^.*/}]
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
include Comparable
|
63
|
+
|
64
|
+
attr_reader :str, :type, :version_parts, :pre, :variant
|
65
|
+
|
66
|
+
alias_method :to_s, :str
|
67
|
+
|
68
|
+
alias_method :eql?, :==
|
69
|
+
|
70
|
+
def initialize(str)
|
71
|
+
str = "#{str}"
|
72
|
+
@str = str.sub(/^ruby-/, '')
|
73
|
+
@variant = $1 if str.slice!(/-(clang|railsexpress)$/)
|
74
|
+
@type = str.slice!(/^([^0-9\-]+)-?/) ? $1 : 'ruby'
|
75
|
+
version_str = $1 if str.slice!(/^(\d+(?:\.\d+)*(?:-p\d+)?)(\.|-|$)/)
|
76
|
+
@version_parts = version_str.scan(/\d+/).map(&:to_i) if version_str
|
77
|
+
@pre = str unless str.empty?
|
78
|
+
end
|
79
|
+
|
80
|
+
def <=>(other)
|
81
|
+
other = self.class.new(other) unless other.is_a?(self.class)
|
82
|
+
compare_by <=> other.compare_by
|
83
|
+
end
|
84
|
+
|
85
|
+
def hash
|
86
|
+
str.hash
|
87
|
+
end
|
88
|
+
|
89
|
+
def match?(other, n)
|
90
|
+
other = self.class.new(other) unless other.is_a?(self.class)
|
91
|
+
match_by(n) == other.match_by(n)
|
92
|
+
end
|
93
|
+
|
94
|
+
protected
|
95
|
+
|
96
|
+
def compare_by
|
97
|
+
[
|
98
|
+
type,
|
99
|
+
version_parts || [],
|
100
|
+
pre ? [0, pre] : [1],
|
101
|
+
variant || '',
|
102
|
+
]
|
103
|
+
end
|
104
|
+
|
105
|
+
def match_by(n)
|
106
|
+
[type, variant, version_parts.take(n)]
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = 'travis_check_rubies'
|
5
|
+
s.version = '0.1.0'
|
6
|
+
s.summary = 'Are you using the latest rubies in .travis.yml?'
|
7
|
+
s.description = 'Check if `.travis.yml` specifies latest available rubies from listed on http://rubies.travis-ci.org and propose changes'
|
8
|
+
s.homepage = "http://github.com/toy/#{s.name}"
|
9
|
+
s.authors = ['Ivan Kuchin']
|
10
|
+
s.license = 'MIT'
|
11
|
+
|
12
|
+
s.files = `git ls-files`.split("\n")
|
13
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
14
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
15
|
+
s.require_paths = %w[lib]
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: travis_check_rubies
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ivan Kuchin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-02-22 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Check if `.travis.yml` specifies latest available rubies from listed
|
14
|
+
on http://rubies.travis-ci.org and propose changes
|
15
|
+
email:
|
16
|
+
executables:
|
17
|
+
- travis_check_rubies
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- .gitignore
|
22
|
+
- .travis.yml
|
23
|
+
- Gemfile
|
24
|
+
- LICENSE.txt
|
25
|
+
- README.markdown
|
26
|
+
- bin/travis_check_rubies
|
27
|
+
- lib/travis_check_rubies.rb
|
28
|
+
- lib/travis_check_rubies/version.rb
|
29
|
+
- travis_check_rubies.gemspec
|
30
|
+
homepage: http://github.com/toy/travis_check_rubies
|
31
|
+
licenses:
|
32
|
+
- MIT
|
33
|
+
metadata: {}
|
34
|
+
post_install_message:
|
35
|
+
rdoc_options: []
|
36
|
+
require_paths:
|
37
|
+
- lib
|
38
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ! '>='
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
requirements: []
|
49
|
+
rubyforge_project:
|
50
|
+
rubygems_version: 2.6.4
|
51
|
+
signing_key:
|
52
|
+
specification_version: 4
|
53
|
+
summary: Are you using the latest rubies in .travis.yml?
|
54
|
+
test_files: []
|
55
|
+
has_rdoc:
|