vivaldiupdater-ubuntu 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c21dfa94a9822930d1c3f6ab360f2bbe2b998f0fb03a67a3c5520103a4fc9850
4
- data.tar.gz: 0250ced9c287742cb3e251faea1fd77fd2526426a2d18a7975dacc5239d17e87
3
+ metadata.gz: a1198bd55e90f45535292282eedb684a4536fe85e58f70abea63559572b1c9af
4
+ data.tar.gz: fde79cccb3dba04e0076700cfbe0a479c6728382b8e81ae09ea57712d5cdad42
5
5
  SHA512:
6
- metadata.gz: d42cd2398cdb59b7b8597d5b563d9d654cb8a748b9977ff37f5f7eed31bf16a15fd5d86568d964ead5d89107604e7e6e444899f0578784a5f59ad1e7549d0cc6
7
- data.tar.gz: 8ee80812c87cbb0e9c4b97d229c25e6edc865dcd57eb67ff4108a352dfcd54258c3a9d81668ff10d949d8bfb80e4db5c670a2afc8b2066f147bca5ebd1f5b3eb
6
+ metadata.gz: ac5e032867e4d7dc2e79aaaec256ffecace10cd8e648a205be7f736b5d2ce0ac9d701b5ad1c55fb64213fb11718df8cc0cfc04f89bef125f772a48f6a125b653
7
+ data.tar.gz: f036113b4e726b87a07e91e1afdb01097136e6613c3976d11a22bcb46f22cb91d961717b3e1b8fdb0ad40f5a915a54e3430658e6e3b45c13f6213d0268784c10
@@ -1,4 +1,25 @@
1
1
  #!/usr/bin/env ruby
2
- require 'vivaldiupdater'
2
+ require_relative '../lib/vivaldiupdater'
3
+ require 'slop'
3
4
 
4
- VivaldiUpdater.new
5
+ begin
6
+ opts = Slop.parse do |o|
7
+ o.bool '-s', '--stable', 'check against stable', default: true
8
+ o.bool '-i', '--install', 'install vivaldi if not installed'
9
+ o.bool '--skip-current', 'skip checking current'
10
+ o.on '-h', '--help', 'display help' do
11
+ puts "Welcome to VivaldiUpdater"
12
+ puts ""
13
+ puts "Options"
14
+ puts " -s, --stable check against stable (default)"
15
+ puts " -i, --install install Vivaldi if not installed"
16
+ puts " --skip-current skip checking current version and install anyway"
17
+ exit
18
+ end
19
+ end
20
+ rescue Slop::UnknownOption => e
21
+ puts "#{e}, try '--help' for help"
22
+ exit
23
+ end
24
+
25
+ VivaldiUpdater.new(opts.install?, opts.skip_current?)
@@ -2,23 +2,41 @@ require 'rest-client'
2
2
  require 'nokogiri'
3
3
 
4
4
  class VivaldiUpdater
5
- def initialize
5
+ def initialize(install = false, skip_current = false)
6
6
  puts "Welcome to Vivaldi Updater for Ubuntu!"
7
7
  puts 'Vivaldi is currently running! If you choose to update, please close it!' if running?
8
- @current = `dpkg -l vivaldi-stable`.split("\n").last.split(' ')[2]
8
+ if skip_current
9
+ @current = "Skipped..."
10
+ else
11
+ begin
12
+ @current = `dpkg -l vivaldi-stable`.split("\n").last.split(' ')[2]
13
+ puts "Vivaldi is installed, ignoring --install flag" if install
14
+ rescue NoMethodError
15
+ case install
16
+ when true
17
+ puts "Vivaldi not detected on this machine! Installing..."
18
+ @current = "None"
19
+ when false
20
+ puts "Vivaldi not detected on this machine! If you would like to install Vivaldi, please append '--install' to your command."
21
+ exit
22
+ end
23
+ end
24
+ end
9
25
  puts "Current Vivaldi Version: #{@current}"
26
+ print "Latest Vivaldi Version: Checking...\r"
10
27
  site = RestClient.get('https://vivaldi.com/download').body
11
28
  doc = Nokogiri::HTML.parse(site)
12
29
  @url = doc.search('a.download-link').first.values[1]
13
30
  @version = @url.split('/').last.gsub('_amd64.deb', '').gsub('vivaldi-stable_', '')
14
- puts "Latest Vivaldi Version: #{@version}"
31
+ $stdout.flush
32
+ print "Latest Vivaldi Version: #{@version}\n"
15
33
 
16
34
  if @current == @version
17
35
  puts 'Vivaldi is up to date!'
18
36
  exit
19
37
  else
20
38
  puts 'Update available! Enter to update, CTRL+C to cancel!'
21
- gets
39
+ STDIN.gets.chomp
22
40
  update
23
41
  end
24
42
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vivaldiupdater-ubuntu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chew
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-12 00:00:00.000000000 Z
11
+ date: 2019-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -72,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
72
  - !ruby/object:Gem::Version
73
73
  version: '0'
74
74
  requirements: []
75
- rubygems_version: 3.0.3
75
+ rubygems_version: 3.0.6
76
76
  signing_key:
77
77
  specification_version: 4
78
78
  summary: A ruby gem to simplify updating Vivaldi!