kang 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4 @@
1
+ == 0.0.1 2009-01-07
2
+
3
+ * 1 major enhancement:
4
+ * Initial release
@@ -0,0 +1,9 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.txt
4
+ Rakefile
5
+ bin/kang
6
+ lib/kang.rb
7
+ lib/kang/cli.rb
8
+ test/test_helper.rb
9
+ test/test_kang.rb
@@ -0,0 +1,36 @@
1
+ = kang
2
+
3
+ * http://kang.rubyforge.org/
4
+
5
+ == DESCRIPTION:
6
+
7
+ * KANG - The Ruby Regex Debugger
8
+
9
+ == FEATURES/PROBLEMS:
10
+
11
+ * This is a cross-platform GUI application. To run it you'll need Ruby (I've only tested with 1.8.7 so far) and the wxruby gem (I've only tested with 1.9.8).
12
+
13
+ == SYNOPSIS:
14
+
15
+ FIX (code sample of usage)
16
+
17
+ == REQUIREMENTS:
18
+
19
+ * ruby
20
+ * rubygems
21
+ * wxruby
22
+
23
+ == INSTALL:
24
+
25
+ * sudo gem install kang
26
+
27
+ == LICENSE:
28
+
29
+ ====================================================================
30
+ Copyright (c) 2008 Tony Doan <tdoan@tdoan.com>. All rights reserved.
31
+ This software is licensed as described in the file COPYING, which
32
+ you should have received as part of this distribution. The terms
33
+ are also available at http://github.com/tdoan/kang/tree/master/COPYING.
34
+ If newer versions of this license are posted there, you may use a
35
+ newer version instead, at your option.
36
+ ====================================================================
@@ -0,0 +1,28 @@
1
+ %w[rubygems rake rake/clean fileutils newgem rubigen].each { |f| require f }
2
+ require File.dirname(__FILE__) + '/lib/kang'
3
+
4
+ # Generate all the Rake tasks
5
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
6
+ $hoe = Hoe.new('kang', Kang::VERSION) do |p|
7
+ p.developer('Tony Doan', 'tdoan@tdoan.com')
8
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
9
+ #p.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
10
+ p.rubyforge_name = p.name # TODO this is default value
11
+ p.extra_deps = [
12
+ ['wxruby','>= 1.9.8'],
13
+ ]
14
+ p.extra_dev_deps = [
15
+ ['newgem', ">= #{::Newgem::VERSION}"]
16
+ ]
17
+
18
+ p.clean_globs |= %w[**/.DS_Store tmp *.log]
19
+ path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
20
+ p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
21
+ p.rsync_args = '-av --delete --ignore-errors'
22
+ end
23
+
24
+ require 'newgem/tasks' # load /tasks/*.rake
25
+ Dir['tasks/**/*.rake'].each { |t| load t }
26
+
27
+ # TODO - want other tests/tasks run by default? Add them to the list
28
+ # task :default => [:spec, :features]
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Created on 2009-1-7.
4
+ # Copyright (c) 2009. All rights reserved.
5
+
6
+ require 'rubygems'
7
+ require File.expand_path(File.dirname(__FILE__) + "/../lib/kang")
8
+ require "kang/cli"
9
+
10
+ Kang::CLI.execute(STDOUT, ARGV)
@@ -0,0 +1,115 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ #
4
+ # kang.rb - Main executable for GUI interface
5
+ #
6
+ # ====================================================================
7
+ # Copyright (c) 2008 Tony Doan <tdoan@tdoan.com>. All rights reserved.
8
+ #
9
+ # This software is licensed as described in the file COPYING, which
10
+ # you should have received as part of this distribution. The terms
11
+ # are also available at http://github.com/tdoan/kang/tree/master/COPYING.
12
+ # If newer versions of this license are posted there, you may use a
13
+ # newer version instead, at your option.
14
+ # ====================================================================
15
+ #
16
+ $:.unshift(File.dirname(__FILE__)) unless
17
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
18
+
19
+ require 'wx'
20
+ include Wx
21
+
22
+ module Kang
23
+ VERSION = '0.0.1'
24
+ class EventFrame < Wx::Frame
25
+ def message(text, title)
26
+ m = Wx::MessageDialog.new(self, text, title, Wx::OK | Wx::ICON_INFORMATION)
27
+ m.show_modal()
28
+ end
29
+
30
+ def initialize()
31
+ @highlight = Wx::TextAttr.new(Wx::GREEN, Wx::Colour.new(255, 255, 0) )
32
+ @normal = Wx::TextAttr.new(Wx::BLACK, Wx::WHITE) #, Wx::Colour.new(255, 255, 0) )
33
+
34
+ super(nil, -1, "Kang")
35
+ set_client_size(Wx::Size.new(640,480))
36
+ t1_title = Wx::StaticBox.new(self, -1, "Regex", Wx::DEFAULT_POSITION)
37
+ t2_title = Wx::StaticBox.new(self, -1, "Text", Wx::DEFAULT_POSITION)
38
+ ls_title = Wx::StaticBox.new(self, -1, "Groups", Wx::DEFAULT_POSITION)
39
+ grid = Wx::GridSizer.new(2,10,10)
40
+ sizer = Wx::BoxSizer.new(Wx::VERTICAL)
41
+ supersizer = Wx::BoxSizer.new(Wx::VERTICAL)
42
+ @text = Wx::TextCtrl.new(self,-1,'(Regex)? (in) (here)',Wx::DEFAULT_POSITION,Wx::DEFAULT_SIZE,Wx::TE_MULTILINE|TE_RICH)
43
+ @text2 = Wx::TextCtrl.new(self,-1,'Text in here',Wx::DEFAULT_POSITION,Wx::DEFAULT_SIZE,Wx::TE_MULTILINE)
44
+ @list = Wx::ListCtrl.new(self,-1,Wx::DEFAULT_POSITION,Wx::DEFAULT_SIZE,Wx::LC_REPORT)
45
+ @list.insert_column(0,"Group Num",Wx::LIST_FORMAT_RIGHT, -1)
46
+ @list.set_column_width(0,85)
47
+ @list.insert_column(1,"Match Data",Wx::LIST_FORMAT_LEFT, -1)
48
+ @list.set_column_width(1,180)
49
+ t1sizer = Wx::StaticBoxSizer.new(t1_title,Wx::VERTICAL)
50
+ t2sizer = Wx::StaticBoxSizer.new(t2_title,Wx::VERTICAL)
51
+ lssizer = Wx::StaticBoxSizer.new(ls_title,Wx::VERTICAL)
52
+ t1sizer.add(@text, 1,Wx::EXPAND|Wx::ALL,2)
53
+ t2sizer.add(@text2,1,Wx::EXPAND|Wx::ALL,2)
54
+ lssizer.add(@list,1,Wx::EXPAND|Wx::ALL,2)
55
+ sizer.add(t1sizer,1,Wx::EXPAND,2)
56
+ sizer.add(t2sizer,1,Wx::EXPAND,2)
57
+ @status = StatusBar.new(self,-1)
58
+ grid.add(sizer,1,Wx::EXPAND)
59
+ grid.add(lssizer,1,Wx::EXPAND)
60
+ supersizer.add(grid,1,Wx::EXPAND)
61
+ supersizer.add(@status)
62
+ self.set_sizer(supersizer)
63
+ evt_text(@text.get_id){|event| text_change(event)}
64
+ evt_text(@text2.get_id){|event| text_change(event)}
65
+ text_change(nil)
66
+ end
67
+
68
+ def set_status(text)
69
+ @status.set_status_text(text)
70
+ end
71
+
72
+ def text_change(event)
73
+ ip = @text2.get_insertion_point
74
+ size = @text2.get_value.size
75
+ begin
76
+ r = Regexp.new(@text.get_value)
77
+ set_status("")
78
+ rescue
79
+ set_status("Invalid Regex")
80
+ @list.delete_all_items
81
+ end
82
+ unless r.nil?
83
+ md = r.match(@text2.get_value)
84
+ unless md.nil?
85
+ b = md.begin(0)
86
+ e = md.end(0)
87
+ ret= @text2.set_style(0,size,@normal)
88
+ @text2.append_text("")
89
+ @text2.set_style(b,e,@highlight)
90
+ @text2.append_text("")
91
+ @list.delete_all_items
92
+ md.to_a[1..-1].each_with_index do |s,i|
93
+ @list.insert_item(i,"#{i+1}")
94
+ @list.set_item(i,1,s) unless s.nil?
95
+ end
96
+ else
97
+ ret = @text2.set_style(0,size,@normal)
98
+ @text2.append_text("")
99
+ @list.delete_all_items
100
+ end
101
+ else
102
+ ret = @text2.set_style(0,size,@normal)
103
+ @text2.append_text("")
104
+ end
105
+ @text2.set_insertion_point(ip)
106
+ end
107
+ end
108
+
109
+ class Kang < App
110
+
111
+ def on_init
112
+ EventFrame.new.show
113
+ end
114
+ end
115
+ end
@@ -0,0 +1,7 @@
1
+ module Kang
2
+ class CLI
3
+ def self.execute(stdout, arguments=[])
4
+ Kang.new.main_loop
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ require 'stringio'
2
+ require 'test/unit'
3
+ require File.dirname(__FILE__) + '/../lib/kang'
@@ -0,0 +1,11 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestKang < Test::Unit::TestCase
4
+
5
+ def setup
6
+ end
7
+
8
+ def test_truth
9
+ assert true
10
+ end
11
+ end
@@ -0,0 +1,14 @@
1
+ require File.join(File.dirname(__FILE__), "test_helper.rb")
2
+ require 'kang/cli'
3
+
4
+ class TestKangCli < Test::Unit::TestCase
5
+ def setup
6
+ Kang::CLI.execute(@stdout_io = StringIO.new, [])
7
+ @stdout_io.rewind
8
+ @stdout = @stdout_io.read
9
+ end
10
+
11
+ def test_not_print_default_output
12
+ assert_no_match(/To update this executable/, @stdout)
13
+ end
14
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kang
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Tony Doan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-01-07 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: wxruby
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.9.8
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: newgem
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.2.3
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: hoe
37
+ type: :development
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 1.8.0
44
+ version:
45
+ description: "* KANG - The Ruby Regex Debugger"
46
+ email:
47
+ - tdoan@tdoan.com
48
+ executables:
49
+ - kang
50
+ extensions: []
51
+
52
+ extra_rdoc_files:
53
+ - History.txt
54
+ - Manifest.txt
55
+ - README.txt
56
+ files:
57
+ - History.txt
58
+ - Manifest.txt
59
+ - README.txt
60
+ - Rakefile
61
+ - bin/kang
62
+ - lib/kang.rb
63
+ - lib/kang/cli.rb
64
+ - test/test_helper.rb
65
+ - test/test_kang.rb
66
+ has_rdoc: true
67
+ homepage: http://kang.rubyforge.org/
68
+ post_install_message:
69
+ rdoc_options:
70
+ - --main
71
+ - README.txt
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: "0"
79
+ version:
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: "0"
85
+ version:
86
+ requirements: []
87
+
88
+ rubyforge_project: kang
89
+ rubygems_version: 1.3.1
90
+ signing_key:
91
+ specification_version: 2
92
+ summary: "* KANG - The Ruby Regex Debugger"
93
+ test_files:
94
+ - test/test_helper.rb
95
+ - test/test_kang.rb
96
+ - test/test_kang_cli.rb