loquat 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/Gemfile +10 -0
- data/README +15 -0
- data/Rakefile +1 -0
- data/bin/loquat +3 -0
- data/lib/loquat/bat.rb +47 -0
- data/lib/loquat/boot.erb +54 -0
- data/lib/loquat/cli.rb +40 -0
- data/lib/loquat/version.rb +3 -0
- data/lib/loquat/wx.rb +71 -0
- data/lib/loquat.rb +5 -0
- data/loquat.gemspec +32 -0
- metadata +90 -0
data/Gemfile
ADDED
data/README
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
* About
|
2
|
+
|
3
|
+
wxruby script から exe への変換をサポート
|
4
|
+
exerb が必要
|
5
|
+
exerb で exe に変換する際に問題となる gem 利用を程度解決
|
6
|
+
GUI実行時のDOS画面非表示化
|
7
|
+
Exception 発生時に再表示
|
8
|
+
|
9
|
+
* About
|
10
|
+
|
11
|
+
Supports conversion from wxruby script to exe
|
12
|
+
Need exerb
|
13
|
+
solve a problem about the use of gem when converting to exe by exerb
|
14
|
+
Hiding the DOS window when running GUI
|
15
|
+
Reappear when an Exception
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
data/bin/loquat
ADDED
data/lib/loquat/bat.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# -*- encoding: UTF-8 -*-
|
2
|
+
|
3
|
+
require 'tempfile'
|
4
|
+
require 'kconv'
|
5
|
+
|
6
|
+
module Bat extend self
|
7
|
+
def exec(src, &block)
|
8
|
+
file, line = *caller(1)[0].match(/(.+):(\d+)/).to_a[1..-1]
|
9
|
+
file = File.expand_path(file)
|
10
|
+
line = line.to_i + 1
|
11
|
+
|
12
|
+
# 全部の行に、エラーだったら終了するよう処理を追加
|
13
|
+
next_noerror = false
|
14
|
+
src_map = src.each_line.with_index.map do |s,i|
|
15
|
+
if s.match(/^\s$/)
|
16
|
+
s
|
17
|
+
elsif s.match(/^\s*(rem\s+|::)skip_error/)
|
18
|
+
next_noerror = true
|
19
|
+
s
|
20
|
+
elsif next_noerror
|
21
|
+
next_noerror = false
|
22
|
+
s
|
23
|
+
else
|
24
|
+
ret = <<-EOSA
|
25
|
+
#{s}
|
26
|
+
@if %errorlevel% == 9009 if NOT "%no_error_break%" == "1" echo You do not have #{s.match(/\w+/).to_a[0]} in your PATH. && exit
|
27
|
+
@if errorlevel 1 if NOT "%no_error_break%" == "1" echo #{file}(#{line + i}): #{s.gsub("\n", "").gsub(/\&/, "\\&")} && echo if you write comment ** "::skip_error" or "rem skip_error" ** to not error stop && exit
|
28
|
+
@set error_no_break=0
|
29
|
+
EOSA
|
30
|
+
end
|
31
|
+
end
|
32
|
+
src = src_map.join
|
33
|
+
Tempfile.open(["", ".bat"]) do |f|
|
34
|
+
f.puts src.tosjis
|
35
|
+
f.close
|
36
|
+
system("#{f.path} 2>&1")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
if __FILE__ == $0
|
42
|
+
Bat.exec <<-'EOS'
|
43
|
+
rem @echo off
|
44
|
+
cd L:\Work\MG3710IQPro\Develop
|
45
|
+
dir
|
46
|
+
EOS
|
47
|
+
end
|
data/lib/loquat/boot.erb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
#!ruby -Ku
|
2
|
+
# -*- encoding: UTF-8 -*-
|
3
|
+
|
4
|
+
require 'Win32API' #exerb に含ませる必要がある
|
5
|
+
|
6
|
+
# gui向けに画面を消去
|
7
|
+
# http://loquat-wxruby.blogspot.com/2011/10/ruby-gui.html
|
8
|
+
get_console_window = Win32API.new("kernel32" , "GetConsoleWindow" , [] , 'L')
|
9
|
+
show_window = Win32API.new( "user32" , "ShowWindow" , ['p' , 'i'] , 'i' )
|
10
|
+
hwnd = get_console_window.call()
|
11
|
+
|
12
|
+
# 実際に消去するのは exe 化されている時だけ
|
13
|
+
show_window.call( hwnd , 0 ) if $Exerb
|
14
|
+
|
15
|
+
# 単体実行のためのファイル
|
16
|
+
|
17
|
+
# mkexy 向け処理
|
18
|
+
# ファイルフルパス指定しているgemがいると、mkexy で作成されるレシピファイルで問題になる
|
19
|
+
module Kernel
|
20
|
+
alias require_old require
|
21
|
+
def require(path)
|
22
|
+
new_path = path
|
23
|
+
if $Exerb
|
24
|
+
return if !path or path.match(/rubygems/) # exerb での実行時は rubygems 使わない
|
25
|
+
|
26
|
+
# フルパス変換してrequireしている gems 用に、exerbパスになるよう置換
|
27
|
+
new_path = new_path.gsub(File.dirname(ExerbRuntime.filepath), "")
|
28
|
+
new_path = new_path.gsub(Dir.pwd + "/", "")
|
29
|
+
new_path = new_path.gsub("./", "")
|
30
|
+
else
|
31
|
+
new_path = path.gsub(/c:.*\/1\.8\/gems\/.*lib\//i, "")
|
32
|
+
end
|
33
|
+
|
34
|
+
# 置換された場合の確認処理( デバッグ用 )
|
35
|
+
# p [new_path, path] if path != new_path
|
36
|
+
|
37
|
+
# 実際の require 処理
|
38
|
+
require_old new_path
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# 不正落ちした場合には、画面を再度表示してエラーメッセージを確認できるようにする
|
43
|
+
begin
|
44
|
+
require "<%=src%>"
|
45
|
+
rescue Exception
|
46
|
+
puts $!.message
|
47
|
+
puts $!.backtrace
|
48
|
+
if $Exerb
|
49
|
+
show_window.call( hwnd , 1 )
|
50
|
+
puts ""
|
51
|
+
puts "press eny key to continue"
|
52
|
+
$stdin.gets
|
53
|
+
end
|
54
|
+
end
|
data/lib/loquat/cli.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# -*- encoding: UTF-8 -*-
|
2
|
+
|
3
|
+
require "rubygems"
|
4
|
+
require "thor"
|
5
|
+
require "loquat/bat"
|
6
|
+
require "yaml"
|
7
|
+
require "fileutils"
|
8
|
+
require "erb"
|
9
|
+
|
10
|
+
class LoquatCli < Thor
|
11
|
+
namespace :loquat
|
12
|
+
|
13
|
+
desc "build src", "exe化"
|
14
|
+
def build(src)
|
15
|
+
# *.rb と同名の * ファイルを作成し、そこから起動する。
|
16
|
+
# example.rb => example, example.exy
|
17
|
+
# 同名の * ファイルの中身は起動に必要な処理
|
18
|
+
exy = src.sub(/\..*/, ".exy")
|
19
|
+
boot = src.sub(/\..*/, "")
|
20
|
+
|
21
|
+
boot_src = File.expand_path( File.join(__FILE__, "..", "boot.erb") )
|
22
|
+
open(boot, "w"){ |f| f.print ERB.new(IO.read(boot_src)).result(binding) }
|
23
|
+
|
24
|
+
Bat.exec <<-EOS
|
25
|
+
call mkexy #{boot} #{src}
|
26
|
+
call loquat execlude_rubygems #{exy}
|
27
|
+
call exerb #{exy}
|
28
|
+
del #{boot}
|
29
|
+
EOS
|
30
|
+
end
|
31
|
+
|
32
|
+
desc "execlude_rubygems", "exy ファイルから rubygems 関連のファイルを抜く"
|
33
|
+
def execlude_rubygems(exy)
|
34
|
+
h = YAML.load_file exy
|
35
|
+
h["file"].reject!{|k,v| k.match(/^rubygems/) }
|
36
|
+
open(exy,"w"){|f| f.print YAML.dump(h) }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
LoquatCli.start
|
data/lib/loquat/wx.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
# -*- encoding: UTF-8 -*-
|
2
|
+
# exerb で実行ファイル作成する場合、すべてのファイルを直接指定する必要がある。
|
3
|
+
require 'wx'
|
4
|
+
|
5
|
+
require 'wx/classes/evthandler.rb'
|
6
|
+
require 'wx/classes/acceleratortable.rb'
|
7
|
+
require 'wx/classes/animation.rb'
|
8
|
+
require 'wx/classes/app.rb'
|
9
|
+
require 'wx/classes/artprovider.rb'
|
10
|
+
require 'wx/classes/auinotebook.rb'
|
11
|
+
require 'wx/classes/bitmap.rb'
|
12
|
+
require 'wx/classes/busycursor.rb'
|
13
|
+
require 'wx/classes/checklistbox.rb'
|
14
|
+
require 'wx/classes/choice.rb'
|
15
|
+
require 'wx/classes/clientdc.rb'
|
16
|
+
require 'wx/classes/clipboard.rb'
|
17
|
+
require 'wx/classes/colour.rb'
|
18
|
+
require 'wx/classes/combobox.rb'
|
19
|
+
require 'wx/classes/commandevent.rb'
|
20
|
+
require 'wx/classes/controlwithitems.rb'
|
21
|
+
require 'wx/classes/dataformat.rb'
|
22
|
+
require 'wx/classes/data_object.rb'
|
23
|
+
require 'wx/classes/data_object_simple.rb'
|
24
|
+
require 'wx/classes/dc.rb'
|
25
|
+
require 'wx/classes/event.rb'
|
26
|
+
require 'wx/classes/evthandler.rb'
|
27
|
+
require 'wx/classes/font.rb'
|
28
|
+
require 'wx/classes/functions.rb'
|
29
|
+
require 'wx/classes/gauge.rb'
|
30
|
+
require 'wx/classes/genericdirctrl.rb'
|
31
|
+
require 'wx/classes/grid.rb'
|
32
|
+
require 'wx/classes/hboxsizer.rb'
|
33
|
+
require 'wx/classes/helpcontroller.rb'
|
34
|
+
require 'wx/classes/helpcontrollerhelpprovider.rb'
|
35
|
+
require 'wx/classes/helpprovider.rb'
|
36
|
+
require 'wx/classes/htmlhelpcontroller.rb'
|
37
|
+
require 'wx/classes/htmlwindow.rb'
|
38
|
+
require 'wx/classes/icon.rb'
|
39
|
+
require 'wx/classes/iconbundle.rb'
|
40
|
+
require 'wx/classes/image.rb'
|
41
|
+
require 'wx/classes/imagelist.rb'
|
42
|
+
require 'wx/classes/listbox.rb'
|
43
|
+
require 'wx/classes/listctrl.rb'
|
44
|
+
require 'wx/classes/locale.rb'
|
45
|
+
require 'wx/classes/mediactrl.rb'
|
46
|
+
require 'wx/classes/menu.rb'
|
47
|
+
require 'wx/classes/menuitem.rb'
|
48
|
+
require 'wx/classes/notebook.rb'
|
49
|
+
require 'wx/classes/object.rb'
|
50
|
+
require 'wx/classes/paintdc.rb'
|
51
|
+
require 'wx/classes/point.rb'
|
52
|
+
require 'wx/classes/previewframe.rb'
|
53
|
+
require 'wx/classes/rect.rb'
|
54
|
+
require 'wx/classes/richtextctrl.rb'
|
55
|
+
require 'wx/classes/simplehelpprovider.rb'
|
56
|
+
require 'wx/classes/size.rb'
|
57
|
+
require 'wx/classes/sizer.rb'
|
58
|
+
require 'wx/classes/sound.rb'
|
59
|
+
require 'wx/classes/splitterwindow.rb'
|
60
|
+
require 'wx/classes/standardpaths.rb'
|
61
|
+
require 'wx/classes/styledtextctrl.rb'
|
62
|
+
require 'wx/classes/textctrl.rb'
|
63
|
+
require 'wx/classes/texturlevent.rb'
|
64
|
+
require 'wx/classes/timer.rb'
|
65
|
+
require 'wx/classes/toolbar.rb'
|
66
|
+
require 'wx/classes/toolbartool.rb'
|
67
|
+
require 'wx/classes/treectrl.rb'
|
68
|
+
require 'wx/classes/validator.rb'
|
69
|
+
require 'wx/classes/vboxsizer.rb'
|
70
|
+
require 'wx/classes/window.rb'
|
71
|
+
require 'wx/classes/xmlresource.rb'
|
data/lib/loquat.rb
ADDED
data/loquat.gemspec
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "loquat/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "loquat"
|
7
|
+
s.version = Loquat::VERSION
|
8
|
+
s.authors = ["drvo"]
|
9
|
+
s.email = ["drvo.gm@gmail.com"]
|
10
|
+
s.homepage = "http://www35150u.sakura.ne.jp/redmine/projects/loquat"
|
11
|
+
s.summary = %q{Supports conversion from wxruby script to exe}
|
12
|
+
s.description = <<EOS
|
13
|
+
wxruby script から exe への変換をサポート
|
14
|
+
exerb が必要
|
15
|
+
exerb で exe に変換する際に問題となる gem 利用を程度解決
|
16
|
+
GUI実行時のDOS画面非表示化
|
17
|
+
Exception 発生時に再表示
|
18
|
+
|
19
|
+
Supports conversion from wxruby script to exe
|
20
|
+
Need exerb
|
21
|
+
solve a problem about the use of gem when converting to exe by exerb
|
22
|
+
Hiding the DOS window when running GUI
|
23
|
+
Reappear when an Exception
|
24
|
+
EOS
|
25
|
+
|
26
|
+
s.rubyforge_project = "loquat"
|
27
|
+
|
28
|
+
s.files = `git ls-files`.split("\n")
|
29
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
30
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
31
|
+
s.require_paths = ["lib"]
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: loquat
|
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-11-22 00:00:00 +09:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: !binary |
|
23
|
+
d3hydWJ5IHNjcmlwdCDjgYvjgokgZXhlIOOBuOOBruWkieaPm+OCkuOCteOD
|
24
|
+
neODvOODiApleGVyYiDjgYzlv4XopoEKZXhlcmIg44GnIGV4ZSDjgavlpInm
|
25
|
+
j5vjgZnjgovpmpvjgavllY/poYzjgajjgarjgosgZ2VtIOWIqeeUqOOCkueo
|
26
|
+
i+W6puino+axugpHVUnlrp/ooYzmmYLjga5ET1PnlLvpnaLpnZ7ooajnpLrl
|
27
|
+
jJYKRXhjZXB0aW9uIOeZuueUn+aZguOBq+WGjeihqOekugoKU3VwcG9ydHMg
|
28
|
+
Y29udmVyc2lvbiBmcm9tIHd4cnVieSBzY3JpcHQgdG8gZXhlCk5lZWQgZXhl
|
29
|
+
cmIKc29sdmUgYSBwcm9ibGVtIGFib3V0IHRoZSB1c2Ugb2YgZ2VtIHdoZW4g
|
30
|
+
Y29udmVydGluZyB0byBleGUgYnkgZXhlcmIKSGlkaW5nIHRoZSBET1Mgd2lu
|
31
|
+
ZG93IHdoZW4gcnVubmluZyBHVUkKUmVhcHBlYXIgd2hlbiBhbiBFeGNlcHRp
|
32
|
+
b24K
|
33
|
+
|
34
|
+
email:
|
35
|
+
- drvo.gm@gmail.com
|
36
|
+
executables:
|
37
|
+
- loquat
|
38
|
+
extensions: []
|
39
|
+
|
40
|
+
extra_rdoc_files: []
|
41
|
+
|
42
|
+
files:
|
43
|
+
- .gitignore
|
44
|
+
- Gemfile
|
45
|
+
- README
|
46
|
+
- Rakefile
|
47
|
+
- bin/loquat
|
48
|
+
- lib/loquat.rb
|
49
|
+
- lib/loquat/bat.rb
|
50
|
+
- lib/loquat/boot.erb
|
51
|
+
- lib/loquat/cli.rb
|
52
|
+
- lib/loquat/version.rb
|
53
|
+
- lib/loquat/wx.rb
|
54
|
+
- loquat.gemspec
|
55
|
+
has_rdoc: true
|
56
|
+
homepage: http://www35150u.sakura.ne.jp/redmine/projects/loquat
|
57
|
+
licenses: []
|
58
|
+
|
59
|
+
post_install_message:
|
60
|
+
rdoc_options: []
|
61
|
+
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
hash: 3
|
70
|
+
segments:
|
71
|
+
- 0
|
72
|
+
version: "0"
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
hash: 3
|
79
|
+
segments:
|
80
|
+
- 0
|
81
|
+
version: "0"
|
82
|
+
requirements: []
|
83
|
+
|
84
|
+
rubyforge_project: loquat
|
85
|
+
rubygems_version: 1.6.2
|
86
|
+
signing_key:
|
87
|
+
specification_version: 3
|
88
|
+
summary: Supports conversion from wxruby script to exe
|
89
|
+
test_files: []
|
90
|
+
|