gigamo-aurb 0.8.3 → 0.8.4

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.
Files changed (4) hide show
  1. data/README.rdoc +19 -5
  2. data/aurb.gemspec +4 -2
  3. data/bin/aurb +78 -88
  4. metadata +2 -2
@@ -6,14 +6,14 @@ See <tt>aurb --help</tt> for a full list of commands.
6
6
 
7
7
  Required options:
8
8
 
9
- <b>--download</b>:: Downloads a specified package and untars it
10
- <b>--search</b>:: Searches the AUR for a specified name or description
11
- <b>--upgrade</b>:: Searches the AUR for updates to foreign local packages
9
+ <tt>--download</tt>:: Downloads a specified package and untars it
10
+ <tt>--search</tt>:: Searches the AUR for a specified name or description
11
+ <tt>--upgrade</tt>:: Searches the AUR for updates to foreign local packages
12
12
 
13
13
  Optional options:
14
14
 
15
- <b>--no-color</b>:: Suppress colored output
16
- <b>--path</b>:: Override the default save path (defined as DlPath)
15
+ <tt>--no-color</tt>:: Suppress colored output
16
+ <tt>--path</tt>:: Override the default save path (defined as DlPath)
17
17
 
18
18
  Other:
19
19
 
@@ -48,6 +48,20 @@ There is also a github gem available:
48
48
 
49
49
  Aurb requires the 'facets', 'json' and 'highline' rubygems to be installed.
50
50
 
51
+ Facets for:
52
+
53
+ * Checking version numbers
54
+ * Coloring text
55
+ * Untarring
56
+
57
+ JSON for:
58
+
59
+ * Parsing the AUR
60
+
61
+ Highline for:
62
+
63
+ * Interactivity
64
+
51
65
  == Todo
52
66
 
53
67
  * Automatically build (and install) the package after download?
@@ -1,7 +1,9 @@
1
+ # aurb.gemspec
2
+
1
3
  Gem::Specification.new do |s|
2
4
  s.name = 'aurb'
3
- s.version = '0.8.3'
4
- s.date = %q{2009-05-07}
5
+ s.version = '0.8.4'
6
+ s.date = %q{2009-06-15}
5
7
  s.summary = %q{An AUR utility written in Ruby}
6
8
  s.email = %q{gigamo@gmail.com}
7
9
  s.homepage = %q{http://github.com/gigamo/aurb}
data/bin/aurb CHANGED
@@ -1,22 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- #++
3
- # Copyright (C) 2009 Gigamo
4
- #
5
- # This program is free software; you can redistribute it and/or
6
- # modify it under the terms of the GNU General Public License
7
- # as published by the Free Software Foundation; either version 2
8
- # of the License, or (at your option) any later version.
9
- #
10
- # This program is distributed in the hope that it will be useful,
11
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- # GNU General Public License for more details.
14
- #
15
- # You should have received a copy of the GNU General Public License
16
- # along with this program; if not, write to the Free Software
17
- # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
- #--
19
- # Inspired by arson (http://evaryont.github.com/arson)
2
+ # encoding: utf-8
20
3
  require 'rubygems'
21
4
 
22
5
  {
@@ -25,10 +8,10 @@ require 'rubygems'
25
8
  :zlib => ['zlib', true ],
26
9
  :openuri => ['open-uri', true ],
27
10
  :json => ['json', true ],
28
- :highline => ['highline/import', false],
11
+ :gettext => ['gettext', false],
29
12
  :ansicode => ['facets/ansicode', false],
30
- :minitar => ['facets/minitar', true ],
31
- :version => ['facets/version', true ],
13
+ :minitar => ['facets/minitar', false],
14
+ :version => ['facets/version', false],
32
15
  }.each do |key, info|
33
16
  path, required = info[0, 2]
34
17
  $have_lib ||= {}
@@ -39,7 +22,7 @@ require 'rubygems'
39
22
  rescue LoadError
40
23
  if required
41
24
  abort <<-ERR
42
- You're missing '#{lib}'.
25
+ You're missing '#{path}'.
43
26
  Please make sure you have the necessary rubygems installed.
44
27
  ERR
45
28
  else
@@ -48,12 +31,13 @@ Please make sure you have the necessary rubygems installed.
48
31
  end
49
32
  end
50
33
 
34
+ def _ str
35
+ $have_lib[:gettext] ? GetText::_(str) : str
36
+ end
37
+
51
38
  module Aurb
52
- # Default download path
53
39
  DlPath = File.join ENV['HOME'], 'abs'
54
-
55
- # Program info
56
- PrInfo = {:name => 'Aurb', :version => [0, 8, 3].join('.'), :release => '2009-05-07'}
40
+ PrInfo = {:name => 'Aurb', :version => [0, 8, 4].join('.'), :release => '2009-06-15'}
57
41
 
58
42
  class << self
59
43
  def aur
@@ -67,21 +51,8 @@ module Aurb
67
51
  if @config[:color] && $have_lib[:ansicode]
68
52
  text = ANSICode.send(effect.to_sym) << text.to_s << ANSICode.clear
69
53
  end
70
- text
71
- end
72
54
 
73
- def yes_or_no? question
74
- if $have_lib[:highline]
75
- ask question, lambda {|yn| yn.downcase[0] == ?y} do |q|
76
- q.readline = true
77
- q.validate = /\Ay(?:es)?|no?\Z/i
78
- q.responses[:not_valid] = 'Yes or no, please'
79
- end
80
- else
81
- $stdout.print question
82
- answer = $stdin.gets.chomp
83
- answer =~ /\Ay(?:es)?|no?\Z/i
84
- end
55
+ text
85
56
  end
86
57
  end
87
58
 
@@ -90,7 +61,7 @@ module Aurb
90
61
 
91
62
  def start
92
63
  trap :INT do
93
- $stderr.puts "\nInterrupt signal received\n\n"
64
+ $stderr.puts _("\nInterrupt signal received\n\n")
94
65
  exit 0
95
66
  end
96
67
 
@@ -107,23 +78,24 @@ module Aurb
107
78
 
108
79
  def download packages
109
80
  packages.delete_if {|pkg| in_sync?(pkg)}
110
- abort 'ERROR: No package(s) to download. Possibly the package(s) you ' +
111
- 'specified was/were found in the community repository?' if packages.empty?
112
-
113
- say "Targets (#{ansi packages.length, :magenta}): #{packages.join(', ')}"
114
- if yes_or_no? 'Proceed? [yn] '
115
- packages.each do |package|
116
- begin
117
- Dir.chdir @config[:path] do
118
- fetch package
119
- untar package
120
- end
121
- rescue OpenURI::HTTPError
122
- $stderr.puts "Something went wrong downloading '#{package}'. Are you sure it exists?"
123
- package == packages.last ? exit : next
81
+ abort _('ERROR: No package(s) to download. Possibly the package(s) you ' +
82
+ 'specified was/were found in the community repository?') if packages.empty?
83
+
84
+ $stdout.puts _("Targets (#{ansi packages.length, :magenta}): #{packages.join(', ')}")
85
+
86
+ packages.each do |package|
87
+ begin
88
+ Dir.chdir @config[:path] do
89
+ fetch package
90
+ untar package
124
91
  end
125
- $stdout.puts "(#{packages.index(package)+1}/#{packages.length}) downloaded #{package}"
92
+ rescue OpenURI::HTTPError
93
+ warn _("WARN: Something went wrong downloading '#{package}'. Are you sure it exists?")
94
+
95
+ package == packages.last ? exit : next
126
96
  end
97
+
98
+ $stdout.puts _("(#{packages.index(package)+1}/#{packages.length}) downloaded #{package}")
127
99
  end
128
100
  end
129
101
 
@@ -131,12 +103,15 @@ module Aurb
131
103
  packages.each do |package|
132
104
  list(package).each do |id|
133
105
  result = json @config[:rpc]['info', id]
106
+
134
107
  unless result['type'] =~ /error/
135
108
  result = result['results']
109
+
136
110
  next if in_sync? result['Name']
111
+
137
112
  if package.any? {|pac| result['Name'].include?(pac) || result['Description'].include?(pac)}
138
- $stdout.puts "[#{result['OutOfDate'] == '1' ? ansi('✘', :red) : ansi('✔', :green)}] " +
139
- "#{ansi result['Name'], :blue} (#{result['Version']})\n #{result['Description']}"
113
+ $stdout.puts _("[#{result['OutOfDate'] == '1' ? ansi('✘', :red) : ansi('✔', :green)}] " +
114
+ "#{ansi result['Name'], :blue} (#{result['Version']})\n #{result['Description']}")
140
115
  end
141
116
  end
142
117
  end
@@ -144,20 +119,30 @@ module Aurb
144
119
  end
145
120
 
146
121
  def check_upgrade
147
- upgradable ||= []
148
- IO.popen('pacman -Qm', IO::RDONLY) {|pm| pm.read.lines}.each do |line|
149
- name, version = line.chomp.split
150
- result = json @config[:rpc]['info', name]
151
- unless result['type'] =~ /error/
152
- result = result['results']
153
- next if in_sync? result['Name']
154
- if VersionNumber.new(result['Version']) > VersionNumber.new(version)
155
- upgradable << result['Name']
156
- $stdout.puts "> #{name}: #{ansi version, :red} => #{ansi result['Version'], :green}"
122
+ if $have_lib[:version]
123
+ upgradable ||= []
124
+
125
+ IO.popen('pacman -Qm', IO::RDONLY) {|pm| pm.read.lines}.each do |line|
126
+ name, version = line.chomp.split
127
+ result = json @config[:rpc]['info', name]
128
+
129
+ unless result['type'] =~ /error/
130
+ result = result['results']
131
+
132
+ next if in_sync? result['Name']
133
+
134
+ if VersionNumber.new(result['Version']) > VersionNumber.new(version)
135
+ upgradable << result['Name']
136
+
137
+ $stdout.puts _("> #{name}: #{ansi version, :red} => #{ansi result['Version'], :green}")
138
+ end
157
139
  end
158
140
  end
141
+
142
+ upgradable.any? ? ($stdout.puts; download upgradable) : ($stdout.puts _('Nothing to update'))
143
+ else
144
+ warn _('WARN: You need the facets rubygem installed to check for updates')
159
145
  end
160
- upgradable.any? ? ($stdout.puts; download upgradable) : ($stdout.puts 'Nothing to update')
161
146
  end
162
147
 
163
148
  private
@@ -167,11 +152,13 @@ module Aurb
167
152
 
168
153
  def list package
169
154
  list, info = [], json(@config[:rpc]['search', URI.escape(package)])
155
+
170
156
  unless info['type'] =~ /error/
171
157
  info['results'].each do |result|
172
158
  list << result['ID']
173
159
  end
174
160
  end
161
+
175
162
  list.sort
176
163
  end
177
164
 
@@ -184,11 +171,15 @@ module Aurb
184
171
  end
185
172
 
186
173
  def untar package
187
- Archive::Tar::Minitar.unpack \
188
- Zlib::GzipReader.new(File.open("#{package}.tar.gz", 'rb')),
189
- Dir.pwd
174
+ if $have_lib[:minitar]
175
+ Archive::Tar::Minitar.unpack \
176
+ Zlib::GzipReader.new(File.open("#{package}.tar.gz", 'rb')),
177
+ Dir.pwd
190
178
 
191
- File.delete "#{package}.tar.gz"
179
+ File.delete "#{package}.tar.gz"
180
+ else
181
+ warn _('WARN: You need the facets rubygem installed to untar the package')
182
+ end
192
183
  end
193
184
 
194
185
  def json item
@@ -210,30 +201,30 @@ module Aurb
210
201
  def parse!
211
202
  ARGV.unshift '-h' if ARGV.empty?
212
203
  gopts = GetoptLong.new \
213
- ['--download', '-d', GetoptLong::REQUIRED_ARGUMENT],
214
- ['--search', '-s', GetoptLong::REQUIRED_ARGUMENT],
215
- ['--upgrade', '-u', GetoptLong::NO_ARGUMENT],
216
- ['--no-color', GetoptLong::NO_ARGUMENT],
217
- ['--path', GetoptLong::OPTIONAL_ARGUMENT],
218
- ['--version', '-v', GetoptLong::NO_ARGUMENT],
219
- ['--help', '-h', GetoptLong::NO_ARGUMENT]
204
+ ['--download', '-d', GetoptLong::REQUIRED_ARGUMENT],
205
+ ['--search', '-s', GetoptLong::REQUIRED_ARGUMENT],
206
+ ['--upgrade', '-u', GetoptLong::NO_ARGUMENT ],
207
+ ['--no-color', GetoptLong::NO_ARGUMENT ],
208
+ ['--path', GetoptLong::OPTIONAL_ARGUMENT],
209
+ ['--version', '-v', GetoptLong::NO_ARGUMENT ],
210
+ ['--help', '-h', GetoptLong::NO_ARGUMENT ]
220
211
 
221
212
  gopts.each do |opt, arg|
222
213
  case opt
223
214
  when '--download' then @cmd << ['download', arg.split]
224
- when '--search' then @cmd << ['search', arg.split]
225
- when '--upgrade' then @cmd << ['check_upgrade']
215
+ when '--search' then @cmd << ['search', arg.split]
216
+ when '--upgrade' then @cmd << ['check_upgrade' ]
226
217
  when '--no-color' then @config[:color] = false
227
218
  when '--path' then
228
219
  if File.exists? arg = (arg[0...1] == '/' ? arg : File.join(Dir.pwd, arg))
229
220
  @config[:path] = Pathname.new(arg).realpath || File.expand_path(arg)
230
221
  else
231
- warn "WARN: '#{arg}' does not exist. Fell back to [#{@config[:path]}]\n"
222
+ warn _("WARN: '#{arg}' does not exist. Fell back to [#{@config[:path]}]\n")
232
223
  end
233
- when '--version' then $stderr.puts '%s %s (%s)' %
224
+ when '--version' then $stdout.puts _('%s %s (%s)' %
234
225
  [
235
226
  :name, :version, :release
236
- ].map {|key| PrInfo[key]}
227
+ ].map {|key| PrInfo[key]})
237
228
  exit -1
238
229
  when '--help' then print_help
239
230
  end
@@ -241,8 +232,8 @@ module Aurb
241
232
  rescue GetoptLong::Error; exit 2
242
233
  end
243
234
 
244
- def print_help out = $stderr
245
- out.puts <<-HELP
235
+ def print_help out = $stdout
236
+ out.puts _(<<-HELP)
246
237
  Aurb - An AUR utility written in Ruby.
247
238
 
248
239
  Usage:
@@ -271,7 +262,6 @@ You can also chain commands, like so:
271
262
  #{name} -d 'thispackage' -s 'thatpackage' -u
272
263
 
273
264
  Aurb was inspired by arson. Do have a look at http://evaryont.github.com/arson
274
- For further information you can contact the author at <gigamo@gmail.com>.
275
265
  HELP
276
266
  exit -1
277
267
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gigamo-aurb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.3
4
+ version: 0.8.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gigamo
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-05-07 00:00:00 -07:00
12
+ date: 2009-06-15 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency