lustr-core 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/Manifest.txt +20 -0
- data/README.txt +8 -0
- data/Rakefile +93 -0
- data/lib/lustr.rb +17 -0
- data/lib/lustr/blank_slate.rb +33 -0
- data/lib/lustr/builder.rb +117 -0
- data/lib/lustr/controller.rb +29 -0
- data/lib/lustr/defaults.rb +67 -0
- data/lib/lustr/dsl.rb +52 -0
- data/lib/lustr/engine.rb +59 -0
- data/lib/lustr/eval_context.rb +45 -0
- data/lib/lustr/gadget.rb +103 -0
- data/lib/lustr/generator.rb +81 -0
- data/lib/lustr/parse_context.rb +58 -0
- data/lib/lustr/runtime.rb +41 -0
- data/lib/lustr/version.rb +24 -0
- data/lib/lustr/widget.rb +103 -0
- data/scripts/txt2html +67 -0
- data/setup.rb +1585 -0
- metadata +73 -0
data/History.txt
ADDED
data/Manifest.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
History.txt
|
2
|
+
Manifest.txt
|
3
|
+
README.txt
|
4
|
+
Rakefile
|
5
|
+
lib/lustr/blank_slate.rb
|
6
|
+
lib/lustr/builder.rb
|
7
|
+
lib/lustr/controller.rb
|
8
|
+
lib/lustr/defaults.rb
|
9
|
+
lib/lustr/dsl.rb
|
10
|
+
lib/lustr/engine.rb
|
11
|
+
lib/lustr/eval_context.rb
|
12
|
+
lib/lustr/gadget.rb
|
13
|
+
lib/lustr/generator.rb
|
14
|
+
lib/lustr/parse_context.rb
|
15
|
+
lib/lustr.rb
|
16
|
+
lib/lustr/runtime.rb
|
17
|
+
lib/lustr/version.rb
|
18
|
+
lib/lustr/widget.rb
|
19
|
+
scripts/txt2html
|
20
|
+
setup.rb
|
data/README.txt
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
Lustr is a Ruby DSL for GUI development. Write a Lustr GUI once, and you can:
|
2
|
+
|
3
|
+
- Run it with Ruby controllers on the desktop, using wxRuby, on all major operating systems, including Linux, OS X, and many versions of Windows
|
4
|
+
- Use the same Ruby controllers and run it in a JVM using JRuby and Swing
|
5
|
+
- Run a code generator to convert the UI to Flex/MXML or XUL, to tie into your ActionScript or Javascript controllers
|
6
|
+
|
7
|
+
More details on Lustr can be found at {Lustr's home page}[http://www.codecorps.org/moinmoin/index.cgi/Lustr]
|
8
|
+
or on the {RubyForge}[http://rubyforge.org/projects/lustr] site.
|
data/Rakefile
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'rake/clean'
|
4
|
+
require 'rake/testtask'
|
5
|
+
require 'rake/packagetask'
|
6
|
+
require 'rake/gempackagetask'
|
7
|
+
require 'rake/rdoctask'
|
8
|
+
require 'rake/contrib/rubyforgepublisher'
|
9
|
+
require 'fileutils'
|
10
|
+
require 'hoe'
|
11
|
+
include FileUtils
|
12
|
+
require File.join(File.dirname(__FILE__), 'lib', 'lustr', 'version')
|
13
|
+
|
14
|
+
AUTHOR = 'Mark Murphy' # can also be an array of Authors
|
15
|
+
EMAIL = "mmurphy@municorps.org"
|
16
|
+
DESCRIPTION = "Lustr core engine for Ruby GUI/RIA development"
|
17
|
+
GEM_NAME = 'lustr-core' # what ppl will type to install your gem
|
18
|
+
RUBYFORGE_PROJECT = 'lustr' # The unix name for your project
|
19
|
+
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
|
20
|
+
DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
|
21
|
+
|
22
|
+
NAME = "lustr-core"
|
23
|
+
REV = nil # UNCOMMENT IF REQUIRED: File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
|
24
|
+
VERS = Lustr::VERSION::STRING + (REV ? ".#{REV}" : "")
|
25
|
+
CLEAN.include ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store']
|
26
|
+
RDOC_OPTS = ['--quiet', '--title', 'lustr-core documentation',
|
27
|
+
"--opname", "index.html",
|
28
|
+
"--line-numbers",
|
29
|
+
"--main", "README",
|
30
|
+
"--inline-source"]
|
31
|
+
|
32
|
+
class Hoe
|
33
|
+
def extra_deps
|
34
|
+
@extra_deps.reject { |x| Array(x).first == 'hoe' }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# Generate all the Rake tasks
|
39
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
40
|
+
hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
41
|
+
p.author = AUTHOR
|
42
|
+
p.description = DESCRIPTION
|
43
|
+
p.email = EMAIL
|
44
|
+
p.summary = DESCRIPTION
|
45
|
+
p.url = HOMEPATH
|
46
|
+
p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
|
47
|
+
p.test_globs = ["test/**/test_*.rb"]
|
48
|
+
p.clean_globs = CLEAN #An array of file patterns to delete on clean.
|
49
|
+
|
50
|
+
# == Optional
|
51
|
+
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
52
|
+
p.extra_deps = [['builder', '>=2.1.1']] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
|
53
|
+
#p.spec_extras = {} # A hash of extra values to set in the gemspec.
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
desc 'Generate website files'
|
58
|
+
task :website_generate do
|
59
|
+
Dir['website/**/*.txt'].each do |txt|
|
60
|
+
sh %{ ruby scripts/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
desc 'Upload website files to rubyforge'
|
65
|
+
task :website_upload do
|
66
|
+
config = YAML.load(File.read(File.expand_path("~/.rubyforge/user-config.yml")))
|
67
|
+
host = "#{config["username"]}@rubyforge.org"
|
68
|
+
remote_dir = "/var/www/gforge-projects/#{RUBYFORGE_PROJECT}/"
|
69
|
+
# remote_dir = "/var/www/gforge-projects/#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
|
70
|
+
local_dir = 'website'
|
71
|
+
sh %{rsync -av #{local_dir}/ #{host}:#{remote_dir}}
|
72
|
+
end
|
73
|
+
|
74
|
+
desc 'Generate and upload website files'
|
75
|
+
task :website => [:website_generate, :website_upload]
|
76
|
+
|
77
|
+
desc 'Release the website and new gem version'
|
78
|
+
task :deploy => [:check_version, :website, :release]
|
79
|
+
|
80
|
+
desc 'Runs tasks website_generate and install_gem as a local deployment of the gem'
|
81
|
+
task :local_deploy => [:website_generate, :install_gem]
|
82
|
+
|
83
|
+
task :check_version do
|
84
|
+
unless ENV['VERSION']
|
85
|
+
puts 'Must pass a VERSION=x.y.z release version'
|
86
|
+
exit
|
87
|
+
end
|
88
|
+
unless ENV['VERSION'] == VERS
|
89
|
+
puts "Please update your version.rb to match the release version, currently #{VERS}"
|
90
|
+
exit
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
data/lib/lustr.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
=begin
|
2
|
+
This file is part of Lustr (http://rubyforge.org/projects/lustr).
|
3
|
+
|
4
|
+
Copyright (c) 2007 Mark L. Murphy.
|
5
|
+
|
6
|
+
Lustr is free software; you can redistribute it and/or modify it under the
|
7
|
+
terms of the GNU General Public License as published by the Free Software
|
8
|
+
Foundation; either version 2 of the License.
|
9
|
+
|
10
|
+
Lustr is distributed in the hope that it will be useful, but WITHOUT ANY
|
11
|
+
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
12
|
+
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
13
|
+
details. This file is included in the Ruby gem as License.txt.
|
14
|
+
=end
|
15
|
+
|
16
|
+
path=File::join(File::dirname(__FILE__), 'lustr')
|
17
|
+
Dir[path+'/*.rb'].sort.each {|f| require f if !File.directory?(f)}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
=begin
|
2
|
+
This file is part of Lustr (http://rubyforge.org/projects/lustr).
|
3
|
+
|
4
|
+
Copyright (c) 2007 Mark L. Murphy.
|
5
|
+
|
6
|
+
Lustr is free software; you can redistribute it and/or modify it under the
|
7
|
+
terms of the GNU General Public License as published by the Free Software
|
8
|
+
Foundation; either version 2 of the License.
|
9
|
+
|
10
|
+
Lustr is distributed in the hope that it will be useful, but WITHOUT ANY
|
11
|
+
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
12
|
+
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
13
|
+
details. This file is included in the Ruby gem as License.txt.
|
14
|
+
=end
|
15
|
+
|
16
|
+
module Lustr
|
17
|
+
|
18
|
+
=begin rdoc
|
19
|
+
This is a "blank slate" class, styled after the BlankSlate documented at
|
20
|
+
http://onestepback.org/index.cgi/Tech/Ruby/BlankSlate.rdoc. It is used as the
|
21
|
+
superclass for the DSL and eliminates as many of the intrinsic Object methods
|
22
|
+
as possible to minimize collision with possible widget and gadget names.
|
23
|
+
=end
|
24
|
+
|
25
|
+
class BlankSlate
|
26
|
+
instance_methods.each { |m| undef_method(m) unless %w(
|
27
|
+
__send__ __id__ send class require
|
28
|
+
inspect instance_eval instance_variables respond_to? kind_of?
|
29
|
+
).include?(m)
|
30
|
+
}
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
@@ -0,0 +1,117 @@
|
|
1
|
+
=begin
|
2
|
+
This file is part of Lustr (http://rubyforge.org/projects/lustr).
|
3
|
+
|
4
|
+
Copyright (c) 2007 Mark L. Murphy.
|
5
|
+
|
6
|
+
Lustr is free software; you can redistribute it and/or modify it under the
|
7
|
+
terms of the GNU General Public License as published by the Free Software
|
8
|
+
Foundation; either version 2 of the License.
|
9
|
+
|
10
|
+
Lustr is distributed in the hope that it will be useful, but WITHOUT ANY
|
11
|
+
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
12
|
+
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
13
|
+
details. This file is included in the Ruby gem as License.txt.
|
14
|
+
=end
|
15
|
+
|
16
|
+
module Lustr
|
17
|
+
|
18
|
+
=begin rdoc
|
19
|
+
BuilderBase is the base class of all builders used in toolkits. A "builder"
|
20
|
+
takes the definition from the DSL and creates a widget instance (runtime) or
|
21
|
+
generates the appropriate UI source code (generative). The norm is for builders
|
22
|
+
to be subclasses of BuilderBase and declared through <tt>Lustr.declare()</tt>.
|
23
|
+
=end
|
24
|
+
|
25
|
+
class BuilderBase
|
26
|
+
attr_reader :children, :event_handlers, :name, :widget_type
|
27
|
+
attr_accessor :options
|
28
|
+
|
29
|
+
def initialize(widget_type, options={})
|
30
|
+
@widget_type=widget_type
|
31
|
+
@children=[]
|
32
|
+
@event_handlers={}
|
33
|
+
|
34
|
+
if widget_type
|
35
|
+
@options=Lustr.defaults(widget_type).merge(options)
|
36
|
+
else
|
37
|
+
@options=options
|
38
|
+
end
|
39
|
+
|
40
|
+
@name=self.options[:name]
|
41
|
+
end
|
42
|
+
|
43
|
+
def all_event_handlers
|
44
|
+
result=event_handlers
|
45
|
+
|
46
|
+
children.each do |child|
|
47
|
+
result.merge!(child.all_event_handlers)
|
48
|
+
end
|
49
|
+
|
50
|
+
return result
|
51
|
+
end
|
52
|
+
|
53
|
+
def <<(child)
|
54
|
+
children << child if child
|
55
|
+
end
|
56
|
+
|
57
|
+
def build_all(eval_context, parent_widget=nil)
|
58
|
+
widget=nil
|
59
|
+
|
60
|
+
if parent_widget
|
61
|
+
widget=build(parent_widget.resolve_parent)
|
62
|
+
else
|
63
|
+
widget=build(nil)
|
64
|
+
end
|
65
|
+
|
66
|
+
widget.init_options(options)
|
67
|
+
widget.name=options[:name]
|
68
|
+
widget.eval_context=eval_context
|
69
|
+
widget.gadget=eval_context.current_gadget
|
70
|
+
eval_context.current_gadget.widgets[widget.name]=widget if eval_context.current_gadget && widget.name
|
71
|
+
|
72
|
+
proc=lambda {
|
73
|
+
children.each do |child|
|
74
|
+
tree=child.build_all(eval_context, widget.resolve)
|
75
|
+
widget << tree
|
76
|
+
end
|
77
|
+
}
|
78
|
+
|
79
|
+
if widget.respond_to?(:init_block=)
|
80
|
+
widget.init_block=proc
|
81
|
+
elsif widget.kind_of?(Gadget)
|
82
|
+
eval_context.for_gadget(widget, proc)
|
83
|
+
else
|
84
|
+
proc.call
|
85
|
+
end
|
86
|
+
|
87
|
+
return widget
|
88
|
+
end
|
89
|
+
|
90
|
+
def dup_from(options)
|
91
|
+
self.class.new(widget_type, options)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
=begin rdoc
|
96
|
+
SimpleBuilder handles the really simple case where a builder simply instantiates
|
97
|
+
some widget class. Then, rather than having to create custom builder subclasses
|
98
|
+
for each widget class, you can simply <tt>Lustr.declare()</tt> an instance of SimpleBuilder
|
99
|
+
with the appropriate widget class as a parameter.
|
100
|
+
=end
|
101
|
+
|
102
|
+
class SimpleBuilder < BuilderBase
|
103
|
+
def initialize(widget_type, klass, options={})
|
104
|
+
super(widget_type, options)
|
105
|
+
@widget_class=klass
|
106
|
+
end
|
107
|
+
|
108
|
+
def dup_from(options)
|
109
|
+
self.class.new(widget_type, @widget_class, options)
|
110
|
+
end
|
111
|
+
|
112
|
+
def build(parent_widget)
|
113
|
+
@widget_class.new
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
=begin
|
2
|
+
This file is part of Lustr (http://rubyforge.org/projects/lustr).
|
3
|
+
|
4
|
+
Copyright (c) 2007 Mark L. Murphy.
|
5
|
+
|
6
|
+
Lustr is free software; you can redistribute it and/or modify it under the
|
7
|
+
terms of the GNU General Public License as published by the Free Software
|
8
|
+
Foundation; either version 2 of the License.
|
9
|
+
|
10
|
+
Lustr is distributed in the hope that it will be useful, but WITHOUT ANY
|
11
|
+
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
12
|
+
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
13
|
+
details. This file is included in the Ruby gem as License.txt.
|
14
|
+
=end
|
15
|
+
|
16
|
+
module Lustr
|
17
|
+
module ControllerBase
|
18
|
+
attr_accessor :gadget
|
19
|
+
end
|
20
|
+
|
21
|
+
class NullController
|
22
|
+
include ControllerBase
|
23
|
+
|
24
|
+
def instance_eval(str)
|
25
|
+
eval(str)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
@@ -0,0 +1,67 @@
|
|
1
|
+
=begin
|
2
|
+
This file is part of Lustr (http://rubyforge.org/projects/lustr).
|
3
|
+
|
4
|
+
Copyright (c) 2007 Mark L. Murphy.
|
5
|
+
|
6
|
+
Lustr is free software; you can redistribute it and/or modify it under the
|
7
|
+
terms of the GNU General Public License as published by the Free Software
|
8
|
+
Foundation; either version 2 of the License.
|
9
|
+
|
10
|
+
Lustr is distributed in the hope that it will be useful, but WITHOUT ANY
|
11
|
+
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
12
|
+
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
13
|
+
details. This file is included in the Ruby gem as License.txt.
|
14
|
+
=end
|
15
|
+
|
16
|
+
module Lustr
|
17
|
+
module Defaults
|
18
|
+
def self.app
|
19
|
+
{:title=>'', :width=>640, :height=>480}
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.box
|
23
|
+
{:direction=>:vertical}
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.button
|
27
|
+
{:text=>'Click me!'}
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.divided_box
|
31
|
+
box
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.field
|
35
|
+
{:text=>''}
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.html_area
|
39
|
+
{:wordWrap=>false}
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.label
|
43
|
+
{:text=>''}
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.list
|
47
|
+
{:editable=>false}
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.tab_panel
|
51
|
+
{:label=>''}
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.text_area
|
55
|
+
{:editable=>true, :wordWrap=>false}
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.tree
|
59
|
+
{}
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.method_missing(sym, *parms)
|
63
|
+
{}
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
data/lib/lustr/dsl.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
=begin
|
2
|
+
This file is part of Lustr (http://rubyforge.org/projects/lustr).
|
3
|
+
|
4
|
+
Copyright (c) 2007 Mark L. Murphy.
|
5
|
+
|
6
|
+
Lustr is free software; you can redistribute it and/or modify it under the
|
7
|
+
terms of the GNU General Public License as published by the Free Software
|
8
|
+
Foundation; either version 2 of the License.
|
9
|
+
|
10
|
+
Lustr is distributed in the hope that it will be useful, but WITHOUT ANY
|
11
|
+
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
12
|
+
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
13
|
+
details. This file is included in the Ruby gem as License.txt.
|
14
|
+
=end
|
15
|
+
|
16
|
+
module Lustr
|
17
|
+
class DSL < BlankSlate
|
18
|
+
def self.add_dsl_method(*symbols)
|
19
|
+
symbols.each do |sym|
|
20
|
+
class_eval <<EOF
|
21
|
+
def #{sym}(options={})
|
22
|
+
@parse_context.add_builder(:#{sym}, options) { yield if block_given? }
|
23
|
+
end
|
24
|
+
EOF
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def initialize(parse_context, eval_context)
|
29
|
+
@parse_context=parse_context
|
30
|
+
@eval_context=eval_context
|
31
|
+
@involved=[]
|
32
|
+
end
|
33
|
+
|
34
|
+
def involve(path)
|
35
|
+
if !@involved.include?(path)
|
36
|
+
@involved << path
|
37
|
+
self.instance_eval(File.new(path).read, path)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def gadget(options)
|
42
|
+
builder=GadgetBuilder.new(options)
|
43
|
+
@parse_context.attach_builder(builder, options[:name]) { yield if block_given? }
|
44
|
+
Lustr.add_dsl_handler(options[:name].to_sym, builder)
|
45
|
+
end
|
46
|
+
|
47
|
+
def is_runtime?
|
48
|
+
@eval_context.is_runtime?
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|