slack-utils 0.7.3 → 0.7.4

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/bin/slf CHANGED
@@ -55,7 +55,7 @@ elsif (ARGV.count == 0)
55
55
  end
56
56
 
57
57
  begin
58
- print_package_searched_files(build_packages(options, []), ARGV)
58
+ print_package_searched_files(ARGV)
59
59
  rescue Interrupt
60
60
  exit 0
61
61
  rescue Exception => e
@@ -37,7 +37,8 @@ module Slackware
37
37
 
38
38
  FMT_UPGRADE_TIME = "%F %H:%M:%S"
39
39
 
40
- attr_accessor :time, :path, :file, :name, :version, :arch, :build, :tag, :tag_sep, :upgrade_time, :owned_files
40
+ attr_accessor :path, :file, :name, :version, :arch, :build, :tag, :tag_sep, :upgrade_time
41
+ #attr_accessor :time, :owned_files
41
42
  def initialize(name = nil)
42
43
  self.name = name
43
44
  end
@@ -89,19 +90,17 @@ module Slackware
89
90
 
90
91
  # Accessor for the PACKAGE DESCRIPTION from the package file
91
92
  def package_description
92
- if not(@package_description.nil?)
93
- return @package_description
94
- end
93
+ return @package_description unless @package_description.nil?
95
94
 
96
- f = File.open(self.path + '/' + self.fullname)
97
- while true
95
+ f = File.open(path() + '/' + self.fullname)
96
+ loop do
98
97
  if (f.readline =~ RE_PACKAGE_DESCRIPTION)
99
- desc = f.take_while {|l|
100
- not(l =~ RE_FILE_LIST)
101
- }.map {|l|
102
- l.sub(/^#{self.name}:\s?/, '').chomp
103
- }
104
- return desc
98
+ @package_description = f.take_while {|l|
99
+ not(l =~ RE_FILE_LIST)
100
+ }.map {|l|
101
+ l.sub(/^#{self.name}:\s?/, '').chomp
102
+ }
103
+ return @package_description
105
104
  end
106
105
  end
107
106
  end
@@ -113,14 +112,12 @@ module Slackware
113
112
 
114
113
  # Accessor for the PACKAGE LOCATION from the package file
115
114
  def package_location
116
- if not(@package_location.nil?)
117
- return @package_location
118
- end
115
+ return @package_location unless @package_location.nil?
119
116
 
120
117
  f = File.open(self.path + '/' + self.fullname)
121
- while true
118
+ loop do
122
119
  if (f.readline =~ RE_PACKAGE_LOCATION)
123
- return $1
120
+ return @package_location = $1
124
121
  end
125
122
  end
126
123
  end
@@ -132,14 +129,12 @@ module Slackware
132
129
 
133
130
  # Accessor for the UNCOMPRESSED PACKAGE SIZE from the package file
134
131
  def uncompressed_size
135
- if not(@uncompressed_size.nil?)
136
- return @uncompressed_size
137
- end
132
+ return @uncompressed_size unless @uncompressed_size.nil?
138
133
 
139
134
  f = File.open(self.path + '/' + self.fullname)
140
- while true
135
+ loop do
141
136
  if (f.readline =~ RE_UNCOMPRESSED_PACKAGE_SIZE)
142
- return $1
137
+ return @uncompressed_size = $1
143
138
  end
144
139
  end
145
140
  end
@@ -151,14 +146,12 @@ module Slackware
151
146
 
152
147
  # Accessor for the COMPRESSED PACKAGE SIZE from the package file
153
148
  def compressed_size
154
- if not(@compressed_size.nil?)
155
- return @compressed_size
156
- end
149
+ return @compressed_size unless @compressed_size.nil?
157
150
 
158
151
  f = File.open(self.path + '/' + self.fullname)
159
- while true
152
+ loop do
160
153
  if (f.readline =~ RE_COMPRESSED_PACKAGE_SIZE)
161
- return $1
154
+ return @compressed_size = $1
162
155
  end
163
156
  end
164
157
  end
@@ -168,70 +161,75 @@ module Slackware
168
161
  @compressed_size = size
169
162
  end
170
163
 
164
+ # Set the file list in the package object in memory
165
+ def owned_files
166
+ @owned_files ||= _owned_files()
167
+ end
168
+
171
169
  # Accessor for the FILE LIST from the package file
172
170
  # unless the :owned_files symbol is populated
173
- def get_owned_files
174
- unless self.owned_files.nil?
175
- return self.owned_files
176
- else
177
- files = []
178
- File.open(self.path + '/' + self.fullname) do |f|
179
- while true
180
- break if f.eof?
181
- line = f.readline()
182
- begin
183
- if line.force_encoding("US-ASCII") =~ RE_FILE_LIST
184
- f.seek(2, IO::SEEK_CUR)
185
- break
186
- end
187
- rescue ArgumentError
188
- # ArgumentError: invalid byte sequence in US-ASCII
189
- # so dumb, i wish i could determine a better solution for this
190
- true
171
+ def _owned_files
172
+ files = []
173
+ File.open(self.path + '/' + self.fullname) do |f|
174
+ loop do
175
+ break if f.eof?
176
+ line = f.readline()
177
+ begin
178
+ if line.force_encoding("US-ASCII") =~ RE_FILE_LIST
179
+ f.seek(2, IO::SEEK_CUR)
180
+ break
191
181
  end
192
- end
193
- begin
194
- files = f.readlines().map {|line| line.rstrip.force_encoding("US-ASCII") }
195
182
  rescue ArgumentError
196
- Log.instance.debug("Slackware::Package") {
197
- "encoding in : " + self.path + '/' + self.fullname
198
- }
183
+ # ArgumentError: invalid byte sequence in US-ASCII
184
+ # so dumb, i wish i could determine a better solution for this
185
+ true
199
186
  end
200
187
  end
201
- return files
202
- end
203
- end
204
-
205
- # Set the file list in the package object in memory
206
- def set_owned_files
207
- if self.owned_files.nil?
208
- self.owned_files = get_owned_files()
209
- return true
210
- else
211
- return false
188
+ begin
189
+ files = f.readlines().map {|line| line.rstrip.force_encoding("US-ASCII") }
190
+ rescue ArgumentError
191
+ Log.instance.debug("Slackware::Package") {
192
+ "encoding in : " + self.path + '/' + self.fullname
193
+ }
194
+ end
212
195
  end
196
+ return files
213
197
  end
214
198
 
215
199
  # populates and returns self.time
216
- def get_time
217
- if (self.time.nil? && self.path)
200
+ def time
201
+ if (@time.nil? && self.path)
218
202
  if (File.exist?(self.path + "/" + self.fullname))
219
- self.time = File.mtime(self.path + "/" + self.fullname)
203
+ @time = File.mtime(self.path + "/" + self.fullname)
220
204
  end
221
- elsif (not(self.path) && (self.time.nil?))
205
+ elsif (not(self.path) && (@time.nil?))
222
206
  if (File.exist?(Paths::installed_packages() + "/" + self.fullname))
223
- self.time = File.mtime(Paths::installed_packages() + "/" + self.fullname)
207
+ @time = File.mtime(Paths::installed_packages() + "/" + self.fullname)
224
208
  end
225
209
  end
226
- return self.time
210
+ return @time
227
211
  end
228
212
 
229
213
  # Fill in the path information
230
- def get_path
231
- if (self.path.nil? && File.exist?(Paths::installed_packages() + "/" + self.name))
232
- self.path = Paths::installed_packages()
233
- return Paths::installed_packages()
234
- end
214
+ def path
215
+ @path ||= Paths::installed_packages()
216
+ end
217
+
218
+ def to_h
219
+ {
220
+ "name" => @name,
221
+ "version" => @version,
222
+ "arch" => @arch,
223
+ "build" => @build,
224
+ "tag" => @tag,
225
+ "tag_sep" => @tag_sep,
226
+ "upgrade_time" => @upgrade_time,
227
+ "compressed_size" => compressed_size(),
228
+ "uncompressed_size" => uncompressed_size(),
229
+ "path" => path(),
230
+ "time" => time(),
231
+ "owned_files" => owned_files(),
232
+ }
235
233
  end
236
234
 
237
235
  def inspect
@@ -248,6 +246,7 @@ module Slackware
248
246
 
249
247
  end
250
248
 
249
+
251
250
  class Script < Package
252
251
  attr_accessor :script
253
252
 
@@ -174,7 +174,7 @@ module Slackware
174
174
  debug('owns_file(): pkgs.count => %d' % pkgs.count)
175
175
  found_files = []
176
176
  file = file.sub(/^\//, "") # clean off the leading '/'
177
- re = /#{file}/
177
+ re = /#{Regexp.escape(file)}/
178
178
  debug('owns_file(): file Regexp => %s' % re.inspect)
179
179
  pkgs.each {|pkg|
180
180
  pkg.get_owned_files().select {|f|
@@ -217,7 +217,7 @@ end
217
217
 
218
218
  # search Array of Slackware::Package's for files
219
219
  # and print the items found
220
- def print_package_searched_files(pkgs, files)
220
+ def print_package_searched_files(files)
221
221
  found_files = []
222
222
  files.each {|file|
223
223
  found_files += Slackware::System.owns_file(file)
@@ -28,7 +28,7 @@ module Slackware
28
28
  rescue
29
29
  nil
30
30
  end
31
- UTILS_VERSION = "0.7.3"
31
+ UTILS_VERSION = "0.7.4"
32
32
  end
33
33
 
34
34
  # vim : set sw=2 sts=2 et :
metadata CHANGED
@@ -1,21 +1,20 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: slack-utils
3
- version: !ruby/object:Gem::Version
4
- version: 0.7.3
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.7.4
5
+ prerelease:
5
6
  platform: ruby
6
- authors:
7
+ authors:
7
8
  - Vincent Batts
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
-
12
- date: 2012-03-09 00:00:00 -05:00
13
- default_executable:
12
+ date: 2012-07-17 00:00:00.000000000 Z
14
13
  dependencies: []
15
-
16
- description: slack-utils is a means by which to access package information on the Slackware Linux OS. See the examples/ for more information.
14
+ description: ! " slack-utils is a means by which to access \npackage information on
15
+ the Slackware Linux OS. \nSee the examples/ for more information.\n "
17
16
  email: vbatts@hashbangbash.com
18
- executables:
17
+ executables:
19
18
  - sli
20
19
  - slf
21
20
  - slo
@@ -25,10 +24,9 @@ executables:
25
24
  - slu
26
25
  - slfindlinked
27
26
  extensions: []
28
-
29
- extra_rdoc_files:
27
+ extra_rdoc_files:
30
28
  - README.rdoc
31
- files:
29
+ files:
32
30
  - README.rdoc
33
31
  - bin/slf
34
32
  - bin/slt
@@ -54,34 +52,32 @@ files:
54
52
  - lib/slackware/repo.rb
55
53
  - lib/slackware/version.rb
56
54
  - lib/slackware/system.rb
57
- has_rdoc: true
58
55
  homepage: https://github.com/vbatts/slack-utils/
56
+ licenses: []
59
57
  post_install_message:
60
- rdoc_options:
58
+ rdoc_options:
61
59
  - --main=README.rdoc
62
60
  - --line-numbers
63
61
  - --inline-source
64
- - --title=Slackware utils (slack-utils) 0.7.3 Documentation
65
- require_paths:
62
+ - --title=Slackware utils (slack-utils) 0.7.4 Documentation
63
+ require_paths:
66
64
  - lib
67
- required_ruby_version: !ruby/object:Gem::Requirement
68
- requirements:
69
- - - ">="
70
- - !ruby/object:Gem::Version
71
- version: "0"
72
- version:
73
- required_rubygems_version: !ruby/object:Gem::Requirement
74
- requirements:
75
- - - ">="
76
- - !ruby/object:Gem::Version
77
- version: "0"
78
- version:
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
79
77
  requirements: []
80
-
81
78
  rubyforge_project:
82
- rubygems_version: 1.3.1
79
+ rubygems_version: 1.8.17
83
80
  signing_key:
84
- specification_version: 2
81
+ specification_version: 3
85
82
  summary: Accessing information for the Slackware Linux distribution
86
83
  test_files: []
87
-