postmodern 0.0.7 → 0.0.8

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: f405030c5dbf5f51a061e1ff2835e4a64910ce50
4
- data.tar.gz: 915def7fe244751c7bba0a86601c225f89c7e706
3
+ metadata.gz: 65c24efcd6053881f84ed0084efe2442c0a78d82
4
+ data.tar.gz: ec44170dedc5a7c2f59f34f91cfb16896bb4d830
5
5
  SHA512:
6
- metadata.gz: 5850bf34a46775aa89ac3dcd5d95d1485e424c75bf05f710a29f4e4373da32dc250c8ff9c3428b4fae46e5f9c359c92d5825431fdd1517251a913a61770a46f5
7
- data.tar.gz: ef083017586db98680ceb3fd7f55dfc9a3940c820c809958d915847efe2115916aefbffc486f828cbcdf65a69ee1b58374ac6de0732187a9e93a33cbb019f41e
6
+ metadata.gz: 89e96ef4176c6e887e9ff106033e63d78a0287cae0b0c7908767651de6c19a863eabadf65da699bb2f483be3906696f96662638d668670e4f676a27abeb73119
7
+ data.tar.gz: ccd1a255715acd723db55c0619fc49574565a9d8efe2814ca97b9cb82fb75d87197875b14223150d4982c9abdc5fdcef87d516ba726d20eeb861fcb4b2b292f5
data/bin/postmodern CHANGED
@@ -2,11 +2,12 @@
2
2
 
3
3
  $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
4
4
 
5
+ require 'postmodern/errors'
5
6
  require 'postmodern/wal'
6
7
  require 'optparse'
7
8
 
8
9
  options = {}
9
- OptionParser.new do |opts|
10
+ parser = OptionParser.new do |opts|
10
11
  opts.banner = "Usage: postmodern (archive|restore) <options>"
11
12
 
12
13
  opts.on('-f', '--filename FILE', 'File name to archive') do |o|
@@ -16,6 +17,23 @@ OptionParser.new do |opts|
16
17
  opts.on('-p', '--path PATH', 'Path name of file to archive') do |o|
17
18
  options[:path] = o
18
19
  end
19
- end.parse!
20
20
 
21
- Postmodern::WAL.run(ARGV.first, options[:file], options[:path])
21
+ opts.on_tail("-h", "--help", "Show this message") do
22
+ puts opts
23
+ exit
24
+ end
25
+
26
+ opts.on_tail("--version", "Show version") do
27
+ require 'postmodern/version'
28
+ puts Postmodern::VERSION
29
+ exit
30
+ end
31
+ end
32
+ parser.parse!
33
+
34
+ begin
35
+ Postmodern::WAL.run(ARGV.first, options)
36
+ rescue Postmodern::Error => e
37
+ puts e.message
38
+ puts parser.to_s
39
+ end
@@ -0,0 +1,4 @@
1
+ module Postmodern
2
+ class Error < StandardError
3
+ end
4
+ end
@@ -1,3 +1,3 @@
1
1
  module Postmodern
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -1,5 +1,6 @@
1
1
  require 'postmodern/wal/archive'
2
2
  require 'postmodern/wal/restore'
3
+ require 'postmodern/errors'
3
4
 
4
5
  module Postmodern
5
6
  module WAL
@@ -8,8 +9,15 @@ module Postmodern
8
9
  'restore' => Postmodern::WAL::Restore
9
10
  }
10
11
 
11
- def self.run(command, filename, path)
12
- COMMANDS[command].new(filename, path).run
12
+ def self.run(command, options)
13
+ validate!(options)
14
+ COMMANDS[command].new(options[:file], options[:path]).run
15
+ end
16
+
17
+ def self.validate!(options)
18
+ unless options[:file] and options[:path]
19
+ raise Postmodern::Error.new('Missing required options')
20
+ end
13
21
  end
14
22
  end
15
23
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: postmodern
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Saxby
@@ -56,6 +56,7 @@ files:
56
56
  - Rakefile
57
57
  - bin/postmodern
58
58
  - lib/postmodern.rb
59
+ - lib/postmodern/errors.rb
59
60
  - lib/postmodern/version.rb
60
61
  - lib/postmodern/wal.rb
61
62
  - lib/postmodern/wal/archive.rb