ruaur 0.2.6 → 0.2.7

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
2
  SHA1:
3
- metadata.gz: 8a5e2fe6ac79c349b56d1d30959643b0704ca75b
4
- data.tar.gz: a71a51dbe47e3be79e673a8f67effbac44e296cc
3
+ metadata.gz: 156d9ca872f9661a9ac52542812df31f5970be15
4
+ data.tar.gz: 4f867da65351851ffa63c6961681c1496d8642f5
5
5
  SHA512:
6
- metadata.gz: de51f7ac7e26fa785e31b9ba8ce2970991eed9c9448c03965349bd4e6f635e788c9f3c3d80a047f289e3c5f35292b075cf13b3e1ad943b30f5f060572a6696f7
7
- data.tar.gz: f41d0571e1eee1ad459c90b905b76c21046535a77d428e66538947b940f3366af7d054afc78c8fe4dd3ed26212c105ee20cece82109b5db088f0229767149213
6
+ metadata.gz: c1d958212921dcbf59082a148c746404d969b68e17f373ab38688870df2381acbe1016a927ee8192baaba209ad2dba2259c69f99512b8a2f10269b173e18ded8
7
+ data.tar.gz: b84723dbb888689f0df47db13133896863907875f98637d991608376fbab89d6c5f18f363498ea339b1418d6f099834f51c1d2e8e2aaf2a902c3b2341e47fc22
data/bin/ruaur CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "colorize"
3
+ require "hilighter"
4
4
  require "optparse"
5
5
  require "ruaur"
6
6
 
@@ -49,7 +49,7 @@ def parse(args)
49
49
  end
50
50
 
51
51
  opts.on("--nocolor", "Disable colorized output") do
52
- String.disable_colorization = true
52
+ Hilighter.disable
53
53
  end
54
54
 
55
55
  opts.on(
@@ -192,7 +192,7 @@ end
192
192
  options = parse(ARGV)
193
193
 
194
194
  begin
195
- ruaur = RuAUR.new(!String.disable_colorization)
195
+ ruaur = RuAUR.new(!Hilighter.disable?)
196
196
 
197
197
  case options["operation"]
198
198
  when Operation::REMOVE
data/lib/ruaur/aur.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require "archive/tar/minitar"
2
- require "colorize"
3
2
  require "fileutils"
3
+ require "hilighter"
4
4
  require "io/wait"
5
5
  require "json"
6
6
  require "scoobydoo"
@@ -9,38 +9,14 @@ require "zlib"
9
9
 
10
10
  class RuAUR::AUR
11
11
  def clean
12
- puts colorize_status("Cleaning AUR cache...")
12
+ puts hilight_status("Cleaning AUR cache...")
13
13
  Dir.chdir(@cache) do
14
14
  FileUtils.rm_rf(Dir["*"])
15
15
  end
16
16
  end
17
17
 
18
- def colorize_dependency(dependency)
19
- return dependency if (!RuAUR.colorize?)
20
- return dependency.light_magenta
21
- end
22
- private :colorize_dependency
23
-
24
- def colorize_installed(installed)
25
- return installed if (!RuAUR.colorize?)
26
- return installed.light_yellow
27
- end
28
- private :colorize_installed
29
-
30
- def colorize_status(status)
31
- return status if (!RuAUR.colorize?)
32
- return status.light_white
33
- end
34
- private :colorize_status
35
-
36
- def colorize_upgrade(old, new)
37
- return "#{old} -> #{new}" if (!RuAUR.colorize?)
38
- return "#{old.light_red} -> #{new.light_green}"
39
- end
40
- private :colorize_upgrade
41
-
42
18
  def compile(package)
43
- puts colorize_status("Compiling #{package.name}...")
19
+ puts hilight_status("Compiling #{package.name}...")
44
20
  if (Process.uid == 0)
45
21
  system("chown -R nobody:nobody .")
46
22
  system("su -s /bin/sh nobody -c \"makepkg -sr\"")
@@ -60,7 +36,7 @@ class RuAUR::AUR
60
36
  def download(package)
61
37
  FileUtils.rm_f(Dir["#{package.name}.tar.gz*"])
62
38
 
63
- puts colorize_status("Downloading #{package.name}...")
39
+ puts hilight_status("Downloading #{package.name}...")
64
40
  tarball(package.name, package.url, "#{package.name}.tar.gz")
65
41
 
66
42
  tgz = Pathname.new("#{package.name}.tar.gz").expand_path
@@ -108,7 +84,7 @@ class RuAUR::AUR
108
84
  def extract(package)
109
85
  FileUtils.rm_rf(package.name)
110
86
 
111
- puts colorize_status("Extracting #{package.name}...")
87
+ puts hilight_status("Extracting #{package.name}...")
112
88
  File.open("#{package.name}.tar.gz", "rb") do |tgz|
113
89
  tar = Zlib::GzipReader.new(tgz)
114
90
  Archive::Tar::Minitar.unpack(tar, ".")
@@ -123,7 +99,7 @@ class RuAUR::AUR
123
99
  private :extract
124
100
 
125
101
  def find_upgrades
126
- puts colorize_status("Checking for AUR updates...")
102
+ puts hilight_status("Checking for AUR updates...")
127
103
 
128
104
  upgrades = Hash.new
129
105
  multiinfo(@installed.keys).each do |package|
@@ -142,6 +118,30 @@ class RuAUR::AUR
142
118
  end
143
119
  private :find_upgrades
144
120
 
121
+ def hilight_dependency(dependency)
122
+ return dependency if (!RuAUR.hilight?)
123
+ return dependency.light_magenta
124
+ end
125
+ private :hilight_dependency
126
+
127
+ def hilight_installed(installed)
128
+ return installed if (!RuAUR.hilight?)
129
+ return installed.light_yellow
130
+ end
131
+ private :hilight_installed
132
+
133
+ def hilight_status(status)
134
+ return status if (!RuAUR.hilight?)
135
+ return status.light_white
136
+ end
137
+ private :hilight_status
138
+
139
+ def hilight_upgrade(old, new)
140
+ return "#{old} -> #{new}" if (!RuAUR.hilight?)
141
+ return "#{old.light_red} -> #{new.light_green}"
142
+ end
143
+ private :hilight_upgrade
144
+
145
145
  def info(package)
146
146
  return nil if (package.nil? || package.empty?)
147
147
 
@@ -176,7 +176,7 @@ class RuAUR::AUR
176
176
  @installed.include?(pkg_name) &&
177
177
  !package.newer?(@installed[pkg_name])
178
178
  )
179
- puts colorize_installed("Already installed: #{pkg_name}")
179
+ puts hilight_installed("Already installed: #{pkg_name}")
180
180
  return
181
181
  end
182
182
 
@@ -207,7 +207,7 @@ class RuAUR::AUR
207
207
  next if (dep.start_with?("$"))
208
208
 
209
209
  if (!@installed.has_key?(dep))
210
- puts colorize_dependency(
210
+ puts hilight_dependency(
211
211
  "Installing dependency: #{dep}"
212
212
  )
213
213
  if (@pacman.exist?(dep))
@@ -288,8 +288,8 @@ class RuAUR::AUR
288
288
  find_upgrades.each do |pkg_name, versions|
289
289
  old, new = versions
290
290
 
291
- puts colorize_status("Upgrading #{pkg_name}...")
292
- puts colorize_upgrade(old, new)
291
+ puts hilight_status("Upgrading #{pkg_name}...")
292
+ puts hilight_upgrade(old, new)
293
293
  install(pkg_name, noconfirm)
294
294
  end
295
295
  end
data/lib/ruaur/package.rb CHANGED
@@ -1,4 +1,4 @@
1
- require "colorize"
1
+ require "hilighter"
2
2
 
3
3
  class RuAUR::Package
4
4
  attr_accessor :description
@@ -23,10 +23,10 @@ class RuAUR::Package
23
23
  return (self.name.downcase <=> other.name.downcase)
24
24
  end
25
25
 
26
- def colorize_header(repo, name, installed, version, votes)
26
+ def hilight_header(repo, name, installed, version, votes)
27
27
  header = Array.new
28
28
 
29
- if (!RuAUR.colorize?)
29
+ if (!RuAUR.hilight?)
30
30
  header.push("#{repo}/#{name}")
31
31
  if (installed && newer?(installed))
32
32
  header.push(installed)
@@ -54,7 +54,7 @@ class RuAUR::Package
54
54
 
55
55
  return header.join(" ")
56
56
  end
57
- private :colorize_header
57
+ private :hilight_header
58
58
 
59
59
  def initialize(json, repo = "aur")
60
60
  @description = json["Description"]
@@ -109,7 +109,7 @@ class RuAUR::Package
109
109
  def to_s
110
110
  out = Array.new
111
111
  out.push(
112
- colorize_header(
112
+ hilight_header(
113
113
  @repo,
114
114
  @name,
115
115
  @installed,
@@ -119,7 +119,7 @@ class RuAUR::Package
119
119
  )
120
120
 
121
121
  # Wrap at default minus 4 spaces
122
- @description.scan(/\S.{0,#{76}}\S(?=\s|$)|\S+/).each do |l|
122
+ @description.scan(/\S.{0,76}\S(?=\s|$)|\S+/).each do |l|
123
123
  out.push(" #{l.strip}")
124
124
  end
125
125
 
data/lib/ruaur/pacman.rb CHANGED
@@ -1,28 +1,28 @@
1
- require "colorize"
1
+ require "hilighter"
2
2
  require "pathname"
3
3
 
4
4
  class RuAUR::Pacman
5
5
  def clean(noconfirm = false)
6
- puts colorize_status("Cleaning pacman cache...")
6
+ puts hilight_status("Cleaning pacman cache...")
7
7
  system("sudo #{@pac_cmd} -Sc") if (!noconfirm)
8
8
  system("sudo #{@pac_cmd} -Sc --noconfirm") if (noconfirm)
9
9
  end
10
10
 
11
- def colorize_installed(installed)
12
- return installed if (!RuAUR.colorize?)
13
- return installed.light_yellow
11
+ def exist?(pkg_name)
12
+ return !%x(#{@pac_nocolor} -Ss "^#{pkg_name}$").empty?
14
13
  end
15
- private :colorize_installed
16
14
 
17
- def colorize_status(status)
18
- return status if (!RuAUR.colorize?)
19
- return status.light_white
15
+ def hilight_installed(installed)
16
+ return installed if (!RuAUR.hilight?)
17
+ return installed.light_yellow
20
18
  end
21
- private :colorize_status
19
+ private :hilight_installed
22
20
 
23
- def exist?(pkg_name)
24
- return !%x(#{@pac_nocolor} -Ss "^#{pkg_name}$").empty?
21
+ def hilight_status(status)
22
+ return status if (!RuAUR.hilight?)
23
+ return status.light_white
25
24
  end
25
+ private :hilight_status
26
26
 
27
27
  def initialize
28
28
  if (ScoobyDoo.where_are_you("pacman").nil?)
@@ -32,17 +32,17 @@ class RuAUR::Pacman
32
32
  @pac_nocolor = "pacman --color=never"
33
33
  @pac_color = "pacman --color=always"
34
34
  @pac_cmd = @pac_color
35
- @pac_cmd = @pac_nocolor if (!RuAUR.colorize?)
35
+ @pac_cmd = @pac_nocolor if (!RuAUR.hilight?)
36
36
  @installed = query
37
37
  end
38
38
 
39
39
  def install(pkg_name, noconfirm = false)
40
40
  if (@installed.include?(pkg_name))
41
- puts colorize_installed("Already installed: #{pkg_name}")
41
+ puts hilight_installed("Already installed: #{pkg_name}")
42
42
  return
43
43
  end
44
44
 
45
- puts colorize_status("Installing #{pkg_name}...")
45
+ puts hilight_status("Installing #{pkg_name}...")
46
46
  if (!noconfirm)
47
47
  system("sudo #{@pac_cmd} -S #{pkg_name} --needed")
48
48
  else
@@ -55,7 +55,7 @@ class RuAUR::Pacman
55
55
  end
56
56
 
57
57
  def install_local(pkgs, noconfirm = false)
58
- puts colorize_status("Installing compiled packages...")
58
+ puts hilight_status("Installing compiled packages...")
59
59
  xzs = pkgs.join(" ")
60
60
  if (!noconfirm)
61
61
  system("sudo #{@pac_cmd} -U #{xzs}")
@@ -92,7 +92,7 @@ class RuAUR::Pacman
92
92
  end
93
93
 
94
94
  def remove(pkg_names, nosave = false)
95
- puts colorize_status("Removing #{pkg_names.join(" ")}...")
95
+ puts hilight_status("Removing #{pkg_names.join(" ")}...")
96
96
  if (!nosave)
97
97
  system("sudo #{@pac_cmd} -R #{pkg_names.join(" ")}")
98
98
  else
@@ -141,7 +141,7 @@ class RuAUR::Pacman
141
141
  end
142
142
 
143
143
  def upgrade(noconfirm = false)
144
- puts colorize_status("Updating...")
144
+ puts hilight_status("Updating...")
145
145
  system("sudo #{@pac_cmd} -Syyu") if (!noconfirm)
146
146
  system("sudo #{@pac_cmd} -Syyu --noconfirm") if (noconfirm)
147
147
  end
data/lib/ruaur.rb CHANGED
@@ -16,12 +16,12 @@ class RuAUR
16
16
  @aur.clean
17
17
  end
18
18
 
19
- def self.colorize?
20
- @@colorize ||= false
21
- return @@colorize
19
+ def self.hilight?
20
+ @@hilight ||= false
21
+ return @@hilight
22
22
  end
23
23
 
24
- def initialize(colorize = false)
24
+ def initialize(hilight = false)
25
25
  [
26
26
  "makepkg",
27
27
  "pacman",
@@ -33,7 +33,7 @@ class RuAUR
33
33
  end
34
34
  end
35
35
 
36
- @@colorize = colorize
36
+ @@hilight = hilight
37
37
  @pacman = RuAUR::Pacman.new
38
38
  @aur = RuAUR::AUR.new(@pacman, nil)
39
39
  @lock = Pathname.new("/tmp/ruaur.lock").expand_path
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruaur
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Whittaker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-31 00:00:00.000000000 Z
11
+ date: 2016-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -51,25 +51,25 @@ dependencies:
51
51
  - !ruby/object:Gem::Version
52
52
  version: 0.5.2
53
53
  - !ruby/object:Gem::Dependency
54
- name: colorize
54
+ name: hilighter
55
55
  requirement: !ruby/object:Gem::Requirement
56
56
  requirements:
57
57
  - - "~>"
58
58
  - !ruby/object:Gem::Version
59
- version: '0.7'
59
+ version: '0.1'
60
60
  - - ">="
61
61
  - !ruby/object:Gem::Version
62
- version: 0.7.7
62
+ version: 0.1.0
63
63
  type: :runtime
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - "~>"
68
68
  - !ruby/object:Gem::Version
69
- version: '0.7'
69
+ version: '0.1'
70
70
  - - ">="
71
71
  - !ruby/object:Gem::Version
72
- version: 0.7.7
72
+ version: 0.1.0
73
73
  - !ruby/object:Gem::Dependency
74
74
  name: scoobydoo
75
75
  requirement: !ruby/object:Gem::Requirement