wx_runner 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.
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source :rubygems
2
+
3
+ # Specify your gem's dependencies in wx_runner.gemspec
4
+ gemspec
5
+
6
+ gem 'wxruby', :require => 'wx', :platforms => :mri_18
7
+ gem 'wxruby19', :require => 'wx', :platforms => :mri_19
data/README.rdoc ADDED
@@ -0,0 +1,121 @@
1
+ = WxRunner
2
+
3
+ Created for use with the following objectives:
4
+ * Wxruby app using threads
5
+ * Wxruby spec app
6
+ * preview of non-top-level window (or text controls, list views, etc.)
7
+
8
+ == Install
9
+
10
+ gem install wx_runner
11
+
12
+ == Useage
13
+
14
+ 1. The classes run windows
15
+ require 'wx'
16
+ require 'wx_ruuner'
17
+ TextCtrl.run
18
+
19
+ 2.'s show window class
20
+ require 'wx'
21
+ require 'wx_ruuner'
22
+ WxRunner.run do
23
+ TextCtrl.show
24
+ CheckBox.show
25
+ end
26
+
27
+ 3. Threading
28
+ You can use ruby threads as usual.
29
+
30
+ 4. accessed over the thread
31
+ require 'wx'
32
+ require 'wx_ruuner'
33
+ WxRunner.run do
34
+ @ text = TextCtrl.show
35
+ CheckBox.show
36
+ Thread.new
37
+ str = WxRunner.on_wx_thread do
38
+ @ text.label = "sample"
39
+ @ text.label
40
+ end
41
+ end
42
+ end
43
+
44
+ 5. Spec automatic test
45
+ require 'wx'
46
+ require 'wx_ruuner'
47
+
48
+ WxRunner.run_thread
49
+
50
+ describe "WxRunner show textctrl" do
51
+ it "TextCtrl show" do
52
+ r = WxRunner.on_wx_thread {Wx:: TextCtrl.show}
53
+ r.class.should == Wx:: TextCtrl
54
+ WxRunner.on_wx_thread {r.parent.close}
55
+ end
56
+ end
57
+
58
+ == License
59
+
60
+ WxRunner is released under the MIT license.
61
+
62
+ = WxRunner
63
+
64
+ 以下の目的で使用するために作成
65
+ * wxruby アプリでスレッドを使う
66
+ * wxruby アプリの spec
67
+ * 非トップレベルウインドウのプレビュー(テキストコントロールや、リストビュー等)
68
+
69
+ == Install
70
+
71
+ gem install wx_runner
72
+
73
+ == Useage
74
+
75
+ 1. ウインドウクラスでの run
76
+ require 'wx'
77
+ require 'wx_ruuner'
78
+ TextCtrl.run
79
+
80
+ 2. ウインドウクラスでの show
81
+ require 'wx'
82
+ require 'wx_ruuner'
83
+ WxRunner.run do
84
+ TextCtrl.show
85
+ CheckBox.show
86
+ end
87
+
88
+ 3. スレッド処理
89
+ ruby のスレッドを通常通り使えます。
90
+
91
+ 4. スレッド越しのアクセス
92
+ require 'wx'
93
+ require 'wx_ruuner'
94
+ WxRunner.run do
95
+ @text = TextCtrl.show
96
+ CheckBox.show
97
+ Thread.new
98
+ str = WxRunner.on_wx_thread do
99
+ @text.label = "sample"
100
+ @text.label
101
+ end
102
+ end
103
+ end
104
+
105
+ 5. spec 自動試験
106
+ require 'wx'
107
+ require 'wx_ruuner'
108
+
109
+ WxRunner.run_thread
110
+
111
+ describe "WxRunner show textctrl" do
112
+ it "TextCtrl show" do
113
+ r = WxRunner.on_wx_thread { Wx::TextCtrl.show }
114
+ r.class.should == Wx::TextCtrl
115
+ WxRunner.on_wx_thread { r.parent.close }
116
+ end
117
+ end
118
+
119
+ == License
120
+
121
+ WxRunner is released under the MIT license.
data/Thorfile ADDED
@@ -0,0 +1,19 @@
1
+ #!rspec
2
+ require 'thor/rake_compat'
3
+ require 'bundler'
4
+
5
+ class Default < Thor
6
+ include Thor::RakeCompat
7
+ Bundler::GemHelper.install_tasks
8
+
9
+ desc "spec", "rspec �������s"
10
+ def spec
11
+ exec("rspec spec/*_spec.rb")
12
+ end
13
+
14
+ desc "autospec", "�����e�X�g"
15
+ def autospec
16
+ system("start prspecd spec/.prspecd")
17
+ system("start watchr spec/watchr")
18
+ end
19
+ end
data/lib/wx_runner.rb ADDED
@@ -0,0 +1,104 @@
1
+ require 'wx'
2
+ require 'thread'
3
+
4
+ module WxRunner extend self
5
+ # &block - ����������������ɌĂяo�����B App �N���X�C���X�^���X���n����܂��B
6
+ def run(&block)
7
+ # app �N���X��ێ����Ă����Ȃ��ƁAsegfalt
8
+ # ./wxutils/app.rb:11: [BUG] rb_gc_mark(): unknown data type 0x0(0x66c200fc) non object
9
+ @app = App.new
10
+ @app.at_exit = @at_exit
11
+ if @init_wait_queue
12
+ @app.block = Proc.new { block.call if block; @init_wait_queue.push(1) }
13
+ else
14
+ @app.block = block
15
+ end
16
+ @app.main_loop
17
+ end
18
+
19
+ # �ʃX���b�h�� wx ���b�Z�[�W���[�v�����s
20
+ def run_thread(&block)
21
+ @init_wait_queue = SizedQueue.new(1)
22
+ Thread.new do
23
+ begin
24
+ self.run(&block)
25
+ rescue Exception
26
+ puts $!.message
27
+ puts $!.backtrace
28
+ end
29
+ end
30
+ @init_wait_queue.pop
31
+ end
32
+
33
+ # wx ���b�Z�[�W�X���b�h�ŏ��������s����
34
+ def on_wx_thread(&block)
35
+ @app.on_wx_thread_proc_queue << {:proc => block.to_proc, :queue => q = Queue.new}
36
+ q.pop
37
+ end
38
+
39
+ # wx ���b�Z�[�W�X���b�h�ŏ��������s����
40
+ # �񓯊����s
41
+ def on_wx_thread_async(&block)
42
+ @app.on_wx_thread_proc_queue << {:proc => block.to_proc, :queue => q = Queue.new}
43
+ end
44
+
45
+ class App < ::Wx::App
46
+ attr_accessor :block, :main_wnd_class, :at_exit, :on_wx_thread_proc_queue
47
+ def initialize(*arg)
48
+ super
49
+ @on_wx_thread_proc_queue = Queue.new
50
+ end
51
+ def on_init
52
+ # wxRuby �ŃX���b�h���g�p���邽��
53
+ t = Wx::Timer.new(self, 55)
54
+ evt_timer(55) do
55
+ sleep(0.05)
56
+ if not @on_wx_thread_proc_queue.empty?
57
+ i = @on_wx_thread_proc_queue.pop
58
+ begin
59
+ i[:queue].push i[:proc].call
60
+ rescue Exception
61
+ i[:queue].push $!
62
+ end
63
+ end
64
+ end
65
+ t.start(100)
66
+
67
+ if @main_wnd_class
68
+ set_top_window( @main_wnd_class.new(nil) )
69
+ get_top_window.show
70
+ end
71
+ if @block
72
+ @block.call(self)
73
+ end
74
+ return true
75
+ end
76
+ end
77
+ end
78
+
79
+ class Wx::Window
80
+ def self.run(*arg, &block)
81
+ WxRunner::App.run { self.show(*arg, &block) }
82
+ end
83
+
84
+ def self.show(*arg, &block)
85
+ top, me = self.new_top_window(nil, *arg)
86
+ top.show
87
+ block.call(me) if block
88
+ return me
89
+ end
90
+
91
+ # �ŏ�ʔz�u�”\�ȃE�C���h�E�𐶐��B
92
+ # �Q�l��Ԃ��B
93
+ # [ �g�b�v���x���E�C���h�E, ��������self�N���X�̃C���X�^���X]
94
+ def self.new_top_window(parent=nil, *arg)
95
+ if self.ancestors.include? Wx::TopLevelWindow
96
+ me = self.new(parent, *arg)
97
+ return me,me
98
+ else
99
+ frame = Wx::Frame.new(parent, :title => "class : #{self}")
100
+ me = self.new(frame, *arg)
101
+ return frame, me
102
+ end
103
+ end
104
+ end
@@ -0,0 +1,3 @@
1
+ module WxRunner
2
+ VERSION = "0.0.1"
3
+ end
data/spec/.prspecd ADDED
@@ -0,0 +1,14 @@
1
+ prefetch {
2
+ require 'pathname'
3
+ ENV["PRSPEC"] = 'true'
4
+ ENV["RAILS_ENV"] ||= 'test'
5
+ require 'rspec'
6
+ require 'rubygems'
7
+ require 'wx'
8
+ }
9
+
10
+ before_run {
11
+ }
12
+
13
+ after_run {
14
+ }
data/spec/watchr ADDED
@@ -0,0 +1,2 @@
1
+ watch('lib/(.*)\.rb$'){|m| system "prspec spec/*_spec.rb" }
2
+ watch('spec/(.*)\.rb$'){|m| system "prspec spec/*.rb" }
@@ -0,0 +1,21 @@
1
+ #!rspec
2
+ require "wx_runner"
3
+ require 'thread'
4
+
5
+ WxRunner.run_thread
6
+ # ���C����ʂ͕\������Ă��Ȃ��ƁA���b�Z�[�W���[�v���I�����Ă��܂��B
7
+ main_wnd = WxRunner.on_wx_thread { Wx::TextCtrl.show }
8
+
9
+ describe "WxRunner show textctrl" do
10
+ it "TextCtrl show" do
11
+ r = WxRunner.on_wx_thread { Wx::TextCtrl.show }
12
+ r.class.should == Wx::TextCtrl
13
+ WxRunner.on_wx_thread { r.parent.close }
14
+ end
15
+
16
+ it "Checkbox show" do
17
+ r = WxRunner.on_wx_thread { Wx::CheckBox.show }
18
+ r.class.should == Wx::CheckBox
19
+ WxRunner.on_wx_thread { r.parent.close }
20
+ end
21
+ end
data/wx_runner.gemspec ADDED
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "wx_runner/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "wx_runner"
7
+ s.version = WxRunner::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["drvo"]
10
+ s.email = ["drvo.gm@gmail.com"]
11
+ s.homepage = ""
12
+ s.summary = %q{Easy access wxruby message loop} # wx ruby run assistance program
13
+ s.description = %q{Wxruby app using threads
14
+ Wxruby spec app
15
+ preview of non-top-level window (or text controls, list views, etc.)} # wx ruby program, support for running the main loop of another thread. Window class run, show added.
16
+
17
+ s.rubyforge_project = "wx_runner"
18
+
19
+ s.files = `git ls-files`.split("\n")
20
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
21
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
22
+ s.require_paths = ["lib"]
23
+ end
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wx_runner
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - drvo
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-04-21 00:00:00 +09:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: |-
23
+ Wxruby app using threads
24
+ Wxruby spec app
25
+ preview of non-top-level window (or text controls, list views, etc.)
26
+ email:
27
+ - drvo.gm@gmail.com
28
+ executables: []
29
+
30
+ extensions: []
31
+
32
+ extra_rdoc_files: []
33
+
34
+ files:
35
+ - .gitignore
36
+ - Gemfile
37
+ - README.rdoc
38
+ - Thorfile
39
+ - lib/wx_runner.rb
40
+ - lib/wx_runner/version.rb
41
+ - spec/.prspecd
42
+ - spec/watchr
43
+ - spec/wx_runner_spec.rb
44
+ - wx_runner.gemspec
45
+ has_rdoc: true
46
+ homepage: ""
47
+ licenses: []
48
+
49
+ post_install_message:
50
+ rdoc_options: []
51
+
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ hash: 3
60
+ segments:
61
+ - 0
62
+ version: "0"
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ hash: 3
69
+ segments:
70
+ - 0
71
+ version: "0"
72
+ requirements: []
73
+
74
+ rubyforge_project: wx_runner
75
+ rubygems_version: 1.6.2
76
+ signing_key:
77
+ specification_version: 3
78
+ summary: Easy access wxruby message loop
79
+ test_files: []
80
+