ronin 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/History.txt +21 -0
  2. data/Manifest.txt +17 -6
  3. data/README.txt +3 -2
  4. data/Rakefile +1 -0
  5. data/bin/ronin-add +12 -0
  6. data/bin/ronin-console +12 -0
  7. data/bin/ronin-ext +12 -0
  8. data/bin/ronin-help +12 -0
  9. data/bin/ronin-install +12 -0
  10. data/bin/ronin-ls +12 -0
  11. data/bin/ronin-overlay +12 -0
  12. data/bin/ronin-rm +12 -0
  13. data/bin/ronin-uninstall +12 -0
  14. data/bin/ronin-update +12 -0
  15. data/lib/ronin/extensions/string.rb +5 -3
  16. data/lib/ronin/platform/extension.rb +8 -2
  17. data/lib/ronin/platform/overlay.rb +16 -32
  18. data/lib/ronin/ui.rb +1 -1
  19. data/lib/ronin/ui/command_line.rb +1 -1
  20. data/lib/ronin/ui/command_line/command.rb +42 -60
  21. data/lib/ronin/ui/command_line/command_line.rb +28 -50
  22. data/lib/ronin/ui/command_line/commands/add.rb +41 -40
  23. data/lib/ronin/ui/command_line/commands/{default.rb → console.rb} +28 -21
  24. data/lib/ronin/ui/command_line/commands/{extension.rb → ext.rb} +25 -27
  25. data/lib/ronin/ui/command_line/commands/help.rb +26 -28
  26. data/lib/ronin/ui/command_line/commands/install.rb +32 -32
  27. data/lib/ronin/ui/command_line/commands/ls.rb +123 -0
  28. data/lib/ronin/ui/command_line/commands/overlay.rb +115 -114
  29. data/lib/ronin/ui/command_line/commands/{remove.rb → rm.rb} +27 -29
  30. data/lib/ronin/ui/command_line/commands/uninstall.rb +27 -29
  31. data/lib/ronin/ui/command_line/commands/update.rb +28 -30
  32. data/lib/ronin/ui/command_line/options.rb +0 -12
  33. data/lib/ronin/ui/command_line/param_parser.rb +34 -14
  34. data/lib/ronin/ui/console.rb +1 -0
  35. data/lib/ronin/ui/diagnostics.rb +5 -19
  36. data/lib/ronin/ui/{command_line/commands.rb → verbose.rb} +19 -11
  37. data/lib/ronin/version.rb +1 -1
  38. data/spec/arch_spec.rb +24 -24
  39. data/spec/chars/chars_spec.rb +49 -13
  40. data/spec/extensions/string_spec.rb +6 -6
  41. data/spec/spec_helper.rb +1 -1
  42. data/spec/ui/command_line/helpers/example_command.rb +21 -0
  43. data/spec/ui/command_line/param_parser_spec.rb +9 -18
  44. data/spec/ui/verbose_spec.rb +17 -0
  45. metadata +39 -8
  46. data/lib/ronin/ui/command_line/commands/list.rb +0 -122
  47. data/spec/ui/diagnostics_spec.rb +0 -17
@@ -1,3 +1,24 @@
1
+ === 0.2.1 / 2009-02-23
2
+
3
+ * Added Ronin::UI::Verbose.
4
+ * Require Nokogiri >= 1.2.0:
5
+ * Use Nokogiri::XML, instead of REXML, for XML parsing and building.
6
+ * Renamed String#inspect to String#dump.
7
+ * Aliased String#inspect to String#dump.
8
+ * Rewrote Ronin::UI::CommandLine.
9
+ * Removed Ronin::UI::CommandLine::Options.command.
10
+ * Refactored Ronin::UI::CommandLine::Command.
11
+ * Added Command#defaults method to give the command's variables
12
+ default values.
13
+ * Fixed a bug in Command.run.
14
+ * Renamed DefaultCommand to ConsoleCommand.
15
+ * Implement git style sub-commands.
16
+ * Use reverse-require to find sub-commands.
17
+ * Refactored Ronin::UI::ParamParser.
18
+ * Control parameter formats and their parsers with ParamParser.recognize.
19
+ * Rewrote the Ronin::Chars spec.
20
+ * Updated the Ronin::UI::ParamParser spec.
21
+
1
22
  === 0.2.0 / 2009-02-06
2
23
 
3
24
  * Moved the HTML formatting methods into the
@@ -5,6 +5,16 @@ README.txt
5
5
  TODO.txt
6
6
  Rakefile
7
7
  bin/ronin
8
+ bin/ronin-add
9
+ bin/ronin-console
10
+ bin/ronin-ext
11
+ bin/ronin-help
12
+ bin/ronin-install
13
+ bin/ronin-ls
14
+ bin/ronin-overlay
15
+ bin/ronin-rm
16
+ bin/ronin-uninstall
17
+ bin/ronin-update
8
18
  lib/ronin.rb
9
19
  lib/ronin/config.rb
10
20
  lib/ronin/extensions.rb
@@ -125,6 +135,7 @@ lib/ronin/platform/extension.rb
125
135
  lib/ronin/platform/platform.rb
126
136
  lib/ronin/platform/ronin.rb
127
137
  lib/ronin/ui.rb
138
+ lib/ronin/ui/verbose.rb
128
139
  lib/ronin/ui/diagnostics.rb
129
140
  lib/ronin/ui/hexdump.rb
130
141
  lib/ronin/ui/hexdump/hexdump.rb
@@ -139,15 +150,14 @@ lib/ronin/ui/command_line/exceptions/unknown_command.rb
139
150
  lib/ronin/ui/command_line/command.rb
140
151
  lib/ronin/ui/command_line/options.rb
141
152
  lib/ronin/ui/command_line/param_parser.rb
142
- lib/ronin/ui/command_line/commands.rb
143
- lib/ronin/ui/command_line/commands/default.rb
153
+ lib/ronin/ui/command_line/commands/console.rb
144
154
  lib/ronin/ui/command_line/commands/overlay.rb
145
- lib/ronin/ui/command_line/commands/extension.rb
155
+ lib/ronin/ui/command_line/commands/ext.rb
146
156
  lib/ronin/ui/command_line/commands/add.rb
147
157
  lib/ronin/ui/command_line/commands/install.rb
148
- lib/ronin/ui/command_line/commands/list.rb
158
+ lib/ronin/ui/command_line/commands/ls.rb
149
159
  lib/ronin/ui/command_line/commands/update.rb
150
- lib/ronin/ui/command_line/commands/remove.rb
160
+ lib/ronin/ui/command_line/commands/rm.rb
151
161
  lib/ronin/ui/command_line/commands/uninstall.rb
152
162
  lib/ronin/ui/command_line/commands/help.rb
153
163
  lib/ronin/ui/command_line/command_line.rb
@@ -192,7 +202,8 @@ spec/platform/overlay_cache_spec.rb
192
202
  spec/platform/extension_cache_spec.rb
193
203
  spec/platform/platform_spec.rb
194
204
  spec/platform/ronin_spec.rb
195
- spec/ui/diagnostics_spec.rb
205
+ spec/ui/verbose_spec.rb
206
+ spec/ui/command_line/helpers/example_command.rb
196
207
  spec/ui/command_line/param_parser_spec.rb
197
208
  spec/ronin_spec.rb
198
209
  static/overlay.xsl
data/README.txt CHANGED
@@ -68,6 +68,7 @@ of Ronin.
68
68
  == REQUIREMENTS:
69
69
 
70
70
  * {libsqlite3}[http://sqlite.org/]
71
+ * {nokogiri}[http://nokogiri.rubyforge.org/] >= 1.2.0
71
72
  * {DataMapper}[http://datamapper.org/]:
72
73
  * dm-core >= 0.9.9
73
74
  * data_objects >= 0.9.9
@@ -106,11 +107,11 @@ of Ronin.
106
107
 
107
108
  * Update all installed Overlays:
108
109
 
109
- $ ronin up
110
+ $ ronin update
110
111
 
111
112
  * Update a specific Overlay:
112
113
 
113
- $ ronin up overlay-name
114
+ $ ronin update overlay-name
114
115
 
115
116
  * Uninstall an Overlay:
116
117
 
data/Rakefile CHANGED
@@ -10,6 +10,7 @@ Hoe.new('ronin', Ronin::VERSION) do |p|
10
10
  p.developer('Postmodern','postmodern.mod3@gmail.com')
11
11
  p.remote_rdoc_dir = 'docs/ronin'
12
12
  p.extra_deps = [
13
+ ['nokogiri', '>=1.2.0'],
13
14
  ['dm-core', '>=0.9.9'],
14
15
  ['data_objects', '>=0.9.9'],
15
16
  ['do_sqlite3', '>=0.9.9'],
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+
5
+ lib_dir = File.expand_path(File.join(File.dirname(__FILE__),'..','lib'))
6
+ unless $LOAD_PATH.include?(lib_dir)
7
+ $LOAD_PATH << lib_dir
8
+ end
9
+
10
+ require 'ronin/ui/command_line/commands/add'
11
+
12
+ Ronin::UI::CommandLine::Commands::Add.run(*ARGV)
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+
5
+ lib_dir = File.expand_path(File.join(File.dirname(__FILE__),'..','lib'))
6
+ unless $LOAD_PATH.include?(lib_dir)
7
+ $LOAD_PATH << lib_dir
8
+ end
9
+
10
+ require 'ronin/ui/command_line/commands/console'
11
+
12
+ Ronin::UI::CommandLine::Commands::Console.run(*ARGV)
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+
5
+ lib_dir = File.expand_path(File.join(File.dirname(__FILE__),'..','lib'))
6
+ unless $LOAD_PATH.include?(lib_dir)
7
+ $LOAD_PATH << lib_dir
8
+ end
9
+
10
+ require 'ronin/ui/command_line/commands/ext'
11
+
12
+ Ronin::UI::CommandLine::Commands::Ext.run(*ARGV)
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+
5
+ lib_dir = File.expand_path(File.join(File.dirname(__FILE__),'..','lib'))
6
+ unless $LOAD_PATH.include?(lib_dir)
7
+ $LOAD_PATH << lib_dir
8
+ end
9
+
10
+ require 'ronin/ui/command_line/commands/help'
11
+
12
+ Ronin::UI::CommandLine::Commands::Help.run(*ARGV)
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+
5
+ lib_dir = File.expand_path(File.join(File.dirname(__FILE__),'..','lib'))
6
+ unless $LOAD_PATH.include?(lib_dir)
7
+ $LOAD_PATH << lib_dir
8
+ end
9
+
10
+ require 'ronin/ui/command_line/commands/install'
11
+
12
+ Ronin::UI::CommandLine::Commands::Install.run(*ARGV)
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+
5
+ lib_dir = File.expand_path(File.join(File.dirname(__FILE__),'..','lib'))
6
+ unless $LOAD_PATH.include?(lib_dir)
7
+ $LOAD_PATH << lib_dir
8
+ end
9
+
10
+ require 'ronin/ui/command_line/commands/ls'
11
+
12
+ Ronin::UI::CommandLine::Commands::LS.run(*ARGV)
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+
5
+ lib_dir = File.expand_path(File.join(File.dirname(__FILE__),'..','lib'))
6
+ unless $LOAD_PATH.include?(lib_dir)
7
+ $LOAD_PATH << lib_dir
8
+ end
9
+
10
+ require 'ronin/ui/command_line/commands/overlay'
11
+
12
+ Ronin::UI::CommandLine::Commands::Overlay.run(*ARGV)
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+
5
+ lib_dir = File.expand_path(File.join(File.dirname(__FILE__),'..','lib'))
6
+ unless $LOAD_PATH.include?(lib_dir)
7
+ $LOAD_PATH << lib_dir
8
+ end
9
+
10
+ require 'ronin/ui/command_line/commands/rm'
11
+
12
+ Ronin::UI::CommandLine::Commands::RM.run(*ARGV)
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+
5
+ lib_dir = File.expand_path(File.join(File.dirname(__FILE__),'..','lib'))
6
+ unless $LOAD_PATH.include?(lib_dir)
7
+ $LOAD_PATH << lib_dir
8
+ end
9
+
10
+ require 'ronin/ui/command_line/commands/uninstall'
11
+
12
+ Ronin::UI::CommandLine::Commands::Uninstall.run(*ARGV)
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+
5
+ lib_dir = File.expand_path(File.join(File.dirname(__FILE__),'..','lib'))
6
+ unless $LOAD_PATH.include?(lib_dir)
7
+ $LOAD_PATH << lib_dir
8
+ end
9
+
10
+ require 'ronin/ui/command_line/commands/update'
11
+
12
+ Ronin::UI::CommandLine::Commands::Update.run(*ARGV)
@@ -84,12 +84,12 @@ class String
84
84
  end
85
85
 
86
86
  #
87
- # Inspects the string, returning a C style encoded version of the string.
87
+ # Dumps the string, returning a C style encoded version of the string.
88
88
  #
89
- # "hello\x00\073\x90\r\n"
89
+ # "hello\x00\073\x90\r\n".dump
90
90
  # # => "hello\0;\x90\r\n"
91
91
  #
92
- def inspect
92
+ def dump
93
93
  c_string = ''
94
94
 
95
95
  each_byte do |b|
@@ -124,4 +124,6 @@ class String
124
124
  return "\"#{c_string}\""
125
125
  end
126
126
 
127
+ alias inspect dump
128
+
127
129
  end
@@ -230,7 +230,13 @@ module Ronin
230
230
  def run(&block)
231
231
  setup!
232
232
 
233
- block.call(self) if block
233
+ if block
234
+ if block.arity == 1
235
+ block.call(self)
236
+ else
237
+ block.call()
238
+ end
239
+ end
234
240
 
235
241
  teardown!
236
242
  return self
@@ -289,7 +295,7 @@ module Ronin
289
295
  # ext.find_file('data/test/file.xml')
290
296
  #
291
297
  # ext.find_file('data/test/file.xml') do |file|
292
- # REXML::Document.new(open(file))
298
+ # Nokogiri::XML(open(file))
293
299
  # ...
294
300
  # end
295
301
  #
@@ -25,8 +25,8 @@ require 'ronin/platform/exceptions/extension_not_found'
25
25
  require 'ronin/platform/maintainer'
26
26
  require 'ronin/platform/extension'
27
27
 
28
- require 'rexml/document'
29
28
  require 'repertoire'
29
+ require 'nokogiri'
30
30
 
31
31
  module Ronin
32
32
  module Platform
@@ -225,44 +225,28 @@ module Ronin
225
225
  @description = nil
226
226
 
227
227
  if File.file?(metadata_path)
228
- doc = REXML::Document.new(open(metadata_path))
229
- overlay = doc.elements['/ronin-overlay']
230
-
231
- overlay.each_element('title[.]:first') do |title|
232
- @title = title.text.strip
233
- end
234
-
235
- overlay.each_element('license[.]:first') do |license|
236
- @license = license.text.strip
237
- end
238
-
239
- overlay.each_element('source[.]:first') do |source|
240
- @source = source.text.strip
241
- end
242
-
243
- overlay.each_element('source-view[.]:first') do |source_view|
244
- @source_view = source_view.text.strip
245
- end
246
-
247
- overlay.each_element('website[.]:first') do |website|
248
- @website = website.text.strip
249
- end
250
-
251
- overlay.each_element('maintainers/maintainer') do |maintainer|
252
- if (name = maintainer.text('name'))
253
- name.strip!
228
+ doc = Nokogiri::XML(open(metadata_path))
229
+ overlay = doc.at('/ronin-overlay')
230
+
231
+ @title = overlay.at('title').inner_text.strip
232
+ @license = overlay.at('license').inner_text.strip
233
+ @source = overlay.at('source').inner_text.strip
234
+ @source_view = overlay.at('source-view').inner_text.strip
235
+ @website = overlay.at('website').inner_text.strip
236
+
237
+ overlay.search('maintainers/maintainer').each do |maintainer|
238
+ if (name = maintainer.at('name'))
239
+ name = name.inner_text.strip
254
240
  end
255
241
 
256
- if (email = maintainer.text('email'))
257
- email.strip!
242
+ if (email = maintainer.at('email'))
243
+ email = email.inner_text.strip
258
244
  end
259
245
 
260
246
  @maintainers << Maintainer.new(name,email)
261
247
  end
262
248
 
263
- overlay.each_element('description[.]:first') do |description|
264
- @description = description.text.strip
265
- end
249
+ @description = overlay.search('description').inner_text.strip
266
250
  end
267
251
 
268
252
  block.call(self) if block
@@ -21,8 +21,8 @@
21
21
  #++
22
22
  #
23
23
 
24
+ require 'ronin/ui/verbose'
24
25
  require 'ronin/ui/diagnostics'
25
26
  require 'ronin/ui/hexdump'
26
27
  require 'ronin/ui/console'
27
28
  require 'ronin/ui/shell'
28
-
@@ -21,5 +21,5 @@
21
21
  #++
22
22
  #
23
23
 
24
+ require 'ronin/ui/command_line/command'
24
25
  require 'ronin/ui/command_line/command_line'
25
- require 'ronin/ui/command_line/commands'
@@ -22,57 +22,53 @@
22
22
  #
23
23
 
24
24
  require 'ronin/ui/command_line/options'
25
- require 'ronin/ui/command_line/command_line'
26
- require 'ronin/extensions/meta'
27
25
 
28
26
  module Ronin
29
27
  module UI
30
28
  module CommandLine
31
29
  class Command
32
30
 
31
+ # The name of the command
32
+ attr_reader :name
33
+
33
34
  # The options for the command
34
35
  attr_reader :options
35
36
 
36
37
  #
37
38
  # Creates a new Command object.
38
39
  #
39
- def initialize
40
- Options.command('ronin',self.class.command_name) do |opts|
40
+ def initialize(name,&block)
41
+ @name = name.to_s
42
+
43
+ defaults()
44
+
45
+ Options.new(@name) do |opts|
41
46
  define_options(opts)
42
47
 
43
48
  @options = opts
44
49
  end
45
- end
46
-
47
- #
48
- # Returns the name of the command.
49
- #
50
- def self.command_name
51
- nil
52
- end
53
50
 
54
- #
55
- # Returns the short names of the command.
56
- #
57
- def self.command_short_names
58
- []
59
- end
60
-
61
- #
62
- # Returns all the names of the command.
63
- #
64
- def self.command_names
65
- ([self.command_name] + self.command_short_names).compact
51
+ block.call(self) if block
66
52
  end
67
53
 
68
54
  #
69
55
  # Creates a new command object and runs it with the given _args_.
70
56
  #
71
57
  def self.run(*args)
72
- cmd = self.new
58
+ name = File.basename($0)
59
+ name.gsub!(/^ronin-/,'')
60
+
61
+ cmd = self.new(name)
62
+
63
+ begin
64
+ cmd.arguments(*(cmd.options.parse(args)))
65
+ rescue OptionParser::MissingArgument,
66
+ OptionParser::InvalidOption => e
67
+ STDERR.puts e
68
+ exit -1
69
+ end
73
70
 
74
- cmd.arguments(*(cmd.options.parse(args)))
75
- return nil
71
+ return true
76
72
  end
77
73
 
78
74
  #
@@ -94,57 +90,43 @@ module Ronin
94
90
  # Returns the String form of the command.
95
91
  #
96
92
  def to_s
97
- names.join(', ')
93
+ @name.to_s
98
94
  end
99
95
 
100
96
  protected
101
97
 
102
98
  #
103
- # Registers the command with the specified _name_ and the given
104
- # _short_names_.
99
+ # Prints the specified error _message_.
105
100
  #
106
- def self.command(name,*short_names)
107
- name = name.to_s
108
- short_names = short_names.map { |short_name| short_name.to_s }
109
-
110
- meta_def(:command_name) { name }
111
- meta_def(:command_short_names) { short_names }
112
-
113
- unless CommandLine.commands.include?(self)
114
- # register the command
115
- CommandLine.commands << self
116
- end
117
-
118
- # register the command by name
119
- CommandLine.commands_by_name[name] = self
120
-
121
- # register the command by it's short_names
122
- short_names.each do |short_name|
123
- CommandLine.commands_by_name[short_name] = self
124
- end
125
-
126
- return self
101
+ def error(message)
102
+ STDERR.puts "ronin: #{@name}: #{message}"
103
+ return false
127
104
  end
128
105
 
129
106
  #
130
- # See CommandLine.error.
107
+ # Calls the specified _block_, then exists with the status code of 0.
131
108
  #
132
- def error(message)
133
- CommandLine.error("#{self.class.command_name}: #{message}")
109
+ def success(&block)
110
+ block.call
111
+ exit 0
134
112
  end
135
113
 
136
114
  #
137
- # See CommandLine.success.
115
+ # Prints the given error _message_ and exits unseccessfully from the
116
+ # command-line utility. If a _block_ is given, it will be called before
117
+ # any error _message_ are printed.
138
118
  #
139
- def success(&block)
140
- CommandLine.success(&block)
119
+ def fail(message,&block)
120
+ block.call() if block
121
+
122
+ error(message)
123
+ exit -1
141
124
  end
142
125
 
143
126
  #
144
- # See CommandLine.fail.
127
+ # Setup the command default values.
145
128
  #
146
- def fail(message,&block)
147
- CommandLine.fail("#{self.class.command_name}: #{message}",&block)
129
+ def defaults
148
130
  end
149
131
 
150
132
  #