gigamo-aurb 0.8.1 → 0.8.2

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 +14 -4
  2. data/aurb.gemspec +2 -2
  3. data/bin/aurb +35 -45
  4. metadata +2 -2
data/README.rdoc CHANGED
@@ -2,11 +2,19 @@
2
2
 
3
3
  See <tt>aurb --help</tt> for a full list of commands.
4
4
 
5
- === Overview
5
+ === Quick Overview
6
6
 
7
- <b>--upgrade</b>:: Searches the AUR for upgrades to local packages that don't exist in any official repository
8
- <b>--download</b>:: Downloads your specified package(s) from the AUR and untars it
7
+ Required options:
8
+
9
+ <b>--download</b>:: Downloads a specified package and untars it
9
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
12
+
13
+ Optional options:
14
+
15
+ <b>--no-color</b>:: Suppress colored output
16
+ <b>--path</b>:: Override the default save path (defined as DlPath)
17
+ <b>--version</b>:: Print version and exit
10
18
 
11
19
  == Installation
12
20
 
@@ -24,7 +32,9 @@ For more information about setup.rb, see <tt>ruby setup.rb --help</tt>.
24
32
  If you prefer RubyGems:
25
33
 
26
34
  % gem build aurb.gemspec
27
- # gem install aurb-0.7.2.gem
35
+ # gem install aurb-$VERSION.gem
36
+
37
+ (substitute $VERSION with aurb's current version)
28
38
 
29
39
  There is also a github gem available:
30
40
 
data/aurb.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'aurb'
3
- s.version = '0.8.1'
4
- s.date = %q{2009-05-03}
3
+ s.version = '0.8.2'
4
+ s.date = %q{2009-05-04}
5
5
  s.summary = %q{A simple AUR utility}
6
6
  s.email = %q{gigamo@gmail.com}
7
7
  s.homepage = %q{http://github.com/gigamo/aurb}
data/bin/aurb CHANGED
@@ -26,7 +26,7 @@ module Aurb
26
26
  DlPath = File.join ENV['HOME'], 'abs'
27
27
 
28
28
  # Program info
29
- PrInfo = {:name => 'Aurb', :version => [0, 8, 1].join('.'), :release => '2009-05-03'}
29
+ PrInfo = {:name => 'Aurb', :version => [0, 8, 2].join('.'), :release => '2009-05-04'}
30
30
 
31
31
  class << self
32
32
  def aur
@@ -65,7 +65,10 @@ module Aurb
65
65
 
66
66
  def start
67
67
  set_trap
68
- instance_eval @opts.cmd
68
+ @opts.cmd.each do |cmd|
69
+ instance_eval cmd
70
+ say "\n---\n\n" unless cmd == @opts.cmd.last
71
+ end
69
72
  end
70
73
 
71
74
  def download packages
@@ -74,7 +77,6 @@ module Aurb
74
77
  abort 'FATAL: No package(s) to download. Possibly the package(s) you ' +
75
78
  'specified was/were found in the community repository?' if packages.empty?
76
79
  say "Targets (#{ansi packages.length, :magenta}): #{packages.join(', ')}"
77
-
78
80
  if yes_or_no? 'Proceed? '
79
81
  packages.each do |package|
80
82
  begin
@@ -82,27 +84,28 @@ module Aurb
82
84
  fetch package
83
85
  untar package
84
86
  end
85
- rescue OpenURI::HTTPError
86
- say "Something went wrong downloading '#{package}'. Are you sure it exists?"
87
+ rescue OpenURI::HTTPError => e
88
+ say "Something went wrong downloading '#{package}'. Are you sure it exists?\n" +
89
+ "---\n#{e.message}"
87
90
  package == packages.last ? exit : next
88
91
  end
89
-
90
92
  say "(#{packages.index(package)+1}/#{packages.length}) downloaded #{package}"
91
93
  end
92
94
  end
93
95
  end
94
96
 
95
- def search package
96
- list(package).each do |names|
97
- result = json @config[:rpc]['info', names.last]
98
-
99
- unless result['type'] =~ /error/
100
- result = result['results']
101
- next if in_sync? result['Name']
102
-
103
- if package.any? {|pac| result['Name'].include?(pac) || result['Description'].include?(pac)}
104
- say "[#{result['OutOfDate'] == '1' ? ansi('✘', :red) : ansi('✔', :green)}] " +
105
- "#{ansi result['Name'], :blue} (#{result['Version']})\n #{result['Description']}"
97
+ def search packages
98
+ packages = packages.split
99
+ packages.each do |package|
100
+ list(package).each do |names|
101
+ result = json @config[:rpc]['info', names.last]
102
+ unless result['type'] =~ /error/
103
+ result = result['results']
104
+ next if in_sync? result['Name']
105
+ if package.any? {|pac| result['Name'].include?(pac) || result['Description'].include?(pac)}
106
+ say "[#{result['OutOfDate'] == '1' ? ansi('✘', :red) : ansi('✔', :green)}] " +
107
+ "#{ansi result['Name'], :blue} (#{result['Version']})\n #{result['Description']}"
108
+ end
106
109
  end
107
110
  end
108
111
  end
@@ -111,22 +114,18 @@ module Aurb
111
114
  def check_upgrade
112
115
  upgradable = []
113
116
  say 'Searching for updates'
114
-
115
117
  IO.popen('pacman -Qm', IO::RDONLY) {|pm| pm.read.lines}.each do |line|
116
118
  name, version = line.chomp.split
117
119
  result = json @config[:rpc]['info', name]
118
-
119
120
  unless result['type'] =~ /error/
120
121
  result = result['results']
121
122
  next if in_sync? result['Name']
122
-
123
123
  if VersionNumber.new(result['Version']) > VersionNumber.new(version)
124
124
  upgradable << result['Name']
125
125
  say " #{name}: #{ansi version, :red} => #{ansi result['Version'], :green}"
126
126
  end
127
127
  end
128
128
  end
129
-
130
129
  upgradable.any? ? (say "\n"; download upgradable) : say('Nothing to update')
131
130
  end
132
131
 
@@ -137,13 +136,11 @@ module Aurb
137
136
 
138
137
  def list package
139
138
  info, list = json(@config[:rpc]['search', URI.escape(package)]), []
140
-
141
139
  unless info['type'] =~ /error/
142
140
  info['results'].each do |result|
143
141
  list << [result['Name'], result['ID']]
144
142
  end
145
143
  end
146
-
147
144
  list.sort
148
145
  end
149
146
 
@@ -156,14 +153,11 @@ module Aurb
156
153
  end
157
154
 
158
155
  def untar package
159
- abort "FATAL: #{package}.tar.gz not found for untar" \
160
- unless File.exists? "#{package}.tar.gz" # This should never, ever happen.
161
-
162
156
  Archive::Tar::Minitar.unpack \
163
157
  Zlib::GzipReader.new(File.open("#{package}.tar.gz", 'rb')),
164
158
  Dir.pwd
165
159
 
166
- FileUtils.rm "#{package}.tar.gz" if File.exists? "#{package}.tar.gz"
160
+ FileUtils.rm "#{package}.tar.gz"
167
161
  end
168
162
 
169
163
  def json item
@@ -172,37 +166,34 @@ module Aurb
172
166
  end
173
167
 
174
168
  class Opts
175
- attr_reader :cmd, :config
169
+ attr_reader :config
170
+ attr_reader :cmd
176
171
 
177
172
  def initialize
178
173
  @config = {:path => DlPath, :color => true}
179
- # Parse zeh ARGV!
174
+ @cmd = []
175
+
180
176
  parse!
181
177
  end
182
178
 
183
179
  private
184
- include Aurb::Util
185
-
186
180
  def parse!
187
- if ARGV.empty?
188
- abort 'No argument given. Try --help.'
189
- end
190
-
181
+ ARGV.unshift '-h' if ARGV.empty?
191
182
  gopts = GetoptLong.new \
192
183
  ['--download', '-d', GetoptLong::REQUIRED_ARGUMENT],
193
184
  ['--search', '-s', GetoptLong::REQUIRED_ARGUMENT],
194
185
  ['--upgrade', '-u', GetoptLong::NO_ARGUMENT],
195
- ['--color', GetoptLong::NO_ARGUMENT],
186
+ ['--no-color', GetoptLong::NO_ARGUMENT],
196
187
  ['--path', GetoptLong::OPTIONAL_ARGUMENT],
197
188
  ['--version', '-v', GetoptLong::NO_ARGUMENT],
198
189
  ['--help', '-h', GetoptLong::NO_ARGUMENT]
199
190
 
200
191
  gopts.each do |opt, arg|
201
192
  case opt
202
- when '--download' then @cmd = "download '#{arg}'"
203
- when '--search' then @cmd = "search '#{arg}'"
204
- when '--upgrade' then @cmd = 'check_upgrade'
205
- when '--color' then @config[:color] = !@config[:color]
193
+ when '--download' then @cmd << "download '#{arg}'"
194
+ when '--search' then @cmd << "search '#{arg}'"
195
+ when '--upgrade' then @cmd << 'check_upgrade'
196
+ when '--no-color' then @config[:color] = false
206
197
  when '--path' then
207
198
  if File.exists? arg = (arg[0...1] == '/' ? arg : File.join(Dir.pwd, arg))
208
199
  @config[:path] = Pathname.new(arg).realpath
@@ -216,7 +207,7 @@ module Aurb
216
207
  Aurb - An AUR utility written in Ruby.
217
208
 
218
209
  Usage:
219
- #$0 [options]
210
+ #{File.basename $0} [options]
220
211
 
221
212
  Options (Required):
222
213
  -d, --download PACKAGE Download a package.
@@ -224,14 +215,13 @@ Options (Required):
224
215
  -u, --upgrade Search for package updates.
225
216
 
226
217
  Optional:
227
- --color Use colors? [#{@config[:color]}]
218
+ --no-color Disable colored output.
228
219
  --path [PATH] Override the default save path. [#{@config[:path]}]
229
220
  --version Show version and exit.
230
221
  HELP
231
222
  end
232
223
  end
233
- rescue GetoptLong::Error
234
- abort $!.message
224
+ rescue GetoptLong::Error; exit 2
235
225
  end
236
226
  end
237
227
  end
@@ -247,7 +237,7 @@ __END__
247
237
 
248
238
  =head1 NAME
249
239
 
250
- Aurb - A Ruby AUR Utility
240
+ Aurb - An AUR utility written in Ruby
251
241
 
252
242
  =head1 SYNOPSIS
253
243
 
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.1
4
+ version: 0.8.2
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-03 00:00:00 -07:00
12
+ date: 2009-05-04 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency