travis_check_rubies 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -3
- data/README.markdown +1 -1
- data/lib/travis_check_rubies/version.rb +21 -16
- data/spec/travis_check_rubies/version_spec.rb +29 -18
- data/travis_check_rubies.gemspec +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da70d316f180f2b40b4840ea6fe7c886d74ea85a
|
4
|
+
data.tar.gz: 76536fb82b627a7f853d3f0c62ca814b6cace50a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 285e6d2050aaff7efc281f542f2e83f207859655c1c697452f6505645bdf17cc49750ce120bee743d6b11c0585bb208ded8e62806b7b768eedd328f63dc636d7
|
7
|
+
data.tar.gz: e1a3efb71f362b24a51349e9862db65bbd819e4ff9f451e0da4dfd55a4331067c34b6076cf7bd38f14a43a8cc592583e518f2b4bba8560ae21a068f3a5dfc0cf
|
data/.travis.yml
CHANGED
data/README.markdown
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
# travis\_check\_rubies
|
5
5
|
|
6
|
-
Check if `.travis.yml` specifies latest available rubies from listed on
|
6
|
+
Check if `.travis.yml` specifies latest available rubies from listed on https://rubies.travis-ci.org and propose changes.
|
7
7
|
|
8
8
|
## Gem installation
|
9
9
|
|
@@ -5,7 +5,7 @@ require 'uri'
|
|
5
5
|
|
6
6
|
module TravisCheckRubies
|
7
7
|
class Version
|
8
|
-
ROOT_URL = '
|
8
|
+
ROOT_URL = 'https://rubies.travis-ci.org/'
|
9
9
|
CACHE_TIME = 24 * 60 * 60
|
10
10
|
|
11
11
|
class << self
|
@@ -79,21 +79,26 @@ module TravisCheckRubies
|
|
79
79
|
end
|
80
80
|
|
81
81
|
def index_urls
|
82
|
-
@index_urls ||=
|
83
|
-
|
84
|
-
cache_path.read
|
85
|
-
else
|
86
|
-
data = Net::HTTP.get(URI(ROOT_URL + 'index.txt'))
|
87
|
-
|
88
|
-
cache_path.dirname.mkpath
|
89
|
-
FSPath.temp_file('travis_check_rubies', cache_path.dirname) do |f|
|
90
|
-
f.write(data)
|
91
|
-
f.path.rename(cache_path)
|
92
|
-
end
|
82
|
+
@index_urls ||= (cached_index_data || fetch_index_data).split("\n")
|
83
|
+
end
|
93
84
|
|
94
|
-
|
95
|
-
|
96
|
-
|
85
|
+
def cached_index_data
|
86
|
+
return unless cache_path.size?
|
87
|
+
return unless cache_path.mtime + CACHE_TIME > Time.now
|
88
|
+
data = cache_path.read
|
89
|
+
data if data.start_with?(ROOT_URL)
|
90
|
+
end
|
91
|
+
|
92
|
+
def fetch_index_data
|
93
|
+
data = Net::HTTP.get(URI(ROOT_URL + 'index.txt'))
|
94
|
+
|
95
|
+
cache_path.dirname.mkpath
|
96
|
+
FSPath.temp_file('travis_check_rubies', cache_path.dirname) do |f|
|
97
|
+
f.write(data)
|
98
|
+
f.path.rename(cache_path)
|
99
|
+
end
|
100
|
+
|
101
|
+
data
|
97
102
|
end
|
98
103
|
|
99
104
|
def base_url
|
@@ -103,7 +108,7 @@ module TravisCheckRubies
|
|
103
108
|
else
|
104
109
|
base_ubuntu_url = "#{ROOT_URL}ubuntu/"
|
105
110
|
first_ubuntu_url = index_urls.sort.find{ |url| url.start_with?(base_ubuntu_url) }
|
106
|
-
fail "First ubuntu url not fount out of:\n#{index_urls.join("\n")}" unless first_ubuntu_url
|
111
|
+
fail "First ubuntu url (#{ROOT_URL}ubuntu/*) not fount out of:\n#{index_urls.join("\n")}" unless first_ubuntu_url
|
107
112
|
first_ubuntu_url[%r{^.*/}]
|
108
113
|
end
|
109
114
|
end
|
@@ -211,32 +211,43 @@ describe TravisCheckRubies::Version do
|
|
211
211
|
end
|
212
212
|
|
213
213
|
it 'returns urls from text index of rubies.travis-ci.org' do
|
214
|
-
allow(Net::HTTP).to receive(:get).with(URI('
|
214
|
+
allow(Net::HTTP).to receive(:get).with(URI('https://rubies.travis-ci.org/index.txt')).
|
215
215
|
and_return("one\ntwo\nthree")
|
216
216
|
|
217
217
|
expect(described_class.send(:index_urls)).to eq(%w[one two three])
|
218
218
|
end
|
219
219
|
|
220
220
|
it 'caches result' do
|
221
|
-
allow(Net::HTTP).to receive(:get).with(URI('
|
221
|
+
allow(Net::HTTP).to receive(:get).with(URI('https://rubies.travis-ci.org/index.txt')).
|
222
222
|
once.and_return("a\nb\nc")
|
223
223
|
|
224
224
|
3.times{ expect(described_class.send(:index_urls)).to eq(%w[a b c]) }
|
225
225
|
end
|
226
226
|
|
227
227
|
it 'reads cache from file if it is new' do
|
228
|
+
cache_path.write "https://rubies.travis-ci.org/foo"
|
228
229
|
allow(cache_path).to receive(:size?).and_return(616)
|
229
230
|
allow(cache_path).to receive(:mtime).and_return(Time.now - described_class::CACHE_TIME / 2)
|
230
|
-
allow(cache_path).to receive(:read).and_return("foo\nbar")
|
231
231
|
|
232
232
|
expect(Net::HTTP).not_to receive(:get)
|
233
|
-
expect(described_class.send(:index_urls)).to eq(%w[foo
|
233
|
+
expect(described_class.send(:index_urls)).to eq(%w[https://rubies.travis-ci.org/foo])
|
234
|
+
end
|
235
|
+
|
236
|
+
it 'ignores bad cache' do
|
237
|
+
cache_path.write "http://rubies.travis-ci.org/foo"
|
238
|
+
allow(cache_path).to receive(:size?).and_return(616)
|
239
|
+
allow(cache_path).to receive(:mtime).and_return(Time.now - described_class::CACHE_TIME / 2)
|
240
|
+
|
241
|
+
allow(Net::HTTP).to receive(:get).with(URI('https://rubies.travis-ci.org/index.txt')).
|
242
|
+
once.and_return("brave\nnew\nworld")
|
243
|
+
expect(described_class.send(:index_urls)).to eq(%w[brave new world])
|
244
|
+
expect(cache_path.read).to eq("brave\nnew\nworld")
|
234
245
|
end
|
235
246
|
|
236
247
|
it 'writes cache file if it is stale' do
|
237
248
|
allow(cache_path).to receive(:size?).and_return(616)
|
238
249
|
allow(cache_path).to receive(:mtime).and_return(Time.now - described_class::CACHE_TIME * 2)
|
239
|
-
allow(Net::HTTP).to receive(:get).with(URI('
|
250
|
+
allow(Net::HTTP).to receive(:get).with(URI('https://rubies.travis-ci.org/index.txt')).
|
240
251
|
once.and_return("brave\nnew\nworld")
|
241
252
|
|
242
253
|
expect(described_class.send(:index_urls)).to eq(%w[brave new world])
|
@@ -257,7 +268,7 @@ describe TravisCheckRubies::Version do
|
|
257
268
|
allow(described_class).to receive(:`).with('rvm debug').
|
258
269
|
and_return(%Q{ foo: "xxx" \n system: "XXX/YYY" \n bar: "yyy" })
|
259
270
|
|
260
|
-
expect(described_class.send(:base_url)).to eq('
|
271
|
+
expect(described_class.send(:base_url)).to eq('https://rubies.travis-ci.org/XXX/YYY/')
|
261
272
|
end
|
262
273
|
end
|
263
274
|
|
@@ -266,12 +277,12 @@ describe TravisCheckRubies::Version do
|
|
266
277
|
|
267
278
|
it 'gets base_url from first ubuntu url in index' do
|
268
279
|
allow(described_class).to receive(:index_urls).and_return(%w[
|
269
|
-
|
270
|
-
|
271
|
-
|
280
|
+
https://rubies.travis-ci.org/osx/AAA/1.tar.gz
|
281
|
+
https://rubies.travis-ci.org/ubuntu/ZZZ/2.tar.gz
|
282
|
+
https://rubies.travis-ci.org/ubuntu/BBB/3.tar.gz
|
272
283
|
])
|
273
284
|
|
274
|
-
expect(described_class.send(:base_url)).to eq('
|
285
|
+
expect(described_class.send(:base_url)).to eq('https://rubies.travis-ci.org/ubuntu/BBB/')
|
275
286
|
end
|
276
287
|
end
|
277
288
|
end
|
@@ -283,22 +294,22 @@ describe TravisCheckRubies::Version do
|
|
283
294
|
|
284
295
|
it 'gets sorted versions from index urls matching base_url' do
|
285
296
|
allow(described_class).to receive(:index_urls).and_return(%w[
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
297
|
+
https://rubies.travis-ci.org/osx/AAA/1.tar.gz
|
298
|
+
https://rubies.travis-ci.org/ubuntu/ZZZ/2.tar.gz
|
299
|
+
https://rubies.travis-ci.org/ubuntu/BBB/4.tar.gz
|
300
|
+
https://rubies.travis-ci.org/ubuntu/BBB/3.tar.bz2
|
290
301
|
])
|
291
|
-
allow(described_class).to receive(:base_url).and_return('
|
302
|
+
allow(described_class).to receive(:base_url).and_return('https://rubies.travis-ci.org/ubuntu/BBB/')
|
292
303
|
|
293
304
|
expect(described_class.available).to eq([v('3'), v('4')])
|
294
305
|
end
|
295
306
|
|
296
307
|
it 'caches result' do
|
297
308
|
allow(described_class).to receive(:index_urls).once.and_return(%w[
|
298
|
-
|
299
|
-
|
309
|
+
https://rubies.travis-ci.org/ubuntu/CCC/a.tar.gz
|
310
|
+
https://rubies.travis-ci.org/ubuntu/CCC/b.tar.bz2
|
300
311
|
])
|
301
|
-
allow(described_class).to receive(:base_url).and_return('
|
312
|
+
allow(described_class).to receive(:base_url).and_return('https://rubies.travis-ci.org/ubuntu/CCC/')
|
302
313
|
|
303
314
|
3.times{ expect(described_class.available).to eq([v('a'), v('b')]) }
|
304
315
|
end
|
data/travis_check_rubies.gemspec
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'travis_check_rubies'
|
5
|
-
s.version = '0.2.
|
5
|
+
s.version = '0.2.1'
|
6
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
|
7
|
+
s.description = 'Check if `.travis.yml` specifies latest available rubies from listed on https://rubies.travis-ci.org and propose changes'
|
8
8
|
s.homepage = "http://github.com/toy/#{s.name}"
|
9
9
|
s.authors = ['Ivan Kuchin']
|
10
10
|
s.license = 'MIT'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: travis_check_rubies
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Kuchin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-04-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fspath
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '3.0'
|
41
41
|
description: Check if `.travis.yml` specifies latest available rubies from listed
|
42
|
-
on
|
42
|
+
on https://rubies.travis-ci.org and propose changes
|
43
43
|
email:
|
44
44
|
executables:
|
45
45
|
- travis_check_rubies
|