rix 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README ADDED
File without changes
data/bin/rix ADDED
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.join(File.dirname(__FILE__), %w[.. lib])
4
+
5
+ require 'rix'
6
+ require 'optparse'
7
+
8
+ Rix::Registry.instance.register 'help', Rix::Commands::Help
9
+
10
+ if ARGV.size == 0
11
+ puts "Type 'rix --help' for usage."
12
+ exit 0
13
+ elsif not ARGV[0].start_with? '-'
14
+ name = ARGV.shift
15
+ command = Rix::Registry.instance[name]
16
+ command.execute
17
+ else
18
+ opts = OptionParser.new do |opts|
19
+ opts.on("-v", "--version") { puts Rix::VERSION; exit 0 }
20
+ opts.on("-h", "--help") { puts Rix::HELP; exit 0 }
21
+ end
22
+ begin
23
+ opts.parse!
24
+ rescue OptionParser::InvalidOption => e
25
+ puts "#{e.to_s.capitalize}. Type 'rix --help' for usage."
26
+ exit 1
27
+ end
28
+ end
@@ -0,0 +1,6 @@
1
+ require 'rix/commands/unknown'
2
+
3
+ module Rix
4
+ class Command
5
+ end
6
+ end
@@ -0,0 +1,33 @@
1
+ module Rix
2
+ module Commands
3
+ class Help < Command
4
+ def help
5
+ HELP
6
+ end
7
+
8
+ def execute
9
+ case ARGV.size
10
+ when 0
11
+ puts Rix::HELP
12
+ when 1
13
+ name = ARGV[0]
14
+ if name.downcase == 'commands'
15
+ puts "Available commands:"
16
+ Registry.instance.commands.each_key { |command| puts " #{command}" }
17
+ else
18
+ puts Registry.instance[name].help
19
+ end
20
+ else
21
+ puts HELP
22
+ end
23
+ end
24
+
25
+ HELP = <<HELP
26
+ Usage:
27
+ rix help
28
+ rix help commands
29
+ rix help <command>
30
+ HELP
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,19 @@
1
+ module Rix
2
+ module Commands
3
+ class UnknownCommand
4
+ attr_accessor :name
5
+
6
+ def message
7
+ "Unknown command: #{name}. Type 'rix help commands' for a list of available commands."
8
+ end
9
+
10
+ def help
11
+ message
12
+ end
13
+
14
+ def execute
15
+ puts message
16
+ end
17
+ end
18
+ end
19
+ end
data/lib/rix/help.rb ADDED
@@ -0,0 +1,16 @@
1
+ module Rix
2
+ HELP = <<HELP
3
+ Rix is a command-line XML editing and refactoring tool.
4
+
5
+ Usage:
6
+ rix <command> [options]
7
+ rix -h/--help
8
+ rix -v/--version
9
+
10
+ Help:
11
+ rix help commands List all commands
12
+ rix help <command> Show help of <command>
13
+
14
+ For additional information, see http://github.com/rh/rix
15
+ HELP
16
+ end
@@ -0,0 +1,25 @@
1
+ require 'rix/commands/unknown'
2
+
3
+ module Rix
4
+ class Registry
5
+ def self.instance
6
+ @instance ||= new
7
+ end
8
+
9
+ attr_reader :commands
10
+
11
+ def initialize
12
+ @commands = Hash.new(Commands::UnknownCommand)
13
+ end
14
+
15
+ def register(name, klass)
16
+ @commands[name] = klass
17
+ end
18
+
19
+ def [](name)
20
+ command = @commands[name].new
21
+ command.name = name if command.respond_to? :name
22
+ command
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,3 @@
1
+ module Rix
2
+ VERSION = '0.0.1'
3
+ end
data/lib/rix.rb ADDED
@@ -0,0 +1,6 @@
1
+ require 'rix/registry'
2
+ require 'rix/command'
3
+ require 'rix/commands/help'
4
+ require 'rix/commands/unknown'
5
+ require 'rix/help'
6
+ require 'rix/version'
metadata ADDED
@@ -0,0 +1,56 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rix
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease: !!null
6
+ platform: ruby
7
+ authors:
8
+ - Richard Hubers
9
+ autorequire: !!null
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-08-16 00:00:00.000000000 +02:00
13
+ default_executable: !!null
14
+ dependencies: []
15
+ description: Command-line XML editing and refactoring
16
+ email: richard.hubers@gmail.com
17
+ executables:
18
+ - rix
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - README
23
+ - bin/rix
24
+ - lib/rix/command.rb
25
+ - lib/rix/commands/help.rb
26
+ - lib/rix/commands/unknown.rb
27
+ - lib/rix/help.rb
28
+ - lib/rix/registry.rb
29
+ - lib/rix/version.rb
30
+ - lib/rix.rb
31
+ has_rdoc: false
32
+ homepage: http://github.com/rh/rix
33
+ licenses: []
34
+ post_install_message: !!null
35
+ rdoc_options: []
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '1.9'
44
+ required_rubygems_version: !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ! '>='
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ requirements: []
51
+ rubyforge_project: !!null
52
+ rubygems_version: 1.5.0
53
+ signing_key: !!null
54
+ specification_version: 3
55
+ summary: Command-line XML editor
56
+ test_files: []