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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eb0f3271a9129ba63ecf3aac21228c5a190275c3
4
- data.tar.gz: 1500b6ff6795dfd62badc224f299246e916a62f6
3
+ metadata.gz: 873cd229abace0b7b91803cf1c78184f82a87264
4
+ data.tar.gz: 844e0b3ef7c333ae7c16e9421cf17db31fd7593d
5
5
  SHA512:
6
- metadata.gz: 50ee0caf1e3d4b6a7e1e88bf03762f3e55cf35c8ef526ea1ba14320f1cb9c626e2950da93e3e55c34c2fec214944e6696fe4716e9f7fd5a2b4b5c1752ec41d6c
7
- data.tar.gz: 9230dfffb60b85a968a6e38b8deebe644516c783b6435af60dffda1430bebcfe131519ce9c491c2b33d5cd0738c76cc8e3f240e1a17458839f128cc7864a603e
6
+ metadata.gz: de280a5dcf73b3e93a55b1afb1976c9977afa0aa7231d5ee59d13541e17dac00f46bc411dad347b25794098a9ea58bafc5280968af744d32922cfd0ea6a5d8be
7
+ data.tar.gz: 5231af5e7c2b016c9f09665a7cab705a9432dfe29f9aec4de8a424784d39a383ecade461435d20f6c12433657d9db254df7569712d2554df3a480e87948ed073
@@ -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
- STDERR.puts "Error - #{e.message}"
27
+ warn "Error - #{e.message}"
22
28
  exit 1
23
29
  end
@@ -3,31 +3,35 @@ require 'pstore'
3
3
  require 'json'
4
4
 
5
5
  module PStorePP
6
- module CLI
7
- class << self
8
- def start(args = ARGV)
9
- args = Array(args)
6
+ class CLI
7
+ def initialize(libraries = [])
8
+ Array(libraries).each do |l|
9
+ require l
10
+ end
11
+ end
10
12
 
11
- case args.size
12
- when 0
13
- fail 'Error - Missing file name.'
14
- when 1
15
- puts JSON.generate(dump(args.first))
16
- else
17
- puts JSON.generate(args.map { |file| { file => dump(file) } })
18
- end
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
- def dump(file)
22
- fail "Could not find file: #{file}" unless File.exist?(file)
26
+ def dump(file)
27
+ fail "Could not find file: #{file}" unless File.exist?(file)
23
28
 
24
- store = PStore.new(file)
29
+ store = PStore.new(file)
25
30
 
26
- store.transaction(true) do
27
- store.roots.map do |key|
28
- [key, store[key]]
29
- end.to_h
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
@@ -1,3 +1,3 @@
1
1
  module PStorePP
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pstore_pp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicholas E. Rabenau