glimmer-dsl-swt 0.5.6 → 0.6.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/RUBY_VERSION +1 -1
- data/VERSION +1 -1
- data/bin/girb +1 -1
- data/bin/glimmer +1 -1
- data/icons/scaffold_app.ico +0 -0
- data/icons/scaffold_app.png +0 -0
- data/lib/ext/glimmer/config.rb +5 -1
- data/lib/glimmer/Rakefile +5 -0
- data/lib/glimmer/dsl/swt/cursor_expression.rb +23 -0
- data/lib/glimmer/dsl/swt/dsl.rb +3 -0
- data/lib/glimmer/dsl/swt/font_expression.rb +26 -0
- data/lib/glimmer/dsl/swt/image_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/message_box_expression.rb +9 -1
- data/lib/glimmer/dsl/swt/widget_expression.rb +7 -7
- data/lib/glimmer/launcher.rb +36 -8
- data/lib/glimmer/package.rb +31 -7
- data/lib/glimmer/rake_task.rb +111 -6
- data/lib/glimmer/scaffold.rb +98 -62
- data/lib/glimmer/swt/cursor_proxy.rb +45 -0
- data/lib/glimmer/swt/display_proxy.rb +13 -2
- data/lib/glimmer/swt/font_proxy.rb +7 -7
- data/lib/glimmer/swt/image_proxy.rb +16 -23
- data/lib/glimmer/swt/layout_proxy.rb +2 -0
- data/lib/glimmer/swt/message_box_proxy.rb +23 -5
- data/lib/glimmer/swt/scrolled_composite_proxy.rb +6 -11
- data/lib/glimmer/swt/style_constantizable.rb +11 -1
- data/lib/glimmer/swt/table_proxy.rb +50 -2
- data/lib/glimmer/swt/widget_proxy.rb +79 -18
- data/samples/elaborate/contact_manager.rb +121 -0
- data/samples/elaborate/contact_manager/contact.rb +11 -0
- data/samples/elaborate/contact_manager/contact_manager_presenter.rb +26 -0
- data/samples/elaborate/contact_manager/contact_repository.rb +244 -0
- data/samples/elaborate/login.rb +108 -0
- data/samples/elaborate/tic_tac_toe.rb +55 -0
- data/samples/elaborate/tic_tac_toe/board.rb +124 -0
- data/samples/elaborate/tic_tac_toe/cell.rb +27 -0
- data/samples/hello/hello_browser.rb +8 -0
- data/samples/hello/hello_combo.rb +38 -0
- data/samples/hello/hello_computed.rb +69 -0
- data/samples/hello/hello_computed/contact.rb +21 -0
- data/samples/hello/hello_drag_and_drop.rb +29 -0
- data/samples/hello/hello_list_multi_selection.rb +48 -0
- data/samples/hello/hello_list_single_selection.rb +37 -0
- data/samples/hello/hello_menu_bar.rb +64 -0
- data/samples/hello/hello_message_box.rb +15 -0
- data/samples/hello/hello_pop_up_context_menu.rb +36 -0
- data/samples/hello/hello_tab.rb +24 -0
- data/samples/hello/hello_world.rb +8 -0
- data/vendor/swt/linux/swt.jar +0 -0
- data/vendor/swt/mac/swt.jar +0 -0
- data/vendor/swt/windows/swt.jar +0 -0
- metadata +48 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82c0437f480a9bfc7064ec9cf10bc196a3bbb644d8fe20832c02eda79565435a
|
4
|
+
data.tar.gz: 418e810fad2c7f12280b78848931c743d619a8cc28f04f7a438092de9fed12e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dadb4107a2480af548a5e1f79f60b44a798e0ae2aa130e14dae4e1878d7211418c53ab88be39cb8adcfe42a1fc3846b46e06f5e90dccb984299896eef90f15a9
|
7
|
+
data.tar.gz: f902727a93b33a3aa0f013484b44f648fc2f991766f612ebb4e093c932389032417f8fe038de17609f7a28e3324d158419a1e502d07cd822b104658a7b4fb33c
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for SWT 0.
|
1
|
+
# [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for SWT 0.6.4 (Desktop GUI)
|
2
2
|
[![Gem Version](https://badge.fury.io/rb/glimmer-dsl-swt.svg)](http://badge.fury.io/rb/glimmer-dsl-swt)
|
3
3
|
[![Travis CI](https://travis-ci.com/AndyObtiva/glimmer-dsl-swt.svg?branch=master)](https://travis-ci.com/github/AndyObtiva/glimmer-dsl-swt)
|
4
4
|
[![Coverage Status](https://coveralls.io/repos/github/AndyObtiva/glimmer-dsl-swt/badge.svg?branch=master)](https://coveralls.io/github/AndyObtiva/glimmer-dsl-swt?branch=master)
|
data/RUBY_VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
jruby-9.2.
|
1
|
+
jruby-9.2.13.0
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.6.4
|
data/bin/girb
CHANGED
data/bin/glimmer
CHANGED
Binary file
|
Binary file
|
data/lib/ext/glimmer/config.rb
CHANGED
@@ -100,7 +100,11 @@ if ENV['GLIMMER_LOGGER_LEVEL']
|
|
100
100
|
# if glimmer log level is being overridden for debugging purposes, then disable async logging making logging immediate
|
101
101
|
Glimmer::Config.logging_appender_options = Glimmer::Config.logging_appender_options.merge(async: false, auto_flushing: 1)
|
102
102
|
Glimmer::Config.logging_devices = [:stdout]
|
103
|
-
|
103
|
+
begin
|
104
|
+
Glimmer::Config.logger.level = ENV['GLIMMER_LOGGER_LEVEL'].strip
|
105
|
+
rescue => e
|
106
|
+
puts e.message
|
107
|
+
end
|
104
108
|
end
|
105
109
|
Glimmer::Config.excluded_keyword_checkers << lambda do |method_symbol, *args|
|
106
110
|
method = method_symbol.to_s
|
@@ -0,0 +1,5 @@
|
|
1
|
+
# This Rakefile gets used from Glimmer::Launcher when the current directory for running the `glimmer` command
|
2
|
+
# does not have a Rakefile (e.g. during scaffolding).
|
3
|
+
# It is not needed when running from inside a scaffolded app or gem, or an app with a Rakefile that has
|
4
|
+
# `require 'glimmer/rake_task'`
|
5
|
+
require 'glimmer/rake_task'
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'glimmer/dsl/expression'
|
2
|
+
require 'glimmer/swt/cursor_proxy'
|
3
|
+
|
4
|
+
module Glimmer
|
5
|
+
module DSL
|
6
|
+
module SWT
|
7
|
+
# cursor expression
|
8
|
+
# Note: Cannot be a static expression because it clashes with cursor property expression
|
9
|
+
class CursorExpression < Expression
|
10
|
+
def can_interpret?(parent, keyword, *args, &block)
|
11
|
+
keyword.to_s == 'cursor' and
|
12
|
+
(parent.nil? or !parent.respond_to?('cursor')) and
|
13
|
+
args.size == 1 and
|
14
|
+
(args.first.is_a?(Integer) or textual?(args.first))
|
15
|
+
end
|
16
|
+
|
17
|
+
def interpret(parent, keyword, *args, &block)
|
18
|
+
Glimmer::SWT::CursorProxy.new(*args)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/glimmer/dsl/swt/dsl.rb
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'glimmer/dsl/expression'
|
2
|
+
require 'glimmer/dsl/top_level_expression'
|
3
|
+
require 'glimmer/swt/font_proxy'
|
4
|
+
|
5
|
+
module Glimmer
|
6
|
+
module DSL
|
7
|
+
module SWT
|
8
|
+
# font expression
|
9
|
+
# Note: Cannot be a static expression because it clashes with font property expression
|
10
|
+
class FontExpression < Expression
|
11
|
+
include TopLevelExpression
|
12
|
+
|
13
|
+
def can_interpret?(parent, keyword, *args, &block)
|
14
|
+
keyword.to_s == 'font' and
|
15
|
+
(parent.nil? || !parent.respond_to?('font')) and
|
16
|
+
args.size == 1 and
|
17
|
+
args.first.is_a?(Hash)
|
18
|
+
end
|
19
|
+
|
20
|
+
def interpret(parent, keyword, *args, &block)
|
21
|
+
Glimmer::SWT::FontProxy.new(*args)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'glimmer/dsl/expression'
|
2
|
+
require 'glimmer/swt/image_proxy'
|
3
|
+
|
4
|
+
module Glimmer
|
5
|
+
module DSL
|
6
|
+
module SWT
|
7
|
+
# image expression
|
8
|
+
# Note: Cannot be a static expression because it clashes with image property expression
|
9
|
+
class ImageExpression < Expression
|
10
|
+
def can_interpret?(parent, keyword, *args, &block)
|
11
|
+
keyword.to_s == 'image' and
|
12
|
+
(parent.nil? or !parent.respond_to?('image'))
|
13
|
+
end
|
14
|
+
|
15
|
+
def interpret(parent, keyword, *args, &block)
|
16
|
+
Glimmer::SWT::ImageProxy.new(*args)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -16,7 +16,15 @@ module Glimmer
|
|
16
16
|
|
17
17
|
def interpret(parent, keyword, *args, &block)
|
18
18
|
potential_parent = args.first
|
19
|
-
|
19
|
+
potential_parent = potential_parent.swt_widget if potential_parent.respond_to?(:swt_widget)
|
20
|
+
parent = nil
|
21
|
+
if potential_parent.is_a?(Shell)
|
22
|
+
args.shift
|
23
|
+
parent = potential_parent
|
24
|
+
elsif potential_parent.is_a?(Widget)
|
25
|
+
args.shift
|
26
|
+
parent = potential_parent.shell
|
27
|
+
end
|
20
28
|
Glimmer::SWT::MessageBoxProxy.new(parent, Glimmer::SWT::SWTProxy[args])
|
21
29
|
end
|
22
30
|
end
|
@@ -17,14 +17,14 @@ module Glimmer
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def interpret(parent, keyword, *args, &block)
|
20
|
-
|
21
|
-
class_name = "#{keyword.camelcase(:upper)}Proxy".to_sym
|
22
|
-
widget_class = Glimmer::SWT.const_get(class_name)
|
23
|
-
rescue
|
24
|
-
widget_class = Glimmer::SWT::WidgetProxy
|
25
|
-
end
|
26
|
-
widget_class.new(keyword, parent, args)
|
20
|
+
Glimmer::SWT::WidgetProxy.create(keyword, parent, args)
|
27
21
|
end
|
22
|
+
|
23
|
+
def add_content(parent, &block)
|
24
|
+
super
|
25
|
+
parent.post_add_content
|
26
|
+
end
|
27
|
+
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
data/lib/glimmer/launcher.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
1
3
|
require_relative 'rake_task'
|
2
4
|
|
3
5
|
module Glimmer
|
@@ -5,6 +7,7 @@ module Glimmer
|
|
5
7
|
OPERATING_SYSTEMS_SUPPORTED = ["mac", "windows", "linux"]
|
6
8
|
|
7
9
|
TEXT_USAGE_PREFIX = <<~MULTI_LINE_STRING
|
10
|
+
Glimmer (Ruby Desktop Development GUI Library) - JRuby Gem: glimmer-dsl-swt v#{File.read(File.expand_path('../../../VERSION', __FILE__))}
|
8
11
|
Usage: glimmer [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
|
9
12
|
|
10
13
|
Runs Glimmer applications/tasks.
|
@@ -13,7 +16,7 @@ module Glimmer
|
|
13
16
|
|
14
17
|
When a task is specified, it runs via rake. Some tasks take arguments in square brackets.
|
15
18
|
|
16
|
-
Available tasks are below (you
|
19
|
+
Available tasks are below (if you do not see any, please add `require 'glimmer/rake_task'` to Rakefile and rerun or run rake -T):
|
17
20
|
MULTI_LINE_STRING
|
18
21
|
|
19
22
|
TEXT_USAGE_SUFFIX = <<~MULTI_LINE_STRING
|
@@ -73,6 +76,10 @@ module Glimmer
|
|
73
76
|
end
|
74
77
|
@glimmer_lib
|
75
78
|
end
|
79
|
+
|
80
|
+
def dev_mode?
|
81
|
+
glimmer_lib == GLIMMER_LIB_LOCAL
|
82
|
+
end
|
76
83
|
|
77
84
|
def glimmer_option_env_vars(glimmer_options)
|
78
85
|
GLIMMER_OPTION_ENV_VAR_MAPPING.reduce({}) do |hash, pair|
|
@@ -89,13 +96,23 @@ module Glimmer
|
|
89
96
|
def launch(application, jruby_options: [], env_vars: {}, glimmer_options: {})
|
90
97
|
jruby_options_string = jruby_options.join(' ') + ' ' if jruby_options.any?
|
91
98
|
env_vars = env_vars.merge(glimmer_option_env_vars(glimmer_options))
|
92
|
-
env_vars_string = env_vars.map
|
99
|
+
env_vars_string = env_vars.map do |k,v|
|
100
|
+
if OS.windows? && ENV['PROMPT'] # detect command prompt (or powershell)
|
101
|
+
"set #{k}=#{v} && "
|
102
|
+
else
|
103
|
+
"export #{k}=#{v} && "
|
104
|
+
end
|
105
|
+
end.join
|
93
106
|
the_glimmer_lib = glimmer_lib
|
94
107
|
devmode_require = nil
|
95
108
|
if the_glimmer_lib == GLIMMER_LIB_LOCAL
|
96
109
|
devmode_require = '-r puts_debuggerer '
|
97
110
|
end
|
98
111
|
rake_tasks = Rake.application.tasks.map(&:to_s).map {|t| t.sub('glimmer:', '')}
|
112
|
+
|
113
|
+
# handle a bash quirk with calling package[msi] while there is a "packages" directory locally (it passes package[msi] as packages)
|
114
|
+
application = 'package[msi]' if application == 'packages'
|
115
|
+
|
99
116
|
potential_rake_task_parts = application.match(REGEX_RAKE_TASK_WITH_ARGS)
|
100
117
|
application = potential_rake_task_parts[1]
|
101
118
|
rake_task_args = potential_rake_task_parts[2].split(',')
|
@@ -109,8 +126,16 @@ module Glimmer
|
|
109
126
|
puts "Launching Glimmer Application: #{application}" if jruby_options_string.to_s.include?('--debug') || glimmer_options['--quiet'].to_s.downcase != 'true'
|
110
127
|
end
|
111
128
|
command = "#{env_vars_string} jruby #{jruby_options_string}#{jruby_os_specific_options} #{devmode_require}-r #{the_glimmer_lib} -S #{application}"
|
129
|
+
if !env_vars_string.empty? && OS.windows?
|
130
|
+
command = "bash -c \"#{command}\"" if ENV['SHELL'] # do in Windows Git Bash only
|
131
|
+
command = "cmd /C \"#{command}\"" if ENV['PROMPT'] # do in Windows Command Prompt only (or Powershell)
|
132
|
+
end
|
112
133
|
puts command if jruby_options_string.to_s.include?('--debug')
|
113
|
-
|
134
|
+
if command.include?(' irb ')
|
135
|
+
exec command
|
136
|
+
else
|
137
|
+
system command
|
138
|
+
end
|
114
139
|
end
|
115
140
|
end
|
116
141
|
end
|
@@ -155,11 +180,14 @@ module Glimmer
|
|
155
180
|
end
|
156
181
|
|
157
182
|
def display_usage
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
183
|
+
rakefile_dir = File.exist?('Rakefile') ? '.' : File.dirname(__FILE__)
|
184
|
+
FileUtils.cd(rakefile_dir) do
|
185
|
+
rake_tasks = `rake -T`.gsub('rake glimmer:', 'glimmer ').split("\n").select {|l| l.start_with?('glimmer ')}
|
186
|
+
puts TEXT_USAGE_PREFIX
|
187
|
+
puts rake_tasks.join("\n")
|
188
|
+
puts TEXT_USAGE_SUFFIX
|
189
|
+
end
|
190
|
+
end
|
163
191
|
|
164
192
|
def extract_application_paths(options)
|
165
193
|
options.select do |option|
|
data/lib/glimmer/package.rb
CHANGED
@@ -6,6 +6,7 @@ module Glimmer
|
|
6
6
|
module Package
|
7
7
|
class << self
|
8
8
|
attr_accessor :javapackager_extra_args
|
9
|
+
alias jpackage_extra_args :javapackager_extra_args
|
9
10
|
|
10
11
|
def clean
|
11
12
|
require 'fileutils'
|
@@ -41,7 +42,16 @@ module Glimmer
|
|
41
42
|
system('warble')
|
42
43
|
end
|
43
44
|
|
44
|
-
def
|
45
|
+
def lock_jars
|
46
|
+
puts 'Locking gem jar-dependencies by downloading & storing in vendor/jars...'
|
47
|
+
FileUtils.mkdir_p('vendor/jars')
|
48
|
+
command = "lock_jars --vendor-dir vendor/jars"
|
49
|
+
puts command
|
50
|
+
system command
|
51
|
+
end
|
52
|
+
|
53
|
+
def native(native_type=nil, native_extra_args)
|
54
|
+
puts "Generating native executable with javapackager/jpackage..."
|
45
55
|
require 'facets/string/titlecase'
|
46
56
|
require 'facets/string/underscore'
|
47
57
|
project_name = File.basename(File.expand_path('.'))
|
@@ -51,14 +61,28 @@ module Glimmer
|
|
51
61
|
license = (File.read(license_file).strip if File.exists?(license_file) && File.file?(license_file)) rescue nil
|
52
62
|
copyright = license.split("\n").first
|
53
63
|
human_name = project_name.underscore.titlecase
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
64
|
+
icon = "package/#{OS.mac? ? 'macosx' : 'windows'}/#{human_name}.#{OS.mac? ? 'icns' : 'ico'}"
|
65
|
+
if (`javapackager`.to_s.include?('Usage: javapackager') rescue nil)
|
66
|
+
command = "javapackager -deploy -native #{native_type} -outdir packages -outfile \"#{project_name}\" -srcfiles \"dist/#{project_name}.jar\" -appclass JarMain -name \"#{human_name}\" -title \"#{human_name}\" -Bmac.CFBundleName=\"#{human_name}\" -Bmac.CFBundleIdentifier=\"org.#{project_name}.application.#{project_name}\" -Bmac.category=\"public.app-category.business\" -BinstalldirChooser=true -Bvendor=\"#{human_name}\" -Bwin.menuGroup=\"#{human_name}\" "
|
67
|
+
command += " -BsystemWide=false " if OS.windows?
|
68
|
+
command += " -BjvmOptions=-XstartOnFirstThread " if OS.mac?
|
69
|
+
command += " -BappVersion=#{version} -Bmac.CFBundleVersion=#{version} " if version
|
70
|
+
command += " -srcfiles LICENSE.txt -BlicenseFile=LICENSE.txt " if license
|
71
|
+
command += " -Bcopyright=\"#{copyright}\" " if copyright
|
72
|
+
elsif (`jpackage`.to_s.include?('Usage: jpackage') rescue nil)
|
73
|
+
command = "jpackage --type #{native_type} --dest 'packages/bundles' --input 'dist' --main-class JarMain --main-jar '#{project_name}.jar' --name '#{human_name}' --vendor '#{human_name}' --icon '#{icon}' "
|
74
|
+
command += " --win-per-user-install --win-dir-chooser --win-menu --win-menu-group '#{human_name}' " if OS.windows?
|
75
|
+
command += " --java-options '-XstartOnFirstThread' --mac-package-name '#{human_name}' --mac-package-identifier 'org.#{project_name}.application.#{project_name}' " if OS.mac?
|
76
|
+
command += " --app-version \"#{version}\" " if version
|
77
|
+
command += " --license-file LICENSE.txt " if license
|
78
|
+
command += " --copyright \"#{copyright}\" " if copyright
|
79
|
+
else
|
80
|
+
puts "Neither javapackager nor jpackage exist in your Java installation. Please ensure javapackager or jpackage is available in PATH environment variable."
|
81
|
+
return
|
82
|
+
end
|
59
83
|
command += " #{javapackager_extra_args} " if javapackager_extra_args
|
60
84
|
command += " #{ENV['JAVAPACKAGER_EXTRA_ARGS']} " if ENV['JAVAPACKAGER_EXTRA_ARGS']
|
61
|
-
|
85
|
+
command += " #{native_extra_args} " if native_extra_args
|
62
86
|
puts command
|
63
87
|
system command
|
64
88
|
end
|
data/lib/glimmer/rake_task.rb
CHANGED
@@ -3,6 +3,103 @@ require 'rake'
|
|
3
3
|
require_relative 'package'
|
4
4
|
|
5
5
|
namespace :glimmer do
|
6
|
+
namespace :sample do
|
7
|
+
desc 'Runs a Glimmer internal sample [included in gem]. If no name is supplied, it runs all samples.'
|
8
|
+
task :run, [:name] => :requires do |t, args|
|
9
|
+
name = args[:name]
|
10
|
+
name = name.underscore.downcase unless name.nil?
|
11
|
+
samples = (Dir.glob(File.expand_path('../../../samples/hello/*.rb', __FILE__)) + Dir.glob(File.expand_path('../../../samples/elaborate/*.rb', __FILE__))).sort
|
12
|
+
samples = samples.select {|path| path.include?("#{name}.rb")} unless name.nil?
|
13
|
+
Rake::Task['glimmer:sample:code'].invoke(name) if samples.size == 1
|
14
|
+
Glimmer::Launcher.new(samples << '--quiet=false').launch
|
15
|
+
end
|
16
|
+
|
17
|
+
namespace :run do
|
18
|
+
task :hello do
|
19
|
+
samples = Dir.glob(File.expand_path('../../../samples/hello/*.rb', __FILE__)).sort
|
20
|
+
Glimmer::Launcher.new(samples << '--quiet=false').launch
|
21
|
+
end
|
22
|
+
|
23
|
+
task :elaborate do
|
24
|
+
samples = Dir.glob(File.expand_path('../../../samples/elaborate/*.rb', __FILE__)).sort
|
25
|
+
Glimmer::Launcher.new(samples << '--quiet=false').launch
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
desc 'Lists Glimmer internal samples [included in gem]. Filters by query if specified (query is optional)'
|
30
|
+
task :list, [:query] do |t, args|
|
31
|
+
Rake::Task['glimmer:sample:list:hello'].invoke(args[:query])
|
32
|
+
Rake::Task['glimmer:sample:list:elaborate'].invoke(args[:query])
|
33
|
+
end
|
34
|
+
|
35
|
+
namespace :list do
|
36
|
+
task :hello, [:query] => :requires do |t, args|
|
37
|
+
array_of_arrays = Dir.glob(File.expand_path('../../../samples/hello/*.rb', __FILE__)).map do |path|
|
38
|
+
File.basename(path, '.rb')
|
39
|
+
end.select do |path|
|
40
|
+
args[:query].nil? || path.include?(args[:query])
|
41
|
+
end.map do |path|
|
42
|
+
[path, path.underscore.titlecase, "#{'bin/' if Glimmer::Launcher.dev_mode?}glimmer sample:run[#{path}]"]
|
43
|
+
end.sort
|
44
|
+
puts
|
45
|
+
puts " Glimmer Hello Samples (run all via: #{'bin/' if Glimmer::Launcher.dev_mode?}glimmer sample:run:hello):"
|
46
|
+
puts Text::Table.new(
|
47
|
+
:head => %w[Name Description Run],
|
48
|
+
:rows => array_of_arrays,
|
49
|
+
:horizontal_padding => 1,
|
50
|
+
:vertical_boundary => ' ',
|
51
|
+
:horizontal_boundary => ' ',
|
52
|
+
:boundary_intersection => ' '
|
53
|
+
)
|
54
|
+
end
|
55
|
+
|
56
|
+
task :elaborate, [:query] => :requires do |t, args|
|
57
|
+
array_of_arrays = Dir.glob(File.expand_path('../../../samples/elaborate/*.rb', __FILE__)).map do |path|
|
58
|
+
File.basename(path, '.rb')
|
59
|
+
end.select do |path|
|
60
|
+
args[:query].nil? || path.include?(args[:query])
|
61
|
+
end.map do |path|
|
62
|
+
[path, path.underscore.titlecase, "#{'bin/' if Glimmer::Launcher.dev_mode?}glimmer sample:run[#{path}]"]
|
63
|
+
end.sort
|
64
|
+
puts
|
65
|
+
puts " Glimmer Elaborate Samples (run all via: #{'bin/' if Glimmer::Launcher.dev_mode?}glimmer sample:run:elaborate):"
|
66
|
+
puts Text::Table.new(
|
67
|
+
:head => %w[Name Description Run],
|
68
|
+
:rows => array_of_arrays,
|
69
|
+
:horizontal_padding => 1,
|
70
|
+
:vertical_boundary => ' ',
|
71
|
+
:horizontal_boundary => ' ',
|
72
|
+
:boundary_intersection => ' '
|
73
|
+
)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
desc 'Outputs code for a Glimmer internal sample [included in gem] (name is required)'
|
78
|
+
task :code, [:name] => :requires do |t, args|
|
79
|
+
samples = (Dir.glob(File.expand_path('../../../samples/hello/*.rb', __FILE__)) + Dir.glob(File.expand_path('../../../samples/elaborate/*.rb', __FILE__))).sort
|
80
|
+
sample = samples.detect {|path| path.include?("#{args[:name].to_s.underscore.downcase}.rb")}
|
81
|
+
sample_additional_files = Dir.glob(File.join(sample.sub('.rb', ''), '**', '*.rb'))
|
82
|
+
([sample] + sample_additional_files).each do |file|
|
83
|
+
puts
|
84
|
+
puts "# #{file}"
|
85
|
+
puts
|
86
|
+
puts File.read(file)
|
87
|
+
puts
|
88
|
+
puts '# # #'
|
89
|
+
puts
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
task :requires do
|
94
|
+
require 'text-table'
|
95
|
+
require 'facets/string/titlecase'
|
96
|
+
require 'facets/string/underscore'
|
97
|
+
|
98
|
+
require_relative 'launcher'
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
|
6
103
|
namespace :package do
|
7
104
|
desc 'Clean by removing "dist" and "packages" directories'
|
8
105
|
task :clean do
|
@@ -19,17 +116,25 @@ namespace :glimmer do
|
|
19
116
|
Glimmer::Package.jar
|
20
117
|
end
|
21
118
|
|
22
|
-
desc '
|
23
|
-
task :
|
24
|
-
Glimmer::Package.
|
119
|
+
desc 'Lock JARs'
|
120
|
+
task :lock_jars do
|
121
|
+
Glimmer::Package.lock_jars
|
122
|
+
end
|
123
|
+
|
124
|
+
desc 'Generate Native files. type can be dmg/pkg on the Mac, msi/exe on Windows, and rpm/deb on Linux (type is optional)'
|
125
|
+
task :native, [:type] do |t, args|
|
126
|
+
extra_args = ARGV.partition {|arg| arg.include?('package:native')}.last.to_a.join(' ')
|
127
|
+
Glimmer::Package.native(args[:type], extra_args)
|
25
128
|
end
|
26
129
|
end
|
27
130
|
|
28
|
-
desc 'Package app for distribution (generating config, jar, and native files)'
|
29
|
-
task :package do
|
131
|
+
desc 'Package app for distribution (generating config, jar, and native files) (type is optional)'
|
132
|
+
task :package, [:type] do |t, args|
|
133
|
+
Rake::Task['gemspec:generate'].execute
|
134
|
+
Rake::Task['glimmer:package:lock_jars'].execute
|
30
135
|
Rake::Task['glimmer:package:config'].execute
|
31
136
|
Rake::Task['glimmer:package:jar'].execute
|
32
|
-
Rake::Task['glimmer:package:native'].execute
|
137
|
+
Rake::Task['glimmer:package:native'].execute(args)
|
33
138
|
end
|
34
139
|
|
35
140
|
|