pstore_pp 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/pstore_pp +8 -2
- data/lib/pstore_pp.rb +24 -20
- data/lib/pstore_pp/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 873cd229abace0b7b91803cf1c78184f82a87264
|
4
|
+
data.tar.gz: 844e0b3ef7c333ae7c16e9421cf17db31fd7593d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de280a5dcf73b3e93a55b1afb1976c9977afa0aa7231d5ee59d13541e17dac00f46bc411dad347b25794098a9ea58bafc5280968af744d32922cfd0ea6a5d8be
|
7
|
+
data.tar.gz: 5231af5e7c2b016c9f09665a7cab705a9432dfe29f9aec4de8a424784d39a383ecade461435d20f6c12433657d9db254df7569712d2554df3a480e87948ed073
|
data/bin/pstore_pp
CHANGED
@@ -6,6 +6,8 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
6
6
|
require 'pstore_pp'
|
7
7
|
require 'optparse'
|
8
8
|
|
9
|
+
libraries = []
|
10
|
+
|
9
11
|
begin
|
10
12
|
OptionParser.new do |opts|
|
11
13
|
opts.banner = <<-END.gsub(/^ {4}/, '')
|
@@ -14,10 +16,14 @@ begin
|
|
14
16
|
Usage: #{opts.program_name} FILE [FILES...]
|
15
17
|
END
|
16
18
|
opts.version = PStorePP::VERSION
|
19
|
+
|
20
|
+
opts.on('--require LIB', 'Require LIB before printing the PStore') do |library|
|
21
|
+
libraries << library
|
22
|
+
end
|
17
23
|
end.parse!
|
18
24
|
|
19
|
-
PStorePP::CLI.start
|
25
|
+
PStorePP::CLI.new(libraries).start
|
20
26
|
rescue => e
|
21
|
-
|
27
|
+
warn "Error - #{e.message}"
|
22
28
|
exit 1
|
23
29
|
end
|
data/lib/pstore_pp.rb
CHANGED
@@ -3,31 +3,35 @@ require 'pstore'
|
|
3
3
|
require 'json'
|
4
4
|
|
5
5
|
module PStorePP
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
class CLI
|
7
|
+
def initialize(libraries = [])
|
8
|
+
Array(libraries).each do |l|
|
9
|
+
require l
|
10
|
+
end
|
11
|
+
end
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
13
|
+
def start(args = ARGV)
|
14
|
+
args = Array(args)
|
15
|
+
|
16
|
+
case args.size
|
17
|
+
when 0
|
18
|
+
fail 'Error - Missing file name.'
|
19
|
+
when 1
|
20
|
+
puts JSON.generate(dump(args.first))
|
21
|
+
else
|
22
|
+
puts JSON.generate(args.map { |file| { file => dump(file) } })
|
19
23
|
end
|
24
|
+
end
|
20
25
|
|
21
|
-
|
22
|
-
|
26
|
+
def dump(file)
|
27
|
+
fail "Could not find file: #{file}" unless File.exist?(file)
|
23
28
|
|
24
|
-
|
29
|
+
store = PStore.new(file)
|
25
30
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
end
|
31
|
+
store.transaction(true) do
|
32
|
+
store.roots.map do |key|
|
33
|
+
[key, store[key]]
|
34
|
+
end.to_h
|
31
35
|
end
|
32
36
|
end
|
33
37
|
end
|
data/lib/pstore_pp/version.rb
CHANGED