glimmer-dsl-swt 0.6.0 → 0.6.5
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/VERSION +1 -1
- data/bin/girb +1 -1
- data/bin/glimmer +5 -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 +1 -4
- data/lib/glimmer/dsl/swt/dsl.rb +1 -0
- data/lib/glimmer/dsl/swt/font_expression.rb +3 -1
- 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 +59 -20
- data/lib/glimmer/package.rb +31 -7
- data/lib/glimmer/rake_task.rb +119 -7
- data/lib/glimmer/scaffold.rb +98 -62
- data/lib/glimmer/swt/display_proxy.rb +13 -2
- 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/table_proxy.rb +50 -2
- data/lib/glimmer/swt/widget_proxy.rb +70 -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
- metadata +59 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8fa25c1d494d14eac00319e494d3b2f12c9a6b344c084b02a1dde9f60c2f44a5
|
4
|
+
data.tar.gz: 648c050a1a25a284e972beb5c129047ef6cbf8fabb1a80981408d900afed0c25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc9dedb03e9251f0a88e5530a642c062899be1651b26d2314258925375b871a3e5736141a1ee5b8dfacde1bc7a1d606d4ce00ac8affc8bf160b06f4aa7141306
|
7
|
+
data.tar.gz: 00416f75c6c00dc163501209a20839cd23fb51921a5335f8ffff7009bf013cca11ccb54389a55367c0ccbb1b0f1bb1641c61141d376a5c5792584567bd1d7937
|
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.6.
|
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.5 (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/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.5
|
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'
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'glimmer/dsl/expression'
|
2
|
-
require 'glimmer/dsl/top_level_expression'
|
3
2
|
require 'glimmer/swt/cursor_proxy'
|
4
3
|
|
5
4
|
module Glimmer
|
@@ -8,11 +7,9 @@ module Glimmer
|
|
8
7
|
# cursor expression
|
9
8
|
# Note: Cannot be a static expression because it clashes with cursor property expression
|
10
9
|
class CursorExpression < Expression
|
11
|
-
include TopLevelExpression
|
12
|
-
|
13
10
|
def can_interpret?(parent, keyword, *args, &block)
|
14
11
|
keyword.to_s == 'cursor' and
|
15
|
-
|
12
|
+
(parent.nil? or !parent.respond_to?('cursor')) and
|
16
13
|
args.size == 1 and
|
17
14
|
(args.first.is_a?(Integer) or textual?(args.first))
|
18
15
|
end
|
data/lib/glimmer/dsl/swt/dsl.rb
CHANGED
@@ -12,7 +12,9 @@ module Glimmer
|
|
12
12
|
|
13
13
|
def can_interpret?(parent, keyword, *args, &block)
|
14
14
|
keyword.to_s == 'font' and
|
15
|
-
|
15
|
+
(parent.nil? || !parent.respond_to?('font')) and
|
16
|
+
args.size == 1 and
|
17
|
+
args.first.is_a?(Hash)
|
16
18
|
end
|
17
19
|
|
18
20
|
def interpret(parent, keyword, *args, &block)
|
@@ -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,36 +1,31 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
1
3
|
require_relative 'rake_task'
|
2
4
|
|
3
5
|
module Glimmer
|
4
6
|
class Launcher
|
5
7
|
OPERATING_SYSTEMS_SUPPORTED = ["mac", "windows", "linux"]
|
6
8
|
|
7
|
-
|
9
|
+
TEXT_USAGE = <<~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
|
-
Runs Glimmer applications
|
11
|
-
|
12
|
-
Either a single task or one or more applications may be specified.
|
13
|
-
|
14
|
-
When a task is specified, it runs via rake. Some tasks take arguments in square brackets.
|
15
|
-
|
16
|
-
Available tasks are below (you may also lookup by adding `require 'glimmer/rake_task'` in Rakefile and running rake -T):
|
17
|
-
MULTI_LINE_STRING
|
18
|
-
|
19
|
-
TEXT_USAGE_SUFFIX = <<~MULTI_LINE_STRING
|
13
|
+
Runs Glimmer applications and tasks.
|
20
14
|
|
21
15
|
When applications are specified, they are run using JRuby,
|
22
16
|
automatically preloading the glimmer Ruby gem and SWT jar dependency.
|
23
17
|
|
24
|
-
Optionally, extra Glimmer options, JRuby options and environment variables may be passed in.
|
18
|
+
Optionally, extra Glimmer options, JRuby options, and/or environment variables may be passed in.
|
25
19
|
|
26
20
|
Glimmer options:
|
27
21
|
- "--quiet" : Does not announce file path of Glimmer application being launched
|
28
22
|
- "--debug" : Displays extra debugging information, passes "--debug" to JRuby, and enables debug logging
|
29
23
|
- "--log-level=VALUE" : Sets Glimmer's Ruby logger level ("ERROR" / "WARN" / "INFO" / "DEBUG"; default is none)
|
30
24
|
|
31
|
-
|
25
|
+
Tasks are run via rake. Some tasks take arguments in square brackets.
|
32
26
|
|
33
|
-
|
27
|
+
Available tasks are below (if you do not see any, please add `require 'glimmer/rake_task'` to Rakefile and rerun or run rake -T):
|
28
|
+
|
34
29
|
MULTI_LINE_STRING
|
35
30
|
|
36
31
|
GLIMMER_LIB_LOCAL = File.expand_path(File.join('lib', 'glimmer-dsl-swt.rb'))
|
@@ -73,6 +68,10 @@ module Glimmer
|
|
73
68
|
end
|
74
69
|
@glimmer_lib
|
75
70
|
end
|
71
|
+
|
72
|
+
def dev_mode?
|
73
|
+
glimmer_lib == GLIMMER_LIB_LOCAL
|
74
|
+
end
|
76
75
|
|
77
76
|
def glimmer_option_env_vars(glimmer_options)
|
78
77
|
GLIMMER_OPTION_ENV_VAR_MAPPING.reduce({}) do |hash, pair|
|
@@ -89,13 +88,23 @@ module Glimmer
|
|
89
88
|
def launch(application, jruby_options: [], env_vars: {}, glimmer_options: {})
|
90
89
|
jruby_options_string = jruby_options.join(' ') + ' ' if jruby_options.any?
|
91
90
|
env_vars = env_vars.merge(glimmer_option_env_vars(glimmer_options))
|
92
|
-
env_vars_string = env_vars.map
|
91
|
+
env_vars_string = env_vars.map do |k,v|
|
92
|
+
if OS.windows? && ENV['PROMPT'] # detect command prompt (or powershell)
|
93
|
+
"set #{k}=#{v} && "
|
94
|
+
else
|
95
|
+
"export #{k}=#{v} && "
|
96
|
+
end
|
97
|
+
end.join
|
93
98
|
the_glimmer_lib = glimmer_lib
|
94
99
|
devmode_require = nil
|
95
100
|
if the_glimmer_lib == GLIMMER_LIB_LOCAL
|
96
101
|
devmode_require = '-r puts_debuggerer '
|
97
102
|
end
|
98
103
|
rake_tasks = Rake.application.tasks.map(&:to_s).map {|t| t.sub('glimmer:', '')}
|
104
|
+
|
105
|
+
# handle a bash quirk with calling package[msi] while there is a "packages" directory locally (it passes package[msi] as packages)
|
106
|
+
application = 'package[msi]' if application == 'packages'
|
107
|
+
|
99
108
|
potential_rake_task_parts = application.match(REGEX_RAKE_TASK_WITH_ARGS)
|
100
109
|
application = potential_rake_task_parts[1]
|
101
110
|
rake_task_args = potential_rake_task_parts[2].split(',')
|
@@ -109,8 +118,16 @@ module Glimmer
|
|
109
118
|
puts "Launching Glimmer Application: #{application}" if jruby_options_string.to_s.include?('--debug') || glimmer_options['--quiet'].to_s.downcase != 'true'
|
110
119
|
end
|
111
120
|
command = "#{env_vars_string} jruby #{jruby_options_string}#{jruby_os_specific_options} #{devmode_require}-r #{the_glimmer_lib} -S #{application}"
|
121
|
+
if !env_vars_string.empty? && OS.windows?
|
122
|
+
command = "bash -c \"#{command}\"" if ENV['SHELL'] # do in Windows Git Bash only
|
123
|
+
command = "cmd /C \"#{command}\"" if ENV['PROMPT'] # do in Windows Command Prompt only (or Powershell)
|
124
|
+
end
|
112
125
|
puts command if jruby_options_string.to_s.include?('--debug')
|
113
|
-
|
126
|
+
if command.include?(' irb ')
|
127
|
+
exec command
|
128
|
+
else
|
129
|
+
system command
|
130
|
+
end
|
114
131
|
end
|
115
132
|
end
|
116
133
|
end
|
@@ -155,10 +172,32 @@ module Glimmer
|
|
155
172
|
end
|
156
173
|
|
157
174
|
def display_usage
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
175
|
+
puts TEXT_USAGE
|
176
|
+
display_tasks
|
177
|
+
end
|
178
|
+
|
179
|
+
def display_tasks
|
180
|
+
if OS.windows?
|
181
|
+
tasks = Rake.application.tasks
|
182
|
+
task_lines = tasks.reject do |task|
|
183
|
+
task.comment.nil?
|
184
|
+
end.map do |task|
|
185
|
+
max_task_size = tasks.map(&:name_with_args).map(&:size).max + 1
|
186
|
+
task_name = task.name_with_args.sub('glimmer:', '')
|
187
|
+
line = "glimmer #{task_name.ljust(max_task_size)} # #{task.comment}"
|
188
|
+
bound = TTY::Screen.width - 6
|
189
|
+
line.size <= bound ? line : "#{line[0..(bound - 3)]}..."
|
190
|
+
end
|
191
|
+
puts task_lines.to_a
|
192
|
+
else
|
193
|
+
Rake::TUI.run(branding_header: nil, prompt_question: 'Select a Glimmer task to run:') do |task, tasks|
|
194
|
+
max_task_size = tasks.map(&:name_with_args).map(&:size).max + 1
|
195
|
+
task_name = task.name_with_args.sub('glimmer:', '')
|
196
|
+
line = "glimmer #{task_name.ljust(max_task_size)} # #{task.comment}"
|
197
|
+
bound = TTY::Screen.width - 6
|
198
|
+
line.size <= bound ? line : "#{line[0..(bound - 3)]}..."
|
199
|
+
end
|
200
|
+
end
|
162
201
|
end
|
163
202
|
|
164
203
|
def extract_application_paths(options)
|
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,111 @@ 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
|
+
if array_of_arrays.empty?
|
45
|
+
puts "No Glimmer Hello Samples match the query."
|
46
|
+
else
|
47
|
+
puts
|
48
|
+
puts " Glimmer Hello Samples (run all via: #{'bin/' if Glimmer::Launcher.dev_mode?}glimmer sample:run:hello):"
|
49
|
+
puts Text::Table.new(
|
50
|
+
:head => %w[Name Description Run],
|
51
|
+
:rows => array_of_arrays,
|
52
|
+
:horizontal_padding => 1,
|
53
|
+
:vertical_boundary => ' ',
|
54
|
+
:horizontal_boundary => ' ',
|
55
|
+
:boundary_intersection => ' '
|
56
|
+
)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
task :elaborate, [:query] => :requires do |t, args|
|
61
|
+
array_of_arrays = Dir.glob(File.expand_path('../../../samples/elaborate/*.rb', __FILE__)).map do |path|
|
62
|
+
File.basename(path, '.rb')
|
63
|
+
end.select do |path|
|
64
|
+
args[:query].nil? || path.include?(args[:query])
|
65
|
+
end.map do |path|
|
66
|
+
[path, path.underscore.titlecase, "#{'bin/' if Glimmer::Launcher.dev_mode?}glimmer sample:run[#{path}]"]
|
67
|
+
end.sort
|
68
|
+
if array_of_arrays.empty?
|
69
|
+
puts "No Glimmer Elaborate Samples match the query."
|
70
|
+
else
|
71
|
+
puts
|
72
|
+
puts " Glimmer Elaborate Samples (run all via: #{'bin/' if Glimmer::Launcher.dev_mode?}glimmer sample:run:elaborate):"
|
73
|
+
puts Text::Table.new(
|
74
|
+
:head => %w[Name Description Run],
|
75
|
+
:rows => array_of_arrays,
|
76
|
+
:horizontal_padding => 1,
|
77
|
+
:vertical_boundary => ' ',
|
78
|
+
:horizontal_boundary => ' ',
|
79
|
+
:boundary_intersection => ' '
|
80
|
+
)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
desc 'Outputs code for a Glimmer internal sample [included in gem] (name is required)'
|
86
|
+
task :code, [:name] => :requires do |t, args|
|
87
|
+
samples = (Dir.glob(File.expand_path('../../../samples/hello/*.rb', __FILE__)) + Dir.glob(File.expand_path('../../../samples/elaborate/*.rb', __FILE__))).sort
|
88
|
+
sample = samples.detect {|path| path.include?("#{args[:name].to_s.underscore.downcase}.rb")}
|
89
|
+
sample_additional_files = Dir.glob(File.join(sample.sub('.rb', ''), '**', '*.rb'))
|
90
|
+
([sample] + sample_additional_files).each do |file|
|
91
|
+
puts
|
92
|
+
puts "# #{file}"
|
93
|
+
puts
|
94
|
+
puts File.read(file)
|
95
|
+
puts
|
96
|
+
puts '# # #'
|
97
|
+
puts
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
task :requires do
|
102
|
+
require 'text-table'
|
103
|
+
require 'facets/string/titlecase'
|
104
|
+
require 'facets/string/underscore'
|
105
|
+
|
106
|
+
require_relative 'launcher'
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
110
|
+
|
6
111
|
namespace :package do
|
7
112
|
desc 'Clean by removing "dist" and "packages" directories'
|
8
113
|
task :clean do
|
@@ -19,20 +124,27 @@ namespace :glimmer do
|
|
19
124
|
Glimmer::Package.jar
|
20
125
|
end
|
21
126
|
|
22
|
-
desc '
|
23
|
-
task :
|
24
|
-
Glimmer::Package.
|
127
|
+
desc 'Lock JARs'
|
128
|
+
task :lock_jars do
|
129
|
+
Glimmer::Package.lock_jars
|
130
|
+
end
|
131
|
+
|
132
|
+
desc 'Generate Native files. type can be dmg/pkg on the Mac, msi/exe on Windows, and rpm/deb on Linux (type is optional)'
|
133
|
+
task :native, [:type] do |t, args|
|
134
|
+
extra_args = ARGV.partition {|arg| arg.include?('package:native')}.last.to_a.join(' ')
|
135
|
+
Glimmer::Package.native(args[:type], extra_args)
|
25
136
|
end
|
26
137
|
end
|
27
138
|
|
28
|
-
desc 'Package app for distribution (generating config, jar, and native files)'
|
29
|
-
task :package do
|
139
|
+
desc 'Package app for distribution (generating config, jar, and native files) (type is optional)'
|
140
|
+
task :package, [:type] do |t, args|
|
141
|
+
Rake::Task['gemspec:generate'].execute
|
142
|
+
Rake::Task['glimmer:package:lock_jars'].execute
|
30
143
|
Rake::Task['glimmer:package:config'].execute
|
31
144
|
Rake::Task['glimmer:package:jar'].execute
|
32
|
-
Rake::Task['glimmer:package:native'].execute
|
145
|
+
Rake::Task['glimmer:package:native'].execute(args)
|
33
146
|
end
|
34
147
|
|
35
|
-
|
36
148
|
desc 'Scaffold Glimmer application directory structure to build a new app'
|
37
149
|
task :scaffold, [:app_name] do |t, args|
|
38
150
|
require_relative 'scaffold'
|