aurb 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/VERSION +1 -1
- data/aurb.gemspec +7 -3
- data/lib/aurb.rb +2 -4
- data/lib/aurb/aur.rb +15 -26
- data/lib/aurb/cli.rb +15 -5
- data/lib/aurb/core_ext.rb +5 -0
- data/lib/aurb/core_ext/hash.rb +28 -0
- data/lib/aurb/core_ext/object.rb +15 -0
- data/lib/aurb/core_ext/string.rb +23 -0
- data/lib/aurb/version.rb +3 -0
- data/test/unit/test_aur.rb +3 -3
- metadata +7 -3
- data/lib/aurb/support.rb +0 -46
data/.gitignore
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.2.
|
1
|
+
1.2.1
|
data/aurb.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{aurb}
|
8
|
-
s.version = "1.2.
|
8
|
+
s.version = "1.2.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Gigamo"]
|
12
|
-
s.date = %q{2010-03-
|
12
|
+
s.date = %q{2010-03-05}
|
13
13
|
s.default_executable = %q{aurb}
|
14
14
|
s.email = %q{gigamo@gmail.com}
|
15
15
|
s.executables = ["aurb"]
|
@@ -28,7 +28,11 @@ Gem::Specification.new do |s|
|
|
28
28
|
"lib/aurb.rb",
|
29
29
|
"lib/aurb/aur.rb",
|
30
30
|
"lib/aurb/cli.rb",
|
31
|
-
"lib/aurb/
|
31
|
+
"lib/aurb/core_ext.rb",
|
32
|
+
"lib/aurb/core_ext/hash.rb",
|
33
|
+
"lib/aurb/core_ext/object.rb",
|
34
|
+
"lib/aurb/core_ext/string.rb",
|
35
|
+
"lib/aurb/version.rb",
|
32
36
|
"test/test_helper.rb",
|
33
37
|
"test/unit/test_aur.rb",
|
34
38
|
"test/unit/test_support.rb"
|
data/lib/aurb.rb
CHANGED
@@ -12,8 +12,6 @@ require 'ansi'
|
|
12
12
|
require 'archive/tar/minitar'
|
13
13
|
|
14
14
|
module Aurb #:nodoc:
|
15
|
-
VERSION = '1.2.0'
|
16
|
-
|
17
15
|
autoload :Aur, 'aurb/aur'
|
18
16
|
|
19
17
|
class AurbError < StandardError
|
@@ -35,7 +33,7 @@ module Aurb #:nodoc:
|
|
35
33
|
@logger ||= Logger.new(STDOUT)
|
36
34
|
end
|
37
35
|
|
38
|
-
def
|
36
|
+
def aur_rpc_path(type, arg)
|
39
37
|
"http://aur.archlinux.org/rpc.php?type=#{type}&arg=#{arg}"
|
40
38
|
end
|
41
39
|
|
@@ -49,4 +47,4 @@ module Aurb #:nodoc:
|
|
49
47
|
end
|
50
48
|
end
|
51
49
|
|
52
|
-
require 'aurb/
|
50
|
+
require 'aurb/core_ext'
|
data/lib/aurb/aur.rb
CHANGED
@@ -42,7 +42,7 @@ module Aurb
|
|
42
42
|
packages.map do |package|
|
43
43
|
Aurb.aur_download_path URI.escape(package.to_s)
|
44
44
|
end.select do |package|
|
45
|
-
|
45
|
+
!!(open package rescue false)
|
46
46
|
end.delete_if(&:blank?)
|
47
47
|
end
|
48
48
|
|
@@ -51,53 +51,42 @@ module Aurb
|
|
51
51
|
# the +download+ method.
|
52
52
|
#
|
53
53
|
# # With Aurb on the AUR as version 1.1.2-1
|
54
|
-
# upgrade(
|
55
|
-
def upgrade(list)
|
54
|
+
# upgrade('aurb 0.0.0-0', 'aurb 0.9.9-9') # => [:aurb]
|
55
|
+
def upgrade(*list)
|
56
|
+
upgradables = []
|
56
57
|
list.inject([]) do |ary, line|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
58
|
+
ary << Thread.new do
|
59
|
+
name, version = line.split
|
60
|
+
next if Dir["/var/lib/pacman/sync/community/#{name}-#{version}"].any?
|
61
|
+
upgradables << name.to_sym if upgradable?(name, version)
|
62
|
+
end
|
63
|
+
end.each(&:join)
|
64
|
+
upgradables
|
62
65
|
end
|
63
66
|
|
64
67
|
protected
|
65
68
|
|
66
|
-
# See if +package+ is available in the community repository.
|
67
|
-
def in_community?(package)
|
68
|
-
Dir["/var/lib/pacman/sync/community/#{package}-*"].any?
|
69
|
-
end
|
70
|
-
|
71
|
-
# Check if +package+ is available for download.
|
72
|
-
def downloadable?(package)
|
73
|
-
open package rescue false
|
74
|
-
end
|
75
|
-
|
76
69
|
# Compare version of local +package+ with the one on the AUR.
|
77
70
|
def upgradable?(package, version)
|
78
71
|
local_version = Version.new(version)
|
79
72
|
remote_version = nil
|
80
|
-
|
81
|
-
parse_json Aurb.aur_path(:info, package.to_s) do |json|
|
73
|
+
parse_json Aurb.aur_rpc_path(:info, package.to_s) do |json|
|
82
74
|
return if json.type =~ /error/
|
83
75
|
remote_version = Version.new(json.results.Version)
|
84
76
|
end
|
85
|
-
|
86
77
|
remote_version && local_version < remote_version
|
87
78
|
end
|
88
79
|
|
89
80
|
# Returns an array containing a hash of search results
|
90
81
|
# for a given +package+.
|
91
82
|
def list_search_results(package)
|
92
|
-
json = parse_json(Aurb.
|
83
|
+
json = parse_json(Aurb.aur_rpc_path(:search, URI.escape(package.to_s)))
|
93
84
|
return [] if json.type =~ /error/
|
94
|
-
|
95
85
|
ids = json.results.map(&:ID)
|
96
86
|
ids.inject([]) do |ary, id|
|
97
|
-
parse_json Aurb.
|
87
|
+
parse_json Aurb.aur_rpc_path(:info, id) do |json|
|
98
88
|
next if json.type =~ /error/
|
99
|
-
|
100
|
-
ary << result unless in_community?(result.Name)
|
89
|
+
ary << json.results.symbolize_keys
|
101
90
|
end
|
102
91
|
ary
|
103
92
|
end
|
data/lib/aurb/cli.rb
CHANGED
@@ -1,16 +1,18 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# encoding: utf-8
|
3
3
|
|
4
|
+
$LOAD_PATH.unshift File.dirname(__FILE__) + '/..'
|
4
5
|
require 'thor'
|
5
|
-
require
|
6
|
+
require 'aurb'
|
6
7
|
|
7
8
|
module Aurb
|
8
9
|
class CLI < Thor
|
9
10
|
ARGV = ::ARGV.dup
|
10
11
|
|
11
|
-
map
|
12
|
-
|
13
|
-
|
12
|
+
map %w[-d --download] => :download,
|
13
|
+
%w[-s --search] => :search,
|
14
|
+
%w[-u --upgrade] => :upgrade,
|
15
|
+
%w[-v --version] => :version
|
14
16
|
|
15
17
|
desc 'download PACKAGES', 'Download packages'
|
16
18
|
method_option :path,
|
@@ -61,11 +63,19 @@ module Aurb
|
|
61
63
|
desc 'upgrade', 'Search for upgrades to installed packages'
|
62
64
|
def upgrade
|
63
65
|
list = `pacman -Qm`.split(/\n/)
|
64
|
-
pkgs = Aurb.aur.upgrade(list)
|
66
|
+
pkgs = Aurb.aur.upgrade(*list)
|
65
67
|
puts 'Nothing to upgrade'.colorize(:red) and return if pkgs.blank?
|
66
68
|
pkgs.each do |package|
|
67
69
|
puts "#{package.to_s.colorize(:yellow)} has an upgrade available"
|
68
70
|
end
|
69
71
|
end
|
72
|
+
|
73
|
+
desc 'version', 'Show version and exit'
|
74
|
+
def version
|
75
|
+
require 'aurb/version'
|
76
|
+
require 'thor/version'
|
77
|
+
puts "Aurb v#{Aurb::VERSION} - Thor v#{Thor::VERSION}"
|
78
|
+
puts 'Copyright (c) 2009-2010 Gigamo <gigamo@gmail.com>'
|
79
|
+
end
|
70
80
|
end
|
71
81
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
module Aurb
|
5
|
+
module CoreExt
|
6
|
+
module Hash
|
7
|
+
# Returns a new hash with all keys converted to symbols.
|
8
|
+
def symbolize_keys
|
9
|
+
inject({}) do |options, (key, value)|
|
10
|
+
options[(key.to_sym rescue key) || key] = value
|
11
|
+
options
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# Destructively converts all keys to symbols.
|
16
|
+
def symbolize_keys!
|
17
|
+
self.replace(self.symbolize_keys)
|
18
|
+
end
|
19
|
+
|
20
|
+
# Delegation
|
21
|
+
def method_missing(key)
|
22
|
+
self.symbolize_keys[key.to_sym]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
Hash.send :include, Aurb::CoreExt::Hash
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
module Aurb
|
5
|
+
module CoreExt
|
6
|
+
module 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
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
Object.send :include, Aurb::CoreExt::Object
|
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
module Aurb
|
5
|
+
module CoreExt
|
6
|
+
module String
|
7
|
+
# Colors a string with +color+.
|
8
|
+
# Uses the ANSICode library provided by +facets+.
|
9
|
+
#
|
10
|
+
# "Hello".colorize(:blue) # => "\e[34mHello\e[0m"
|
11
|
+
#
|
12
|
+
# For more information on available effects, see
|
13
|
+
# http://facets.rubyforge.org/apidoc/api/more/classes/ANSICode.html
|
14
|
+
def colorize(effect)
|
15
|
+
ANSI::Code.send(effect.to_sym) << self << ANSI::Code.clear
|
16
|
+
rescue
|
17
|
+
self
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
String.send :include, Aurb::CoreExt::String
|
data/lib/aurb/version.rb
ADDED
data/test/unit/test_aur.rb
CHANGED
@@ -26,12 +26,12 @@ class AurTest < Test::Unit::TestCase
|
|
26
26
|
end
|
27
27
|
|
28
28
|
should 'return an array' do
|
29
|
-
assert_operator Array, :===, Aurb.aur.upgrade(
|
29
|
+
assert_operator Array, :===, Aurb.aur.upgrade(*@list)
|
30
30
|
end
|
31
31
|
|
32
32
|
should 'contain only upgradable packages' do
|
33
|
-
assert_not_equal [:aurb, :aurb], Aurb.aur.upgrade(
|
34
|
-
assert_equal [:aurb], Aurb.aur.upgrade(
|
33
|
+
assert_not_equal [:aurb, :aurb], Aurb.aur.upgrade(*@list)
|
34
|
+
assert_equal [:aurb], Aurb.aur.upgrade(*@list)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
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: 1.2.
|
4
|
+
version: 1.2.1
|
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: 2010-03-
|
12
|
+
date: 2010-03-05 00:00:00 +01:00
|
13
13
|
default_executable: aurb
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -82,7 +82,11 @@ files:
|
|
82
82
|
- lib/aurb.rb
|
83
83
|
- lib/aurb/aur.rb
|
84
84
|
- lib/aurb/cli.rb
|
85
|
-
- lib/aurb/
|
85
|
+
- lib/aurb/core_ext.rb
|
86
|
+
- lib/aurb/core_ext/hash.rb
|
87
|
+
- lib/aurb/core_ext/object.rb
|
88
|
+
- lib/aurb/core_ext/string.rb
|
89
|
+
- lib/aurb/version.rb
|
86
90
|
- test/test_helper.rb
|
87
91
|
- test/unit/test_aur.rb
|
88
92
|
- test/unit/test_support.rb
|
data/lib/aurb/support.rb
DELETED
@@ -1,46 +0,0 @@
|
|
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 Hash
|
14
|
-
# Returns a new hash with all keys converted to symbols.
|
15
|
-
def symbolize_keys
|
16
|
-
inject({}) do |options, (key, value)|
|
17
|
-
options[(key.to_sym rescue key) || key] = value
|
18
|
-
options
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
# Destructively converts all keys to symbols.
|
23
|
-
def symbolize_keys!
|
24
|
-
self.replace(self.symbolize_keys)
|
25
|
-
end
|
26
|
-
|
27
|
-
# Delegation
|
28
|
-
def method_missing(key)
|
29
|
-
self.symbolize_keys[key.to_sym]
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
class String
|
34
|
-
# Colors a string with +color+.
|
35
|
-
# Uses the ANSICode library provided by +facets+.
|
36
|
-
#
|
37
|
-
# "Hello".colorize(:blue) # => "\e[34mHello\e[0m"
|
38
|
-
#
|
39
|
-
# For more information on available effects, see
|
40
|
-
# http://facets.rubyforge.org/apidoc/api/more/classes/ANSICode.html
|
41
|
-
def colorize(effect)
|
42
|
-
ANSI::Code.send(effect.to_sym) << self << ANSI::Code.clear
|
43
|
-
rescue
|
44
|
-
self
|
45
|
-
end
|
46
|
-
end
|