aurb 0.9.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +7 -0
- data/LICENSE +339 -0
- data/README.md +0 -0
- data/bin/aurb +71 -204
- data/lib/aurb.rb +43 -0
- data/lib/aurb/aur.rb +121 -0
- data/lib/aurb/support.rb +71 -0
- data/lib/aurb/version.rb +19 -0
- data/test/test_helper.rb +15 -0
- data/test/unit/test_aur.rb +89 -0
- data/test/unit/test_support.rb +51 -0
- metadata +54 -18
- data/README.rdoc +0 -54
- data/aurb.gemspec +0 -19
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,339 @@
|
|
1
|
+
GNU GENERAL PUBLIC LICENSE
|
2
|
+
Version 2, June 1991
|
3
|
+
|
4
|
+
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
5
|
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
6
|
+
Everyone is permitted to copy and distribute verbatim copies
|
7
|
+
of this license document, but changing it is not allowed.
|
8
|
+
|
9
|
+
Preamble
|
10
|
+
|
11
|
+
The licenses for most software are designed to take away your
|
12
|
+
freedom to share and change it. By contrast, the GNU General Public
|
13
|
+
License is intended to guarantee your freedom to share and change free
|
14
|
+
software--to make sure the software is free for all its users. This
|
15
|
+
General Public License applies to most of the Free Software
|
16
|
+
Foundation's software and to any other program whose authors commit to
|
17
|
+
using it. (Some other Free Software Foundation software is covered by
|
18
|
+
the GNU Lesser General Public License instead.) You can apply it to
|
19
|
+
your programs, too.
|
20
|
+
|
21
|
+
When we speak of free software, we are referring to freedom, not
|
22
|
+
price. Our General Public Licenses are designed to make sure that you
|
23
|
+
have the freedom to distribute copies of free software (and charge for
|
24
|
+
this service if you wish), that you receive source code or can get it
|
25
|
+
if you want it, that you can change the software or use pieces of it
|
26
|
+
in new free programs; and that you know you can do these things.
|
27
|
+
|
28
|
+
To protect your rights, we need to make restrictions that forbid
|
29
|
+
anyone to deny you these rights or to ask you to surrender the rights.
|
30
|
+
These restrictions translate to certain responsibilities for you if you
|
31
|
+
distribute copies of the software, or if you modify it.
|
32
|
+
|
33
|
+
For example, if you distribute copies of such a program, whether
|
34
|
+
gratis or for a fee, you must give the recipients all the rights that
|
35
|
+
you have. You must make sure that they, too, receive or can get the
|
36
|
+
source code. And you must show them these terms so they know their
|
37
|
+
rights.
|
38
|
+
|
39
|
+
We protect your rights with two steps: (1) copyright the software, and
|
40
|
+
(2) offer you this license which gives you legal permission to copy,
|
41
|
+
distribute and/or modify the software.
|
42
|
+
|
43
|
+
Also, for each author's protection and ours, we want to make certain
|
44
|
+
that everyone understands that there is no warranty for this free
|
45
|
+
software. If the software is modified by someone else and passed on, we
|
46
|
+
want its recipients to know that what they have is not the original, so
|
47
|
+
that any problems introduced by others will not reflect on the original
|
48
|
+
authors' reputations.
|
49
|
+
|
50
|
+
Finally, any free program is threatened constantly by software
|
51
|
+
patents. We wish to avoid the danger that redistributors of a free
|
52
|
+
program will individually obtain patent licenses, in effect making the
|
53
|
+
program proprietary. To prevent this, we have made it clear that any
|
54
|
+
patent must be licensed for everyone's free use or not licensed at all.
|
55
|
+
|
56
|
+
The precise terms and conditions for copying, distribution and
|
57
|
+
modification follow.
|
58
|
+
|
59
|
+
GNU GENERAL PUBLIC LICENSE
|
60
|
+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
61
|
+
|
62
|
+
0. This License applies to any program or other work which contains
|
63
|
+
a notice placed by the copyright holder saying it may be distributed
|
64
|
+
under the terms of this General Public License. The "Program", below,
|
65
|
+
refers to any such program or work, and a "work based on the Program"
|
66
|
+
means either the Program or any derivative work under copyright law:
|
67
|
+
that is to say, a work containing the Program or a portion of it,
|
68
|
+
either verbatim or with modifications and/or translated into another
|
69
|
+
language. (Hereinafter, translation is included without limitation in
|
70
|
+
the term "modification".) Each licensee is addressed as "you".
|
71
|
+
|
72
|
+
Activities other than copying, distribution and modification are not
|
73
|
+
covered by this License; they are outside its scope. The act of
|
74
|
+
running the Program is not restricted, and the output from the Program
|
75
|
+
is covered only if its contents constitute a work based on the
|
76
|
+
Program (independent of having been made by running the Program).
|
77
|
+
Whether that is true depends on what the Program does.
|
78
|
+
|
79
|
+
1. You may copy and distribute verbatim copies of the Program's
|
80
|
+
source code as you receive it, in any medium, provided that you
|
81
|
+
conspicuously and appropriately publish on each copy an appropriate
|
82
|
+
copyright notice and disclaimer of warranty; keep intact all the
|
83
|
+
notices that refer to this License and to the absence of any warranty;
|
84
|
+
and give any other recipients of the Program a copy of this License
|
85
|
+
along with the Program.
|
86
|
+
|
87
|
+
You may charge a fee for the physical act of transferring a copy, and
|
88
|
+
you may at your option offer warranty protection in exchange for a fee.
|
89
|
+
|
90
|
+
2. You may modify your copy or copies of the Program or any portion
|
91
|
+
of it, thus forming a work based on the Program, and copy and
|
92
|
+
distribute such modifications or work under the terms of Section 1
|
93
|
+
above, provided that you also meet all of these conditions:
|
94
|
+
|
95
|
+
a) You must cause the modified files to carry prominent notices
|
96
|
+
stating that you changed the files and the date of any change.
|
97
|
+
|
98
|
+
b) You must cause any work that you distribute or publish, that in
|
99
|
+
whole or in part contains or is derived from the Program or any
|
100
|
+
part thereof, to be licensed as a whole at no charge to all third
|
101
|
+
parties under the terms of this License.
|
102
|
+
|
103
|
+
c) If the modified program normally reads commands interactively
|
104
|
+
when run, you must cause it, when started running for such
|
105
|
+
interactive use in the most ordinary way, to print or display an
|
106
|
+
announcement including an appropriate copyright notice and a
|
107
|
+
notice that there is no warranty (or else, saying that you provide
|
108
|
+
a warranty) and that users may redistribute the program under
|
109
|
+
these conditions, and telling the user how to view a copy of this
|
110
|
+
License. (Exception: if the Program itself is interactive but
|
111
|
+
does not normally print such an announcement, your work based on
|
112
|
+
the Program is not required to print an announcement.)
|
113
|
+
|
114
|
+
These requirements apply to the modified work as a whole. If
|
115
|
+
identifiable sections of that work are not derived from the Program,
|
116
|
+
and can be reasonably considered independent and separate works in
|
117
|
+
themselves, then this License, and its terms, do not apply to those
|
118
|
+
sections when you distribute them as separate works. But when you
|
119
|
+
distribute the same sections as part of a whole which is a work based
|
120
|
+
on the Program, the distribution of the whole must be on the terms of
|
121
|
+
this License, whose permissions for other licensees extend to the
|
122
|
+
entire whole, and thus to each and every part regardless of who wrote it.
|
123
|
+
|
124
|
+
Thus, it is not the intent of this section to claim rights or contest
|
125
|
+
your rights to work written entirely by you; rather, the intent is to
|
126
|
+
exercise the right to control the distribution of derivative or
|
127
|
+
collective works based on the Program.
|
128
|
+
|
129
|
+
In addition, mere aggregation of another work not based on the Program
|
130
|
+
with the Program (or with a work based on the Program) on a volume of
|
131
|
+
a storage or distribution medium does not bring the other work under
|
132
|
+
the scope of this License.
|
133
|
+
|
134
|
+
3. You may copy and distribute the Program (or a work based on it,
|
135
|
+
under Section 2) in object code or executable form under the terms of
|
136
|
+
Sections 1 and 2 above provided that you also do one of the following:
|
137
|
+
|
138
|
+
a) Accompany it with the complete corresponding machine-readable
|
139
|
+
source code, which must be distributed under the terms of Sections
|
140
|
+
1 and 2 above on a medium customarily used for software interchange; or,
|
141
|
+
|
142
|
+
b) Accompany it with a written offer, valid for at least three
|
143
|
+
years, to give any third party, for a charge no more than your
|
144
|
+
cost of physically performing source distribution, a complete
|
145
|
+
machine-readable copy of the corresponding source code, to be
|
146
|
+
distributed under the terms of Sections 1 and 2 above on a medium
|
147
|
+
customarily used for software interchange; or,
|
148
|
+
|
149
|
+
c) Accompany it with the information you received as to the offer
|
150
|
+
to distribute corresponding source code. (This alternative is
|
151
|
+
allowed only for noncommercial distribution and only if you
|
152
|
+
received the program in object code or executable form with such
|
153
|
+
an offer, in accord with Subsection b above.)
|
154
|
+
|
155
|
+
The source code for a work means the preferred form of the work for
|
156
|
+
making modifications to it. For an executable work, complete source
|
157
|
+
code means all the source code for all modules it contains, plus any
|
158
|
+
associated interface definition files, plus the scripts used to
|
159
|
+
control compilation and installation of the executable. However, as a
|
160
|
+
special exception, the source code distributed need not include
|
161
|
+
anything that is normally distributed (in either source or binary
|
162
|
+
form) with the major components (compiler, kernel, and so on) of the
|
163
|
+
operating system on which the executable runs, unless that component
|
164
|
+
itself accompanies the executable.
|
165
|
+
|
166
|
+
If distribution of executable or object code is made by offering
|
167
|
+
access to copy from a designated place, then offering equivalent
|
168
|
+
access to copy the source code from the same place counts as
|
169
|
+
distribution of the source code, even though third parties are not
|
170
|
+
compelled to copy the source along with the object code.
|
171
|
+
|
172
|
+
4. You may not copy, modify, sublicense, or distribute the Program
|
173
|
+
except as expressly provided under this License. Any attempt
|
174
|
+
otherwise to copy, modify, sublicense or distribute the Program is
|
175
|
+
void, and will automatically terminate your rights under this License.
|
176
|
+
However, parties who have received copies, or rights, from you under
|
177
|
+
this License will not have their licenses terminated so long as such
|
178
|
+
parties remain in full compliance.
|
179
|
+
|
180
|
+
5. You are not required to accept this License, since you have not
|
181
|
+
signed it. However, nothing else grants you permission to modify or
|
182
|
+
distribute the Program or its derivative works. These actions are
|
183
|
+
prohibited by law if you do not accept this License. Therefore, by
|
184
|
+
modifying or distributing the Program (or any work based on the
|
185
|
+
Program), you indicate your acceptance of this License to do so, and
|
186
|
+
all its terms and conditions for copying, distributing or modifying
|
187
|
+
the Program or works based on it.
|
188
|
+
|
189
|
+
6. Each time you redistribute the Program (or any work based on the
|
190
|
+
Program), the recipient automatically receives a license from the
|
191
|
+
original licensor to copy, distribute or modify the Program subject to
|
192
|
+
these terms and conditions. You may not impose any further
|
193
|
+
restrictions on the recipients' exercise of the rights granted herein.
|
194
|
+
You are not responsible for enforcing compliance by third parties to
|
195
|
+
this License.
|
196
|
+
|
197
|
+
7. If, as a consequence of a court judgment or allegation of patent
|
198
|
+
infringement or for any other reason (not limited to patent issues),
|
199
|
+
conditions are imposed on you (whether by court order, agreement or
|
200
|
+
otherwise) that contradict the conditions of this License, they do not
|
201
|
+
excuse you from the conditions of this License. If you cannot
|
202
|
+
distribute so as to satisfy simultaneously your obligations under this
|
203
|
+
License and any other pertinent obligations, then as a consequence you
|
204
|
+
may not distribute the Program at all. For example, if a patent
|
205
|
+
license would not permit royalty-free redistribution of the Program by
|
206
|
+
all those who receive copies directly or indirectly through you, then
|
207
|
+
the only way you could satisfy both it and this License would be to
|
208
|
+
refrain entirely from distribution of the Program.
|
209
|
+
|
210
|
+
If any portion of this section is held invalid or unenforceable under
|
211
|
+
any particular circumstance, the balance of the section is intended to
|
212
|
+
apply and the section as a whole is intended to apply in other
|
213
|
+
circumstances.
|
214
|
+
|
215
|
+
It is not the purpose of this section to induce you to infringe any
|
216
|
+
patents or other property right claims or to contest validity of any
|
217
|
+
such claims; this section has the sole purpose of protecting the
|
218
|
+
integrity of the free software distribution system, which is
|
219
|
+
implemented by public license practices. Many people have made
|
220
|
+
generous contributions to the wide range of software distributed
|
221
|
+
through that system in reliance on consistent application of that
|
222
|
+
system; it is up to the author/donor to decide if he or she is willing
|
223
|
+
to distribute software through any other system and a licensee cannot
|
224
|
+
impose that choice.
|
225
|
+
|
226
|
+
This section is intended to make thoroughly clear what is believed to
|
227
|
+
be a consequence of the rest of this License.
|
228
|
+
|
229
|
+
8. If the distribution and/or use of the Program is restricted in
|
230
|
+
certain countries either by patents or by copyrighted interfaces, the
|
231
|
+
original copyright holder who places the Program under this License
|
232
|
+
may add an explicit geographical distribution limitation excluding
|
233
|
+
those countries, so that distribution is permitted only in or among
|
234
|
+
countries not thus excluded. In such case, this License incorporates
|
235
|
+
the limitation as if written in the body of this License.
|
236
|
+
|
237
|
+
9. The Free Software Foundation may publish revised and/or new versions
|
238
|
+
of the General Public License from time to time. Such new versions will
|
239
|
+
be similar in spirit to the present version, but may differ in detail to
|
240
|
+
address new problems or concerns.
|
241
|
+
|
242
|
+
Each version is given a distinguishing version number. If the Program
|
243
|
+
specifies a version number of this License which applies to it and "any
|
244
|
+
later version", you have the option of following the terms and conditions
|
245
|
+
either of that version or of any later version published by the Free
|
246
|
+
Software Foundation. If the Program does not specify a version number of
|
247
|
+
this License, you may choose any version ever published by the Free Software
|
248
|
+
Foundation.
|
249
|
+
|
250
|
+
10. If you wish to incorporate parts of the Program into other free
|
251
|
+
programs whose distribution conditions are different, write to the author
|
252
|
+
to ask for permission. For software which is copyrighted by the Free
|
253
|
+
Software Foundation, write to the Free Software Foundation; we sometimes
|
254
|
+
make exceptions for this. Our decision will be guided by the two goals
|
255
|
+
of preserving the free status of all derivatives of our free software and
|
256
|
+
of promoting the sharing and reuse of software generally.
|
257
|
+
|
258
|
+
NO WARRANTY
|
259
|
+
|
260
|
+
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
261
|
+
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
262
|
+
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
263
|
+
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
264
|
+
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
265
|
+
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
266
|
+
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
267
|
+
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
268
|
+
REPAIR OR CORRECTION.
|
269
|
+
|
270
|
+
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
271
|
+
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
272
|
+
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
273
|
+
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
274
|
+
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
275
|
+
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
276
|
+
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
277
|
+
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
278
|
+
POSSIBILITY OF SUCH DAMAGES.
|
279
|
+
|
280
|
+
END OF TERMS AND CONDITIONS
|
281
|
+
|
282
|
+
How to Apply These Terms to Your New Programs
|
283
|
+
|
284
|
+
If you develop a new program, and you want it to be of the greatest
|
285
|
+
possible use to the public, the best way to achieve this is to make it
|
286
|
+
free software which everyone can redistribute and change under these terms.
|
287
|
+
|
288
|
+
To do so, attach the following notices to the program. It is safest
|
289
|
+
to attach them to the start of each source file to most effectively
|
290
|
+
convey the exclusion of warranty; and each file should have at least
|
291
|
+
the "copyright" line and a pointer to where the full notice is found.
|
292
|
+
|
293
|
+
<one line to give the program's name and a brief idea of what it does.>
|
294
|
+
Copyright (C) <year> <name of author>
|
295
|
+
|
296
|
+
This program is free software; you can redistribute it and/or modify
|
297
|
+
it under the terms of the GNU General Public License as published by
|
298
|
+
the Free Software Foundation; either version 2 of the License, or
|
299
|
+
(at your option) any later version.
|
300
|
+
|
301
|
+
This program is distributed in the hope that it will be useful,
|
302
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
303
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
304
|
+
GNU General Public License for more details.
|
305
|
+
|
306
|
+
You should have received a copy of the GNU General Public License along
|
307
|
+
with this program; if not, write to the Free Software Foundation, Inc.,
|
308
|
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
309
|
+
|
310
|
+
Also add information on how to contact you by electronic and paper mail.
|
311
|
+
|
312
|
+
If the program is interactive, make it output a short notice like this
|
313
|
+
when it starts in an interactive mode:
|
314
|
+
|
315
|
+
Gnomovision version 69, Copyright (C) year name of author
|
316
|
+
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
317
|
+
This is free software, and you are welcome to redistribute it
|
318
|
+
under certain conditions; type `show c' for details.
|
319
|
+
|
320
|
+
The hypothetical commands `show w' and `show c' should show the appropriate
|
321
|
+
parts of the General Public License. Of course, the commands you use may
|
322
|
+
be called something other than `show w' and `show c'; they could even be
|
323
|
+
mouse-clicks or menu items--whatever suits your program.
|
324
|
+
|
325
|
+
You should also get your employer (if you work as a programmer) or your
|
326
|
+
school, if any, to sign a "copyright disclaimer" for the program, if
|
327
|
+
necessary. Here is a sample; alter the names:
|
328
|
+
|
329
|
+
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
330
|
+
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
331
|
+
|
332
|
+
<signature of Ty Coon>, 1 April 1989
|
333
|
+
Ty Coon, President of Vice
|
334
|
+
|
335
|
+
This General Public License does not permit incorporating your program into
|
336
|
+
proprietary programs. If your program is a subroutine library, you may
|
337
|
+
consider it more useful to permit linking proprietary applications with the
|
338
|
+
library. If this is what you want to do, use the GNU Lesser General
|
339
|
+
Public License instead of this License.
|
data/README.md
ADDED
File without changes
|
data/bin/aurb
CHANGED
@@ -5,220 +5,87 @@
|
|
5
5
|
# Copyright protects this work.
|
6
6
|
# See LICENSE file for details.
|
7
7
|
#++
|
8
|
-
%w[rubygems getoptlong pathname zlib open-uri yajl gettext
|
9
|
-
facets/ansicode facets/minitar facets/version].each do |lib|
|
10
|
-
begin
|
11
|
-
require lib
|
12
|
-
rescue LoadError
|
13
|
-
abort "F: You're missing '#{lib}'.\nPlease make sure you have the necessary rubygems installed."
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def _ str
|
18
|
-
GetText::_(str)
|
19
|
-
end
|
20
|
-
|
21
|
-
module Aurb
|
22
|
-
DlPath = File.join ENV['HOME'], 'abs'
|
23
|
-
PrInfo = {:name => 'Aurb', :version => [0, 9, 3].join('.'), :release => '2009-12-02'}
|
24
|
-
|
25
|
-
module Util
|
26
|
-
def ansi text, effect
|
27
|
-
(@config[:color] ? ANSICode.send(effect.to_sym) : '') << text.to_s << ANSICode.clear
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
class Aur
|
32
|
-
include Aurb::Util
|
33
|
-
|
34
|
-
class << self
|
35
|
-
def start
|
36
|
-
trap :INT do
|
37
|
-
$stderr.puts _("\nInterrupt signal received\n\n")
|
38
|
-
exit 0
|
39
|
-
end
|
40
|
-
|
41
|
-
self.new :rpc => proc {|type, arg| "http://aur.archlinux.org/rpc.php?type=#{type}&arg=#{arg}"}
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def initialize config
|
46
|
-
opts = Opts.new
|
47
|
-
@config = config.merge(opts.config)
|
48
8
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
$stdout.puts _("[#{result['OutOfDate'] == '1' ? ansi('✘', :red) : ansi('✔', :green)}] " +
|
82
|
-
"#{ansi result['Name'], :blue} (#{result['Version']})\n #{result['Description']}")
|
9
|
+
require File.expand_path(File.dirname(__FILE__) + '/../lib/aurb')
|
10
|
+
|
11
|
+
class Session
|
12
|
+
include Aurb::Aur
|
13
|
+
|
14
|
+
@@path ||= ENV[:HOME] + '/abs'
|
15
|
+
|
16
|
+
def self.parse_options
|
17
|
+
ARGV.unshift '-h' if ARGV.empty?
|
18
|
+
|
19
|
+
gopts = GetoptLong.new(
|
20
|
+
['--download', '-d', GetoptLong::REQUIRED_ARGUMENT],
|
21
|
+
['--search', '-s', GetoptLong::REQUIRED_ARGUMENT],
|
22
|
+
['--upgrade', '-u', GetoptLong::NO_ARGUMENT ],
|
23
|
+
['--version', '-v', GetoptLong::NO_ARGUMENT ],
|
24
|
+
['--help', '-h', GetoptLong::NO_ARGUMENT ]
|
25
|
+
)
|
26
|
+
|
27
|
+
gopts.each do |opt, args|
|
28
|
+
case opt
|
29
|
+
when '--download'
|
30
|
+
packages = download(args.split)
|
31
|
+
packages.each_with_index do |package, index|
|
32
|
+
current = index + 1
|
33
|
+
total = packages.size
|
34
|
+
local = package.split('/')[-1]
|
35
|
+
|
36
|
+
Dir.chdir(@@path) do
|
37
|
+
open(package) do |remote|
|
38
|
+
File.open(local, 'wb') do |local|
|
39
|
+
local.write remote.read
|
40
|
+
end
|
83
41
|
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
42
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
result = json @config[:rpc]['info', name]
|
94
|
-
unless result['type'] =~ /error/
|
95
|
-
result = result['results']
|
96
|
-
next if in_sync? result['Name']
|
97
|
-
if VersionNumber.new(result['Version']) > VersionNumber.new(version)
|
98
|
-
upgradables << result['Name']
|
99
|
-
$stdout.puts _("* #{name}: #{ansi version, :red} => #{ansi result['Version'], :green}")
|
43
|
+
Archive::Tar::Minitar.unpack(
|
44
|
+
Zlib::GzipReader.new(File.open(local, 'rb')), Dir.pwd
|
45
|
+
)
|
46
|
+
File.delete local
|
100
47
|
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
upgradables.any? ? (download upgradables) : ($stdout.puts _('Nothing to update'))
|
104
|
-
end
|
105
48
|
|
106
|
-
|
107
|
-
def in_sync? package
|
108
|
-
!!Dir["/var/lib/pacman/sync/community/#{package}-*"].first
|
109
|
-
end
|
110
|
-
|
111
|
-
def list package
|
112
|
-
list = []
|
113
|
-
info = json @config[:rpc]['search', URI.escape(package)]
|
114
|
-
unless info['type'] =~ /error/
|
115
|
-
info['results'].each do |result|
|
116
|
-
list << result['ID']
|
49
|
+
puts "(#{current}/#{total}) downloaded #{local}"
|
117
50
|
end
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
51
|
+
when '--search'
|
52
|
+
packages = search(args.split)
|
53
|
+
packages.each do |package|
|
54
|
+
status = package.OutOfDate == '1' ? '✘'.colorize(:red) : '✔'.colorize(:green)
|
55
|
+
name = package.Name.colorize(:yellow)
|
56
|
+
version = package.Version
|
57
|
+
description = package.Description
|
58
|
+
|
59
|
+
puts "[#{status}] #{name} (#{version})\n #{description}"
|
126
60
|
end
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
Dir.pwd
|
134
|
-
File.delete "#{package}.tar.gz"
|
135
|
-
end
|
136
|
-
|
137
|
-
def json item
|
138
|
-
Yajl::Parser.new.parse(open(item).read)
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
class Opts
|
143
|
-
attr_reader :config, :cmd
|
144
|
-
|
145
|
-
def initialize
|
146
|
-
@cmd = []
|
147
|
-
@config = {:path => DlPath, :color => true}
|
148
|
-
|
149
|
-
parse!
|
150
|
-
self
|
151
|
-
end
|
152
|
-
|
153
|
-
private
|
154
|
-
def parse!
|
155
|
-
ARGV.unshift '-h' if ARGV.empty?
|
156
|
-
|
157
|
-
gopts = GetoptLong.new \
|
158
|
-
['--download', '-d', GetoptLong::REQUIRED_ARGUMENT],
|
159
|
-
['--search', '-s', GetoptLong::REQUIRED_ARGUMENT],
|
160
|
-
['--upgrade', '-u', GetoptLong::NO_ARGUMENT ],
|
161
|
-
['--no-color', GetoptLong::NO_ARGUMENT ],
|
162
|
-
['--path', GetoptLong::OPTIONAL_ARGUMENT],
|
163
|
-
['--version', '-v', GetoptLong::NO_ARGUMENT ],
|
164
|
-
['--help', '-h', GetoptLong::NO_ARGUMENT ]
|
165
|
-
|
166
|
-
gopts.each do |opt, arg|
|
167
|
-
case opt
|
168
|
-
when '--download' then @cmd << ['download', arg.split]
|
169
|
-
when '--search' then @cmd << ['search', arg.split]
|
170
|
-
when '--upgrade' then @cmd << ['check_upgrade' ]
|
171
|
-
when '--no-color' then @config[:color] = false
|
172
|
-
when '--path'
|
173
|
-
if File.exists? arg = (arg[0...1] == '/' ? arg : File.join(Dir.pwd, arg))
|
174
|
-
@config[:path] = Pathname.new(arg).realpath || File.expand_path(arg)
|
175
|
-
else
|
176
|
-
warn _("W: '#{arg}' does not exist. Fell back to [#{@config[:path]}]\n")
|
177
|
-
end
|
178
|
-
when '--version'
|
179
|
-
$stdout.puts _('%s %s (%s)' % [:name, :version, :release].map {|key| PrInfo[key]})
|
180
|
-
exit -1
|
181
|
-
when '--help' then print_help
|
61
|
+
when '--upgrade'
|
62
|
+
local_list = `pacman -Qm`.split(/\n/)
|
63
|
+
packages = upgrade(local_list)
|
64
|
+
puts 'Nothing to upgrade' and return if packages.blank?
|
65
|
+
packages.each do |package|
|
66
|
+
puts "#{package} has an upgrade available"
|
182
67
|
end
|
68
|
+
when '--version'
|
69
|
+
puts Aurb::Version
|
70
|
+
when '--help'
|
71
|
+
puts %{
|
72
|
+
Aurb - An AUR (Arch User Repository) script
|
73
|
+
|
74
|
+
Usage:
|
75
|
+
#{name = File.basename $0} [options]
|
76
|
+
|
77
|
+
Options (Required):
|
78
|
+
-d, --download "packages" Download package(s).
|
79
|
+
-s, --search "packages" Search package(s).
|
80
|
+
-u, --upgrade Search for package upgrades.
|
81
|
+
|
82
|
+
Other:
|
83
|
+
--version Show version and exit.
|
84
|
+
--help You're looking at it.
|
85
|
+
}
|
183
86
|
end
|
184
|
-
rescue GetoptLong::Error; exit 2
|
185
|
-
end
|
186
|
-
|
187
|
-
def print_help out = $stdout
|
188
|
-
out.puts _(<<-HELP)
|
189
|
-
Aurb - An AUR (Arch User Repository) script
|
190
|
-
|
191
|
-
Usage:
|
192
|
-
#{name = File.basename $0} [options]
|
193
|
-
|
194
|
-
Options (Required):
|
195
|
-
-d, --download PACKAGE Download package(s).
|
196
|
-
-s, --search PACKAGE Search for package(s).
|
197
|
-
-u, --upgrade Search for package updates.
|
198
|
-
|
199
|
-
Optional:
|
200
|
-
--no-color Disable colored output.
|
201
|
-
--path [PATH] Override the default save path. [#{@config[:path]}]
|
202
|
-
|
203
|
-
Other:
|
204
|
-
--version Show version and exit.
|
205
|
-
--help You're looking at it.
|
206
|
-
|
207
|
-
Examples:
|
208
|
-
#{name} -d 'package1 package2' --path ~/downloads
|
209
|
-
#{name} -s 'package1 package2' --no-color
|
210
|
-
#{name} --upgrade
|
211
|
-
|
212
|
-
Aurb was inspired by arson. Have a look at http://evaryont.github.com/arson
|
213
|
-
HELP
|
214
|
-
exit -1
|
215
87
|
end
|
216
88
|
end
|
217
89
|
end
|
218
90
|
|
219
|
-
|
220
|
-
if __FILE__ == $0
|
221
|
-
raise $! if $!
|
222
|
-
Aurb::Aur.start
|
223
|
-
end
|
224
|
-
end
|
91
|
+
Session.parse_options
|
data/lib/aurb.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
#
|
4
|
+
#--
|
5
|
+
# Copyright protects this work.
|
6
|
+
# See LICENSE file for details.
|
7
|
+
#++
|
8
|
+
|
9
|
+
require 'logger'
|
10
|
+
require 'getoptlong'
|
11
|
+
require 'zlib'
|
12
|
+
require 'open-uri'
|
13
|
+
require 'yajl'
|
14
|
+
require 'ansi'
|
15
|
+
require 'archive/tar/minitar'
|
16
|
+
require 'facets/version'
|
17
|
+
|
18
|
+
module Aurb
|
19
|
+
# Generic Aurb error.
|
20
|
+
class AurbError < StandardError; end
|
21
|
+
|
22
|
+
# Raised for faulty arguments.
|
23
|
+
class AurbArgumentError < AurbError
|
24
|
+
def initialize
|
25
|
+
super('Invalid arguments')
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# Make a +Logger+ object available.
|
30
|
+
def self.logger
|
31
|
+
@logger ||= Logger.new(STDOUT)
|
32
|
+
end
|
33
|
+
|
34
|
+
# Returns an URL which will be used for JSON parsing.
|
35
|
+
def self.aur_path(type, arg)
|
36
|
+
"http://aur.archlinux.org/rpc.php?type=#{type}&arg=#{arg}"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
$LOAD_PATH.unshift File.dirname(__FILE__)
|
41
|
+
require 'aurb/support'
|
42
|
+
require 'aurb/aur'
|
43
|
+
require 'aurb/version'
|
data/lib/aurb/aur.rb
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
#
|
4
|
+
#--
|
5
|
+
# Copyright protects this work.
|
6
|
+
# See LICENSE file for details.
|
7
|
+
#++
|
8
|
+
|
9
|
+
module Aurb
|
10
|
+
module Aur
|
11
|
+
def self.included(klass)
|
12
|
+
klass.class_eval { extend ClassMethods }
|
13
|
+
end
|
14
|
+
|
15
|
+
module ClassMethods
|
16
|
+
# Search the AUR for given +packages+.
|
17
|
+
# Returns an array of results.
|
18
|
+
#
|
19
|
+
# search(['aurb']) # => [{:ID => ..., :Name => 'aurb', ...}, {...}]
|
20
|
+
def search(packages)
|
21
|
+
if packages.is_a?(Array)
|
22
|
+
results = packages.map do |package|
|
23
|
+
list_search_results(package)
|
24
|
+
end.flatten
|
25
|
+
elsif packages.is_a?(String) || packages.is_a?(Symbol)
|
26
|
+
results = list_search_results(packages)
|
27
|
+
else
|
28
|
+
raise AurbArgumentError and return
|
29
|
+
end
|
30
|
+
|
31
|
+
results
|
32
|
+
end
|
33
|
+
|
34
|
+
# Download +packages+ from the AUR.
|
35
|
+
# Returns an array of downloadable package urls.
|
36
|
+
#
|
37
|
+
# download(['aurb']) # => ['http://.../aurb.tar.gz']
|
38
|
+
def download(packages)
|
39
|
+
if packages.is_a?(String) || packages.is_a?(Symbol)
|
40
|
+
packages = packages.to_s.split(/\s+/)
|
41
|
+
end
|
42
|
+
raise AurbArgumentError and return unless packages.is_a?(Array)
|
43
|
+
|
44
|
+
url = lambda {|p| "http://aur.archlinux.org/packages/#{p}/#{p}.tar.gz"}
|
45
|
+
|
46
|
+
downloadables = packages.map do |package|
|
47
|
+
url.call(URI.escape(package.to_s))
|
48
|
+
end.select do |package|
|
49
|
+
downloadable?(package)
|
50
|
+
end
|
51
|
+
|
52
|
+
downloadables
|
53
|
+
end
|
54
|
+
|
55
|
+
# Returns a +list+ of names of packages that have an upgrade
|
56
|
+
# available to them, which could then in turn be passed on to
|
57
|
+
# the +download+ method.
|
58
|
+
#
|
59
|
+
# # With Aurb on the AUR as version [0, 8, 2, 1]
|
60
|
+
# upgrade(['aurb 0.0.0.0', 'aurb 0.9.9.9']) # => [:aurb]
|
61
|
+
def upgrade(list)
|
62
|
+
upgradables = []
|
63
|
+
|
64
|
+
list.each do |line|
|
65
|
+
name, version = line.split
|
66
|
+
next if in_community?(name)
|
67
|
+
upgradables << name if upgradable?(name, version)
|
68
|
+
end
|
69
|
+
|
70
|
+
upgradables.map(&:to_sym)
|
71
|
+
end
|
72
|
+
|
73
|
+
private
|
74
|
+
# See if +package+ is available in the community repository.
|
75
|
+
def in_community?(package)
|
76
|
+
Dir["/var/lib/pacman/sync/community/#{package}-*"].any?
|
77
|
+
end
|
78
|
+
|
79
|
+
# Shortcut to the +Yajl+ JSON parser.
|
80
|
+
def parse_json(json)
|
81
|
+
Yajl::Parser.new.parse(open(json).read)
|
82
|
+
end
|
83
|
+
|
84
|
+
# Check if +package+ is available for download.
|
85
|
+
def downloadable?(package)
|
86
|
+
open package rescue false
|
87
|
+
end
|
88
|
+
|
89
|
+
# Compare version of local +package+ with the one on the AUR.
|
90
|
+
def upgradable?(package, version)
|
91
|
+
json = parse_json(Aurb.aur_path(:info, package.to_s))
|
92
|
+
return if json.type =~ /error/
|
93
|
+
remote_package = json.results
|
94
|
+
|
95
|
+
local_version = VersionNumber.new(version)
|
96
|
+
remote_version = VersionNumber.new(remote_package.Version)
|
97
|
+
|
98
|
+
local_version < remote_version
|
99
|
+
end
|
100
|
+
|
101
|
+
# Returns an array containing a hash of search results
|
102
|
+
# for a given +package+.
|
103
|
+
def list_search_results(package)
|
104
|
+
json = parse_json(Aurb.aur_path(:search, URI.escape(package.to_s)))
|
105
|
+
return if json.type =~ /error/
|
106
|
+
ids = json.results.map(&:ID)
|
107
|
+
results = []
|
108
|
+
|
109
|
+
ids.each do |id|
|
110
|
+
json = parse_json(Aurb.aur_path(:info, id))
|
111
|
+
next if json.type =~ /error/
|
112
|
+
result = json.results.symbolize_keys
|
113
|
+
results << result unless in_community?(result[:Name])
|
114
|
+
end
|
115
|
+
|
116
|
+
results
|
117
|
+
end
|
118
|
+
# private
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
data/lib/aurb/support.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
#
|
4
|
+
# Most of these extracted from Rails source (http://github.com/rails/rails)
|
5
|
+
|
6
|
+
class Object
|
7
|
+
# An object is blank if it's false, empty or a whitespace string.
|
8
|
+
def blank?
|
9
|
+
respond_to?(:empty?) ? empty? : !self
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class Symbol
|
14
|
+
# Turns the symbol into a proc, useful for enumerations.
|
15
|
+
#
|
16
|
+
# items.select(&:cool?).map(&:name)
|
17
|
+
# # Does the same as
|
18
|
+
# items.select {|i| i.cool?}.map {|i| i.name}
|
19
|
+
def to_proc
|
20
|
+
Proc.new {|obj| obj.__send__(self)}
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class Hash
|
25
|
+
# Returns a new hash with all keys converted to symbols.
|
26
|
+
def symbolize_keys
|
27
|
+
inject({}) do |options, (key, value)|
|
28
|
+
options[(key.to_sym rescue key) || key] = value
|
29
|
+
options
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# Destructively converts all keys to symbols.
|
34
|
+
def symbolize_keys!
|
35
|
+
self.replace(self.symbolize_keys)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Delegation
|
39
|
+
def method_missing(key)
|
40
|
+
self.symbolize_keys[key.to_sym]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
class Array
|
45
|
+
# Extracts options from a set of arguments.
|
46
|
+
#
|
47
|
+
# def options(*args)
|
48
|
+
# args.extract_options!
|
49
|
+
# end
|
50
|
+
#
|
51
|
+
# options(1, 2) # => {}
|
52
|
+
# options(1, 2, :a => :b) # => {:a=>:b}
|
53
|
+
def extract_options!
|
54
|
+
last.is_a?(Hash) ? pop : {}
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
class String
|
59
|
+
# Colors a string with +color+.
|
60
|
+
# Uses the ANSICode library provided by +facets+.
|
61
|
+
#
|
62
|
+
# "Hello".colorize(:blue) # => "\e[34mHello\e[0m"
|
63
|
+
#
|
64
|
+
# For more information on available effects, see
|
65
|
+
# http://facets.rubyforge.org/apidoc/api/more/classes/ANSICode.html
|
66
|
+
def colorize(effect)
|
67
|
+
ANSI::Code.send(effect.to_sym) << self << ANSI::Code.clear
|
68
|
+
rescue
|
69
|
+
self
|
70
|
+
end
|
71
|
+
end
|
data/lib/aurb/version.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
#
|
4
|
+
#--
|
5
|
+
# Copyright protects this work.
|
6
|
+
# See LICENSE file for details.
|
7
|
+
#++
|
8
|
+
|
9
|
+
module Aurb
|
10
|
+
module Version
|
11
|
+
MAJOR = '1'
|
12
|
+
MINOR = '0'
|
13
|
+
TINY = '0'
|
14
|
+
|
15
|
+
def self.to_s
|
16
|
+
[MAJOR, MINOR, TINY].join('.').freeze
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
|
+
|
3
|
+
class AurTest < Test::Unit::TestCase
|
4
|
+
context 'Aur ClassMethod' do
|
5
|
+
setup do
|
6
|
+
@session = Session()
|
7
|
+
end
|
8
|
+
|
9
|
+
context 'upgrade' do
|
10
|
+
setup do
|
11
|
+
@list = ['aurb 0.0.0.0',
|
12
|
+
'aurb 0.9.9.9']
|
13
|
+
end
|
14
|
+
|
15
|
+
should 'return an array' do
|
16
|
+
assert @session.upgrade(@list).is_a?(Array)
|
17
|
+
end
|
18
|
+
|
19
|
+
should 'contain only upgradable packages' do
|
20
|
+
assert_not_equal [:aurb, :aurb], @session.upgrade(@list)
|
21
|
+
assert_equal [:aurb], @session.upgrade(@list)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'download' do
|
26
|
+
setup do
|
27
|
+
@url = lambda {|p| "http://aur.archlinux.org/packages/#{p}/#{p}.tar.gz"}
|
28
|
+
@package_working = 'awesome-git'
|
29
|
+
@package_faulty = 'awesome'
|
30
|
+
end
|
31
|
+
|
32
|
+
should 'accept arrays, symbols and strings' do
|
33
|
+
assert_nothing_raised { @session.download(@package_working.to_s) }
|
34
|
+
assert_nothing_raised { @session.download(@package_working.split) }
|
35
|
+
assert_nothing_raised { @session.download(@package_working.to_sym) }
|
36
|
+
end
|
37
|
+
|
38
|
+
should 'return an array' do
|
39
|
+
assert @session.download(@package_working).is_a?(Array)
|
40
|
+
assert @session.download(@package_faulty).is_a?(Array)
|
41
|
+
end
|
42
|
+
|
43
|
+
should 'return download links' do
|
44
|
+
assert_equal [@url.call(@package_working)], @session.download(@package_working)
|
45
|
+
end
|
46
|
+
|
47
|
+
should 'filter out non-existant packages' do
|
48
|
+
assert_equal [], @session.download(@package_faulty)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context 'search' do
|
53
|
+
setup do
|
54
|
+
@package = 'aurb'
|
55
|
+
end
|
56
|
+
|
57
|
+
should 'accept arrays, symbols and strings' do
|
58
|
+
assert_nothing_raised { @session.search(@package.to_s) }
|
59
|
+
assert_nothing_raised { @session.search(@package.split) }
|
60
|
+
assert_nothing_raised { @session.search(@package.to_sym) }
|
61
|
+
end
|
62
|
+
|
63
|
+
should 'return an array of results' do
|
64
|
+
assert @session.search(@package.to_s).is_a?(Array)
|
65
|
+
assert @session.search(@package.split).is_a?(Array)
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'result' do
|
69
|
+
setup do
|
70
|
+
@result = @session.search(@package).first
|
71
|
+
end
|
72
|
+
|
73
|
+
should 'return an array containing hashes' do
|
74
|
+
assert @result.is_a?(Hash)
|
75
|
+
end
|
76
|
+
|
77
|
+
context 'keys' do
|
78
|
+
setup do
|
79
|
+
@key = @result.keys.first
|
80
|
+
end
|
81
|
+
|
82
|
+
should 'be symbolized' do
|
83
|
+
assert @key.is_a?(Symbol)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
|
+
|
3
|
+
class SupportTest < Test::Unit::TestCase
|
4
|
+
context 'The core extensions' do
|
5
|
+
should 'be able to check for blank' do
|
6
|
+
assert ''.blank?
|
7
|
+
assert nil.blank?
|
8
|
+
end
|
9
|
+
|
10
|
+
context 'for symbol' do
|
11
|
+
setup do
|
12
|
+
@stub = ['HELLO']
|
13
|
+
end
|
14
|
+
|
15
|
+
should 'allow for to_proc on enumerations' do
|
16
|
+
assert_equal @stub.map {|s| s.downcase}, @stub.map(&:downcase)
|
17
|
+
assert_equal ['hello'], @stub.map(&:downcase)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'for hash' do
|
22
|
+
setup do
|
23
|
+
@hash_s = {'hello' => 'world'}
|
24
|
+
@hash_sym = {:hello => 'world'}
|
25
|
+
end
|
26
|
+
|
27
|
+
should 'be able to symbolize keys' do
|
28
|
+
assert_equal @hash_sym, @hash_s.symbolize_keys
|
29
|
+
symbolized = @hash_s.symbolize_keys!
|
30
|
+
assert_equal @hash_sym, symbolized
|
31
|
+
end
|
32
|
+
|
33
|
+
should 'provide methods for its keys and automatically symbolize them' do
|
34
|
+
assert_equal 'world', @hash_s.hello
|
35
|
+
assert_equal 'world', @hash_sym.hello
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'for array' do
|
40
|
+
setup do
|
41
|
+
@array_no_opts = [1, 2]
|
42
|
+
@array_with_opts = [1, 2, :a => :b]
|
43
|
+
end
|
44
|
+
|
45
|
+
should 'be able to extract options' do
|
46
|
+
assert_equal({}, @array_no_opts.extract_options!)
|
47
|
+
assert_equal({:a => :b}, @array_with_opts.extract_options!)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aurb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gigamo
|
@@ -9,8 +9,8 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
13
|
-
default_executable:
|
12
|
+
date: 2010-01-23 00:00:00 +01:00
|
13
|
+
default_executable: aurb
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: yajl-ruby
|
@@ -22,6 +22,26 @@ dependencies:
|
|
22
22
|
- !ruby/object:Gem::Version
|
23
23
|
version: "0"
|
24
24
|
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: ansi
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: archive-tar-minitar
|
37
|
+
type: :runtime
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: "0"
|
44
|
+
version:
|
25
45
|
- !ruby/object:Gem::Dependency
|
26
46
|
name: facets
|
27
47
|
type: :runtime
|
@@ -32,30 +52,44 @@ dependencies:
|
|
32
52
|
- !ruby/object:Gem::Version
|
33
53
|
version: "0"
|
34
54
|
version:
|
35
|
-
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: shoulda
|
57
|
+
type: :development
|
58
|
+
version_requirement:
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: "0"
|
64
|
+
version:
|
65
|
+
description:
|
36
66
|
email: gigamo@gmail.com
|
37
67
|
executables:
|
38
68
|
- aurb
|
39
69
|
extensions: []
|
40
70
|
|
41
|
-
extra_rdoc_files:
|
42
|
-
|
71
|
+
extra_rdoc_files:
|
72
|
+
- LICENSE
|
73
|
+
- README.md
|
43
74
|
files:
|
75
|
+
- .gitignore
|
76
|
+
- LICENSE
|
77
|
+
- README.md
|
44
78
|
- bin/aurb
|
45
|
-
- aurb.
|
46
|
-
-
|
79
|
+
- lib/aurb.rb
|
80
|
+
- lib/aurb/aur.rb
|
81
|
+
- lib/aurb/support.rb
|
82
|
+
- lib/aurb/version.rb
|
83
|
+
- test/test_helper.rb
|
84
|
+
- test/unit/test_aur.rb
|
85
|
+
- test/unit/test_support.rb
|
47
86
|
has_rdoc: true
|
48
87
|
homepage: http://github.com/gigamo/aurb
|
49
88
|
licenses: []
|
50
89
|
|
51
90
|
post_install_message:
|
52
91
|
rdoc_options:
|
53
|
-
- --
|
54
|
-
- --inline-source
|
55
|
-
- --title
|
56
|
-
- Aurb
|
57
|
-
- --main
|
58
|
-
- README.rdoc
|
92
|
+
- --charset=UTF-8
|
59
93
|
require_paths:
|
60
94
|
- lib
|
61
95
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -72,10 +106,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
72
106
|
version:
|
73
107
|
requirements: []
|
74
108
|
|
75
|
-
rubyforge_project:
|
109
|
+
rubyforge_project:
|
76
110
|
rubygems_version: 1.3.5
|
77
111
|
signing_key:
|
78
112
|
specification_version: 3
|
79
|
-
summary: An AUR (Arch User Repository)
|
80
|
-
test_files:
|
81
|
-
|
113
|
+
summary: An AUR (Arch User Repository) utility
|
114
|
+
test_files:
|
115
|
+
- test/unit/test_aur.rb
|
116
|
+
- test/unit/test_support.rb
|
117
|
+
- test/test_helper.rb
|
data/README.rdoc
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
== Usage
|
2
|
-
|
3
|
-
See <tt>aurb --help</tt> for a full list of commands.
|
4
|
-
|
5
|
-
=== Quick Overview
|
6
|
-
|
7
|
-
Required options:
|
8
|
-
|
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
|
-
|
13
|
-
Optional options:
|
14
|
-
|
15
|
-
<tt>--no-color</tt>:: Suppress colored output
|
16
|
-
<tt>--path</tt>:: Override the default save path (defined as DlPath)
|
17
|
-
|
18
|
-
Other:
|
19
|
-
|
20
|
-
<tt>--version</tt>:: Print version and exit
|
21
|
-
|
22
|
-
== Installation
|
23
|
-
|
24
|
-
Quick and dirty:
|
25
|
-
|
26
|
-
# ruby setup.rb all
|
27
|
-
|
28
|
-
Or you can install it in ~/bin:
|
29
|
-
|
30
|
-
% ruby setup.rb config --bindir=$HOME/bin
|
31
|
-
% ruby setup.rb install
|
32
|
-
|
33
|
-
For more information about setup.rb, see <tt>ruby setup.rb --help</tt>.
|
34
|
-
|
35
|
-
There is also a ruby gemspec available.
|
36
|
-
|
37
|
-
=== Dependencies
|
38
|
-
|
39
|
-
Aurb requires the 'facets' and 'yajl-ruby' rubygems to be installed.
|
40
|
-
|
41
|
-
Facets for:
|
42
|
-
|
43
|
-
* Checking version numbers
|
44
|
-
* Coloring text
|
45
|
-
* Untarring
|
46
|
-
|
47
|
-
Yajl for:
|
48
|
-
|
49
|
-
* Parsing the AUR
|
50
|
-
|
51
|
-
== Todo
|
52
|
-
|
53
|
-
* Automatically build (and install) the package after download?
|
54
|
-
* Add dependency checking/downloading?
|
data/aurb.gemspec
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
# aurb.gemspec
|
2
|
-
|
3
|
-
Gem::Specification.new do |s|
|
4
|
-
s.name = 'aurb'
|
5
|
-
s.version = '0.9.3'
|
6
|
-
s.date = %q{2009-12-02}
|
7
|
-
s.summary = %q{An AUR (Arch User Repository) script}
|
8
|
-
s.email = %q{gigamo@gmail.com}
|
9
|
-
s.homepage = %q{http://github.com/gigamo/aurb}
|
10
|
-
s.description = s.summary
|
11
|
-
s.rubyforge_project = %q{aurb}
|
12
|
-
s.executables = ['aurb']
|
13
|
-
s.has_rdoc = true
|
14
|
-
s.rdoc_options = ['--line-numbers', '--inline-source', '--title', 'Aurb', '--main', 'README.rdoc']
|
15
|
-
s.authors = ['Gigamo']
|
16
|
-
s.files = ['bin/aurb', 'aurb.gemspec', 'README.rdoc']
|
17
|
-
s.add_dependency 'yajl-ruby'
|
18
|
-
s.add_dependency 'facets'
|
19
|
-
end
|