slapp 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.
- checksums.yaml +4 -4
- data/lib/slapp/package.rb +13 -7
- data/lib/slapp/parser.rb +4 -3
- data/lib/slapp/version.rb +1 -1
- data/spec/parser_spec.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ce9903469327aab318ff50b88cc417d94b4836c
|
4
|
+
data.tar.gz: 94b5b1081d35d9efe684984ba14b3b632cc95b83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64cc07ea988821934c647db33f361de9680b9c7819252f0c582ed28e56bbdcb909a2e7aaeee8756ba3e84db1d45165c2c2b55d882c49df374642c27523bce39a
|
7
|
+
data.tar.gz: 17ea0cc0a07ad04b155a90790521ece188c1b7cd438f4c7c8a398db4f004066a04f5c1c24af836a1f4a7220de54d9255ec2ee223cb68ede5d56819b2083fccf4
|
data/lib/slapp/package.rb
CHANGED
@@ -3,8 +3,9 @@ class Slapp::Package
|
|
3
3
|
|
4
4
|
attr_accessor :data
|
5
5
|
|
6
|
-
def initialize(data)
|
6
|
+
def initialize(data, slackware_version)
|
7
7
|
@data = data
|
8
|
+
@slackware_version = slackware_version
|
8
9
|
|
9
10
|
@name_match = regex('name').match(data)
|
10
11
|
@location_match = regex('location').match(data)
|
@@ -13,19 +14,23 @@ class Slapp::Package
|
|
13
14
|
end
|
14
15
|
|
15
16
|
def name
|
17
|
+
@name_match[3]
|
18
|
+
end
|
19
|
+
|
20
|
+
def package_name
|
16
21
|
@name_match[2]
|
17
22
|
end
|
18
23
|
|
19
|
-
def
|
24
|
+
def file_name
|
20
25
|
@name_match[1]
|
21
26
|
end
|
22
27
|
|
23
28
|
def version
|
24
|
-
@name_match[
|
29
|
+
@name_match[4]
|
25
30
|
end
|
26
31
|
|
27
32
|
def arch
|
28
|
-
@name_match[
|
33
|
+
@name_match[5]
|
29
34
|
end
|
30
35
|
|
31
36
|
def location
|
@@ -33,7 +38,7 @@ class Slapp::Package
|
|
33
38
|
end
|
34
39
|
|
35
40
|
def path
|
36
|
-
File.join location,
|
41
|
+
File.join "/slackware/slackware-#{@slackware_version}", location, file_name
|
37
42
|
end
|
38
43
|
|
39
44
|
def build
|
@@ -76,7 +81,8 @@ class Slapp::Package
|
|
76
81
|
|
77
82
|
def to_hash
|
78
83
|
{
|
79
|
-
|
84
|
+
file_name: file_name,
|
85
|
+
package_name: package_name,
|
80
86
|
name: name,
|
81
87
|
version: version,
|
82
88
|
arch: arch,
|
@@ -105,7 +111,7 @@ private
|
|
105
111
|
|
106
112
|
def regexes
|
107
113
|
{
|
108
|
-
name: /PACKAGE NAME:\s+((.+)-(.+)-(.+)-(.+)\.t\wz)/,
|
114
|
+
name: /PACKAGE NAME:\s+(((.+)-(.+)-(.+)-(.+))\.t\wz)/,
|
109
115
|
location: /PACKAGE LOCATION:\s+\.([\S]+)/,
|
110
116
|
size: /PACKAGE SIZE\s+\(\w+\):\s+(.+)/,
|
111
117
|
description: /PACKAGE DESCRIPTION:\s+(.+)/m
|
data/lib/slapp/parser.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
class Slapp::Parser
|
2
2
|
include Slapp::Helpers
|
3
3
|
|
4
|
-
attr_accessor :lines, :contents
|
4
|
+
attr_accessor :lines, :contents, :slackware_version
|
5
5
|
|
6
|
-
def initialize(path)
|
6
|
+
def initialize(path, slackware_version)
|
7
7
|
@lines = File.readlines(path, :encoding => 'ISO-8859-1')
|
8
8
|
@contents = @lines.join('')
|
9
|
+
@slackware_version = slackware_version
|
9
10
|
end
|
10
11
|
|
11
12
|
def total_size_uncompressed
|
@@ -22,7 +23,7 @@ class Slapp::Parser
|
|
22
23
|
|
23
24
|
def packages
|
24
25
|
raw_packages.map { |pkg|
|
25
|
-
package = Slapp::Package.new pkg.first
|
26
|
+
package = Slapp::Package.new pkg.first, slackware_version
|
26
27
|
package.to_hash
|
27
28
|
}
|
28
29
|
end
|
data/lib/slapp/version.rb
CHANGED
data/spec/parser_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require 'slapp/parser'
|
|
2
2
|
|
3
3
|
describe Slapp::Parser do
|
4
4
|
before do
|
5
|
-
@parser = Slapp::Parser.new('spec/support/13.37/slackware/PACKAGES.TXT')
|
5
|
+
@parser = Slapp::Parser.new('spec/support/13.37/slackware/PACKAGES.TXT', '13.37')
|
6
6
|
end
|
7
7
|
|
8
8
|
it "parses the total size (uncompressed)" do
|
@@ -25,7 +25,7 @@ describe Slapp::Parser do
|
|
25
25
|
end
|
26
26
|
|
27
27
|
it "parses the filename" do
|
28
|
-
@package[:
|
28
|
+
@package[:file_name].should == 'ConsoleKit-0.4.3-i486-1.txz'
|
29
29
|
end
|
30
30
|
|
31
31
|
it "parses the name" do
|
@@ -41,7 +41,7 @@ describe Slapp::Parser do
|
|
41
41
|
end
|
42
42
|
|
43
43
|
it "parses the path" do
|
44
|
-
@package[:path].should == '/slackware/l/ConsoleKit-0.4.3-i486-1.txz'
|
44
|
+
@package[:path].should == '/slackware/slackware-13.37/slackware/l/ConsoleKit-0.4.3-i486-1.txz'
|
45
45
|
end
|
46
46
|
|
47
47
|
it "parses the size" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slapp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nic Aitch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|