debsfromrepos 0.1.2 → 0.1.3
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.
- data/README.rdoc +16 -5
- data/examples/repo2json.rb +2 -1
- data/lib/debsfromrepos/list_url.rb +17 -3
- data/lib/debsfromrepos/packages.rb +13 -7
- data/lib/debsfromrepos_version.rb +1 -1
- metadata +13 -51
data/README.rdoc
CHANGED
@@ -5,6 +5,8 @@
|
|
5
5
|
This is a small lib to get the names and descriptions for the availables
|
6
6
|
packages at specific (or group of them) Debian/Ubuntu repository.
|
7
7
|
|
8
|
+
The description can be obtained in a specific language.
|
9
|
+
|
8
10
|
== Installation
|
9
11
|
|
10
12
|
|
@@ -26,21 +28,30 @@ and ask for the right <tt>Packages.gz</tt> url for a specific Debian/Ubuntu serv
|
|
26
28
|
server = "http://us.archive.ubuntu.com/ubuntu"
|
27
29
|
suite = "oneiric"
|
28
30
|
component = "main"
|
29
|
-
|
30
|
-
repository.
|
31
|
+
language = "es"
|
32
|
+
repository = DebsFromRepos::ListUrl.new(server, suite, component, language)
|
33
|
+
packages_url = repository.get_packages_url
|
31
34
|
# => "http://us.archive.ubuntu.com/ubuntu/dists/oneiric/main/binary-i386/Packages.gz"
|
35
|
+
translations_url = repository.get_translations_url
|
36
|
+
# => "http://us.archive.ubuntu.com/ubuntu/dists/oneiric/main/i18n/Translation-es.gz"
|
32
37
|
|
33
38
|
you also can change the <tt>suite</tt> or <tt>component</tt>
|
34
39
|
|
35
40
|
repository.component = 'universe'
|
36
41
|
# => "http://us.archive.ubuntu.com/ubuntu/dists/oneiric/universe/binary-i386/Packages.gz"
|
37
42
|
|
43
|
+
or ask for another <tt>language</tt>
|
44
|
+
|
45
|
+
repository.get_translations_url('it')
|
46
|
+
# => "http://us.archive.ubuntu.com/ubuntu/dists/oneiric/main/i18n/Translation-it.gz"
|
47
|
+
|
48
|
+
|
38
49
|
and then get all the packages' names and descriptions on that component of
|
39
50
|
that suite of that repository:
|
40
51
|
|
41
|
-
pkgs = DebsFromRepos::Packages.new(
|
42
|
-
pkgs.packages['
|
43
|
-
# => "
|
52
|
+
pkgs = DebsFromRepos::Packages.new(packages_url, translations_url)
|
53
|
+
pkgs.packages['zlib1g']
|
54
|
+
# => "Biblioteca de compresión, ejecutables"
|
44
55
|
|
45
56
|
== Tests
|
46
57
|
|
data/examples/repo2json.rb
CHANGED
@@ -25,7 +25,8 @@ sources_lists.each_pair do |server,suites|
|
|
25
25
|
components.each_pair do |component,pkgs|
|
26
26
|
packages[server][suite][component] = {}
|
27
27
|
repo = DebsFromRepos::ListUrl.new(server,suite,component)
|
28
|
-
|
28
|
+
pkgs_url, translations_url = repo.get_packages_url, repo.get_translations_url('es')
|
29
|
+
pkgs = DebsFromRepos::Packages.new(pkgs_url, translations_url)
|
29
30
|
packages[server][suite][component] = pkgs.packages
|
30
31
|
end
|
31
32
|
end
|
@@ -1,15 +1,16 @@
|
|
1
1
|
module DebsFromRepos
|
2
2
|
class ListUrl
|
3
3
|
|
4
|
-
attr_accessor :suite, :component
|
4
|
+
attr_accessor :suite, :component, :lang
|
5
5
|
|
6
|
-
def initialize(url, suite='', component='')
|
6
|
+
def initialize(url, suite='', component='', lang=nil)
|
7
7
|
@url = url
|
8
8
|
@suite = suite
|
9
9
|
@component = component
|
10
|
+
@lang = lang
|
10
11
|
end
|
11
12
|
|
12
|
-
def
|
13
|
+
def get_packages_url
|
13
14
|
if @suite.empty?
|
14
15
|
$stderr.puts "ERROR: the suite was missing"
|
15
16
|
return nil
|
@@ -23,5 +24,18 @@ module DebsFromRepos
|
|
23
24
|
end
|
24
25
|
"#{@url}/dists/#{@suite}/#{@component}/binary-i386/Packages.gz"
|
25
26
|
end
|
27
|
+
|
28
|
+
def get_translations_url(lang=nil)
|
29
|
+
@lang = lang ? lang : @lang
|
30
|
+
unless @lang
|
31
|
+
$stderr.puts "ERROR: no language has been selected"
|
32
|
+
return nil
|
33
|
+
end
|
34
|
+
unless @lang.match(/^[a-z][a-z]$/)
|
35
|
+
$stderr.puts "ERROR: the language is wrong"
|
36
|
+
return nil
|
37
|
+
end
|
38
|
+
"#{@url}/dists/#{@suite}/#{@component}/i18n/Translation-#{@lang}.gz"
|
39
|
+
end
|
26
40
|
end
|
27
41
|
end
|
@@ -6,16 +6,22 @@ module DebsFromRepos
|
|
6
6
|
|
7
7
|
attr_reader :packages
|
8
8
|
|
9
|
-
def initialize(
|
10
|
-
|
11
|
-
|
9
|
+
def initialize(packages_url, translations_url=nil)
|
10
|
+
get_packages(packages_url)
|
11
|
+
if translations_url
|
12
|
+
lang_match = translations_url.match(/Translation-([a-z][a-z]).gz/)
|
13
|
+
if lang_match
|
14
|
+
lang = "-#{lang_match[1]}"
|
15
|
+
get_packages(translations_url, lang)
|
16
|
+
end
|
17
|
+
end
|
12
18
|
end
|
13
19
|
|
14
20
|
private
|
15
|
-
def get_packages
|
16
|
-
@packages
|
21
|
+
def get_packages(url, lang="")
|
22
|
+
@packages ||= Hash.new
|
17
23
|
begin
|
18
|
-
zip_file = Zlib::GzipReader.new(open(
|
24
|
+
zip_file = Zlib::GzipReader.new(open(url))
|
19
25
|
packages_lines = zip_file.readlines("\n\n")
|
20
26
|
rescue Exception => e
|
21
27
|
packages_lines = []
|
@@ -25,7 +31,7 @@ module DebsFromRepos
|
|
25
31
|
next unless name_match
|
26
32
|
name = name_match[1]
|
27
33
|
description = ''
|
28
|
-
description_match = line.match(/Description:\s(.+)\n/)
|
34
|
+
description_match = line.match(/Description#{lang}:\s(.+)\n/)
|
29
35
|
description = description_match[1] if description_match
|
30
36
|
@packages[name] = description
|
31
37
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: debsfromrepos
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,62 +10,25 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
date: 2012-01-07 00:00:00.000000000 Z
|
13
|
-
dependencies:
|
14
|
-
- !ruby/object:Gem::Dependency
|
15
|
-
name: rake
|
16
|
-
requirement: &82973890 !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ! '>='
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: '0'
|
22
|
-
type: :development
|
23
|
-
prerelease: false
|
24
|
-
version_requirements: *82973890
|
25
|
-
- !ruby/object:Gem::Dependency
|
26
|
-
name: cucumber
|
27
|
-
requirement: &82973680 !ruby/object:Gem::Requirement
|
28
|
-
none: false
|
29
|
-
requirements:
|
30
|
-
- - ! '>='
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: '0'
|
33
|
-
type: :development
|
34
|
-
prerelease: false
|
35
|
-
version_requirements: *82973680
|
36
|
-
- !ruby/object:Gem::Dependency
|
37
|
-
name: json
|
38
|
-
requirement: &82973470 !ruby/object:Gem::Requirement
|
39
|
-
none: false
|
40
|
-
requirements:
|
41
|
-
- - ! '>='
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: '0'
|
44
|
-
type: :development
|
45
|
-
prerelease: false
|
46
|
-
version_requirements: *82973470
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: rdoc
|
49
|
-
requirement: &82973260 !ruby/object:Gem::Requirement
|
50
|
-
none: false
|
51
|
-
requirements:
|
52
|
-
- - ! '>='
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
type: :development
|
56
|
-
prerelease: false
|
57
|
-
version_requirements: *82973260
|
13
|
+
dependencies: []
|
58
14
|
description: ! "\n\n== Description\n\nThis is a small lib to get the names and descriptions
|
59
15
|
for the availables\npackages at specific (or group of them) Debian/Ubuntu repository.\n\n==
|
60
16
|
Usage\n\nYou have a example of how the library works at the <tt>examples/</tt> directory:\n\n
|
61
17
|
\ examples/repo2json.rb\n\nBasicaly you require the lib\n\n require 'debsfromrepos'\n\nand
|
62
18
|
ask for the right <tt>Packages.gz</tt> url for a specific Debian/Ubuntu server\n\n
|
63
19
|
\ server = \"http://us.archive.ubuntu.com/ubuntu\"\n suite = \"oneiric\"\n component
|
64
|
-
= \"main\"\n repository = DebsFromRepos::ListUrl.new(server,
|
65
|
-
\ repository.
|
20
|
+
= \"main\"\n language = \"es\"\n repository = DebsFromRepos::ListUrl.new(server,
|
21
|
+
suite, component, language)\n packages_url = repository.get_packages_url\n # =>
|
22
|
+
\"http://us.archive.ubuntu.com/ubuntu/dists/oneiric/main/binary-i386/Packages.gz\"\n
|
23
|
+
\ translations_url = repository.get_translations_url\n # => \"http://us.archive.ubuntu.com/ubuntu/dists/oneiric/main/i18n/Translation-es.gz\"\n\nyou
|
24
|
+
also can change the <tt>suite</tt> or <tt>component</tt>\n\n repository.component
|
25
|
+
= \"universe\"\n # => \"http://us.archive.ubuntu.com/ubuntu/dists/oneiric/universe/binary-i386/Packages.gz\"\n\nor
|
26
|
+
ask for another <tt>language</tt>\n\n repository.get_translations_url(\"it\")\n
|
27
|
+
\ # => \"http://us.archive.ubuntu.com/ubuntu/dists/oneiric/main/i18n/Translation-it.gz\"\n\n\nand
|
66
28
|
then get all the packages' names and descriptions on that component of\nthat suite
|
67
|
-
of that repository:\n\n pkgs = DebsFromRepos::Packages.new(
|
68
|
-
\ # => \"
|
29
|
+
of that repository:\n\n pkgs = DebsFromRepos::Packages.new(packages_url, translations_url)\n
|
30
|
+
\ pkgs.packages[\"zlib1g\"]\n # => \"Biblioteca de compresión, ejecutables\"\n
|
31
|
+
\ "
|
69
32
|
email: jojeda@emergya.com
|
70
33
|
executables: []
|
71
34
|
extensions: []
|
@@ -88,7 +51,6 @@ rdoc_options:
|
|
88
51
|
- debsfromrepos
|
89
52
|
- --main
|
90
53
|
- README.rdoc
|
91
|
-
- --ri
|
92
54
|
require_paths:
|
93
55
|
- lib
|
94
56
|
- lib
|