bootic_cli 0.4.7 → 0.4.8

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
- SHA1:
3
- metadata.gz: d367fc55f094ab200cc69836ed66a79c153ce766
4
- data.tar.gz: a3aeee896b866038b588991bab6bb742a1c7114b
2
+ SHA256:
3
+ metadata.gz: cd67c5e244fa152afde49d0ded817c9733d6ce640aee72c14854f635566e0a43
4
+ data.tar.gz: 51b29bf4e75a6f597887198fbdfa66df41301370f2a3169de0f4bcba363b755b
5
5
  SHA512:
6
- metadata.gz: f057c66358b85c1ceb1d58e874922a5ceec891aca95e9039e7a784d36d7fdb97662345d633e868d56eac19f7e0b09e95654ba3fe2fc5602120a5c808320f8498
7
- data.tar.gz: e5ff8006d9b702befaf184822258306c194a947841ad5af8e7b3fa923ba5d4b0c6ca98cfa5df92e7c03f67fe5ddf91e3c9383c66a5455344f9216d60fb492cb2
6
+ metadata.gz: 4e6094bca75a4a68b4a94a80180e543fdae6286612a8697fb66662821e896b3b4008ed2abb0a62c4ea89c64f0346b3efe8a57ac583467151d359531b708ffff5
7
+ data.tar.gz: 1e32cc79ee74403371a7b5daeecc6355a32db967559701f7d262b5509baea3d74c4a5a0224c1dec395063a00e97850aeebbf85023d9266e4ceaa0aae47144988
data/bin/bootic CHANGED
File without changes
@@ -14,17 +14,37 @@ module BooticCli
14
14
  end
15
15
 
16
16
  class APIAsset < ItemWithTime
17
+ REQUEST_OPTS = {
18
+ open_timeout: 5,
19
+ read_timeout: 5
20
+ }
21
+
17
22
  def file
18
- @file ||= (
19
- data = Net::HTTP.get(URI.parse(rels[:file].href))
20
- StringIO.new(data)
21
- )
23
+ @file ||= StringIO.new(fetch_data)
22
24
  end
23
25
 
24
26
  def ==(other)
25
27
  return super if digest.to_s == '' || other.digest.to_s == ''
26
28
  self.file_size == other.file_size && self.digest == other.digest
27
29
  end
30
+
31
+ def fetch_data(attempt = 1)
32
+ uri = URI.parse(rels[:file].href)
33
+ opts = REQUEST_OPTS.merge({
34
+ # verify_mode: OpenSSL::SSL::VERIFY_PEER # OpenSSL::SSL::VERIFY_NONE
35
+ use_ssl: uri.port == 443
36
+ })
37
+
38
+ Net::HTTP.start(uri.host, uri.port, opts) do |http|
39
+ resp = http.get(uri.path)
40
+ raise "Invalid response: #{resp.code}" unless resp.code.to_i == 200
41
+ resp.body
42
+ end
43
+ rescue Net::OpenTimeout, Net::ReadTimeout => e
44
+ raise if attempt > 3 # max attempts
45
+ # puts "#{e.class} for #{File.basename(uri.path)}! Retrying request..."
46
+ fetch_data(attempt + 1)
47
+ end
28
48
  end
29
49
 
30
50
  class APITheme
@@ -2,7 +2,7 @@ module BooticCli
2
2
  module Themes
3
3
  class MemTheme
4
4
  Template = Struct.new(:file_name, :body, :updated_on)
5
- ThemeAsset = Struct.new(:file_name, :file, :updated_on)
5
+ ThemeAsset = Struct.new(:file_name, :file, :updated_on, :file_size)
6
6
 
7
7
  def initialize
8
8
  reload!
@@ -26,7 +26,7 @@ module BooticCli
26
26
 
27
27
  def add_template(file_name, body, mtime: Time.now)
28
28
  tpl = Template.new(file_name, body, mtime)
29
- if idx = templates.index{|t| t.file_name == file_name }
29
+ if idx = templates.index { |t| t.file_name == file_name }
30
30
  templates[idx] = tpl
31
31
  else
32
32
  templates << tpl
@@ -34,14 +34,14 @@ module BooticCli
34
34
  end
35
35
 
36
36
  def remove_template(file_name)
37
- if idx = templates.index{|t| t.file_name == file_name }
37
+ if idx = templates.index { |t| t.file_name == file_name }
38
38
  templates.delete_at idx
39
39
  end
40
40
  end
41
41
 
42
42
  def add_asset(file_name, file, mtime: Time.now)
43
43
  asset = ThemeAsset.new(file_name, file, mtime)
44
- if idx = assets.index{|t| t.file_name == file_name }
44
+ if idx = assets.index { |t| t.file_name == file_name }
45
45
  assets[idx] = asset
46
46
  else
47
47
  assets << asset
@@ -49,7 +49,7 @@ module BooticCli
49
49
  end
50
50
 
51
51
  def remove_asset(file_name)
52
- if idx = assets.index{|t| t.file_name == file_name }
52
+ if idx = assets.index { |t| t.file_name == file_name }
53
53
  assets.delete_at idx
54
54
  end
55
55
  end
@@ -274,7 +274,7 @@ module BooticCli
274
274
  def copy_templates(from, to, opts = {})
275
275
  from.templates.each do |t|
276
276
  to.add_template t.file_name, t.body
277
- puts "Copied #{t.file_name}"
277
+ puts "Copied #{highlight(t.file_name)}"
278
278
  end
279
279
  end
280
280
 
@@ -297,7 +297,7 @@ module BooticCli
297
297
  files.each do |a|
298
298
  pool.schedule do
299
299
  to.add_asset a.file_name, a.file
300
- puts "Copied asset #{a.file_name}"
300
+ puts "Copied asset #{highlight(a.file_name)} (#{a.file_size} bytes)"
301
301
  end
302
302
  end
303
303
 
@@ -1,3 +1,3 @@
1
1
  module BooticCli
2
- VERSION = "0.4.7"
2
+ VERSION = "0.4.8"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootic_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.7
4
+ version: 0.4.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ismael Celis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-02 00:00:00.000000000 Z
11
+ date: 2018-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -199,7 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
199
199
  version: '0'
200
200
  requirements: []
201
201
  rubyforge_project:
202
- rubygems_version: 2.5.1
202
+ rubygems_version: 2.7.3
203
203
  signing_key:
204
204
  specification_version: 4
205
205
  summary: Bootic command-line client.