glimmer-dsl-swt 0.6.9 → 4.17.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +276 -0
- data/LICENSE.txt +1 -1
- data/README.md +4017 -24
- data/VERSION +1 -1
- data/bin/girb +21 -0
- data/bin/girb_runner.rb +21 -0
- data/bin/glimmer +21 -0
- data/glimmer-dsl-swt.gemspec +187 -0
- data/lib/ext/glimmer.rb +21 -0
- data/lib/ext/glimmer/config.rb +21 -5
- data/lib/glimmer-dsl-swt.rb +27 -0
- data/lib/glimmer/Rakefile +21 -0
- data/lib/glimmer/data_binding/list_selection_binding.rb +21 -0
- data/lib/glimmer/data_binding/observable_widget.rb +21 -0
- data/lib/glimmer/data_binding/shine.rb +22 -1
- data/lib/glimmer/data_binding/table_items_binding.rb +21 -0
- data/lib/glimmer/data_binding/tree_items_binding.rb +21 -0
- data/lib/glimmer/data_binding/widget_binding.rb +21 -0
- data/lib/glimmer/dsl/swt/async_exec_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/bind_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/block_property_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/color_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/column_properties_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/combo_selection_data_binding_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/cursor_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/custom_widget_expression.rb +20 -0
- data/lib/glimmer/dsl/swt/data_binding_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/dialog_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/display_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/dnd_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/dsl.rb +21 -0
- data/lib/glimmer/dsl/swt/exec_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/font_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/image_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/layout_data_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/layout_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/list_selection_data_binding_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/menu_bar_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/menu_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/message_box_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/observe_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/property_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/rgb_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/rgba_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/shell_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/swt_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/sync_exec_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/tab_item_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/table_items_data_binding_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/tree_items_data_binding_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/tree_properties_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/widget_expression.rb +21 -0
- data/lib/glimmer/dsl/swt/widget_listener_expression.rb +21 -0
- data/lib/glimmer/launcher.rb +34 -9
- data/lib/glimmer/rake_task.rb +66 -85
- data/lib/glimmer/rake_task/list.rb +25 -1
- data/lib/glimmer/rake_task/package.rb +128 -0
- data/lib/glimmer/rake_task/sample.rb +115 -0
- data/lib/glimmer/rake_task/scaffold.rb +661 -0
- data/lib/glimmer/swt/color_proxy.rb +21 -0
- data/lib/glimmer/swt/cursor_proxy.rb +21 -0
- data/lib/glimmer/swt/display_proxy.rb +21 -0
- data/lib/glimmer/swt/dnd_proxy.rb +21 -0
- data/lib/glimmer/swt/font_proxy.rb +21 -0
- data/lib/glimmer/swt/image_proxy.rb +21 -0
- data/lib/glimmer/swt/layout_data_proxy.rb +21 -0
- data/lib/glimmer/swt/layout_proxy.rb +21 -0
- data/lib/glimmer/swt/menu_proxy.rb +21 -0
- data/lib/glimmer/swt/message_box_proxy.rb +21 -0
- data/lib/glimmer/swt/packages.rb +21 -0
- data/lib/glimmer/swt/scrolled_composite_proxy.rb +21 -0
- data/lib/glimmer/swt/shell_proxy.rb +22 -0
- data/lib/glimmer/swt/style_constantizable.rb +21 -0
- data/lib/glimmer/swt/swt_proxy.rb +21 -0
- data/lib/glimmer/swt/tab_item_proxy.rb +21 -0
- data/lib/glimmer/swt/table_column_proxy.rb +21 -0
- data/lib/glimmer/swt/table_proxy.rb +21 -0
- data/lib/glimmer/swt/tree_proxy.rb +21 -0
- data/lib/glimmer/swt/widget_listener_proxy.rb +21 -0
- data/lib/glimmer/swt/widget_proxy.rb +24 -0
- data/lib/glimmer/ui/custom_shell.rb +21 -0
- data/lib/glimmer/ui/custom_widget.rb +29 -4
- data/lib/glimmer/util/proc_tracker.rb +23 -0
- data/samples/elaborate/contact_manager.rb +21 -0
- data/samples/elaborate/contact_manager/contact.rb +21 -0
- data/samples/elaborate/contact_manager/contact_manager_presenter.rb +21 -0
- data/samples/elaborate/contact_manager/contact_repository.rb +21 -0
- data/samples/elaborate/login.rb +20 -2
- data/samples/elaborate/tic_tac_toe.rb +21 -0
- data/samples/elaborate/tic_tac_toe/board.rb +21 -0
- data/samples/elaborate/tic_tac_toe/cell.rb +21 -0
- data/samples/elaborate/user_profile.rb +21 -0
- data/samples/hello/hello_browser.rb +22 -1
- data/samples/hello/hello_combo.rb +21 -0
- data/samples/hello/hello_computed.rb +21 -0
- data/samples/hello/hello_computed/contact.rb +21 -0
- data/samples/hello/hello_custom_shell.rb +134 -0
- data/samples/hello/hello_custom_widget.rb +65 -0
- data/samples/hello/hello_drag_and_drop.rb +21 -0
- data/samples/hello/hello_list_multi_selection.rb +21 -0
- data/samples/hello/hello_list_single_selection.rb +21 -0
- data/samples/hello/hello_menu_bar.rb +21 -0
- data/samples/hello/hello_message_box.rb +21 -0
- data/samples/hello/hello_pop_up_context_menu.rb +21 -0
- data/samples/hello/hello_tab.rb +21 -0
- data/samples/hello/hello_world.rb +21 -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 +52 -61
- data/lib/glimmer/package.rb +0 -91
- data/lib/glimmer/scaffold.rb +0 -631
@@ -1,3 +1,24 @@
|
|
1
|
+
# Copyright (c) 2007-2020 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
1
22
|
require 'glimmer'
|
2
23
|
require 'glimmer/dsl/expression'
|
3
24
|
require 'glimmer/dsl/parent_expression'
|
@@ -1,3 +1,24 @@
|
|
1
|
+
# Copyright (c) 2007-2020 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
1
22
|
require 'glimmer/dsl/expression'
|
2
23
|
require 'glimmer/swt/display_proxy'
|
3
24
|
|
data/lib/glimmer/launcher.rb
CHANGED
@@ -1,3 +1,28 @@
|
|
1
|
+
# Copyright (c) 2007-2020 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
if ARGV.include?('--bundler') && File.exist?(File.expand_path('./Gemfile'))
|
23
|
+
require 'bundler'
|
24
|
+
Bundler.setup(:default)
|
25
|
+
end
|
1
26
|
require 'fileutils'
|
2
27
|
require 'os'
|
3
28
|
|
@@ -7,7 +32,7 @@ module Glimmer
|
|
7
32
|
|
8
33
|
TEXT_USAGE = <<~MULTI_LINE_STRING
|
9
34
|
Glimmer (Ruby Desktop Development GUI Library) - JRuby Gem: glimmer-dsl-swt v#{File.read(File.expand_path('../../../VERSION', __FILE__))}
|
10
|
-
Usage: glimmer [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
|
35
|
+
Usage: glimmer [--bundler] [--pd] [--quiet] [--debug] [--log-level=VALUE] [[ENV_VAR=VALUE]...] [[-jruby-option]...] (application.rb or task[task_args]) [[application2.rb]...]
|
11
36
|
|
12
37
|
Runs Glimmer applications and tasks.
|
13
38
|
|
@@ -17,7 +42,9 @@ module Glimmer
|
|
17
42
|
Optionally, extra Glimmer options, JRuby options, and/or environment variables may be passed in.
|
18
43
|
|
19
44
|
Glimmer options:
|
20
|
-
- "--
|
45
|
+
- "--bundler=GROUP" : Activates gems in Bundler default group in Gemfile
|
46
|
+
- "--pd=BOOLEAN" : Requires puts_debuggerer to enable pd method
|
47
|
+
- "--quiet=BOOLEAN" : Does not announce file path of Glimmer application being launched
|
21
48
|
- "--debug" : Displays extra debugging information, passes "--debug" to JRuby, and enables debug logging
|
22
49
|
- "--log-level=VALUE" : Sets Glimmer's Ruby logger level ("ERROR" / "WARN" / "INFO" / "DEBUG"; default is none)
|
23
50
|
|
@@ -29,9 +56,11 @@ module Glimmer
|
|
29
56
|
|
30
57
|
GLIMMER_LIB_LOCAL = File.expand_path(File.join('lib', 'glimmer-dsl-swt.rb'))
|
31
58
|
GLIMMER_LIB_GEM = 'glimmer-dsl-swt'
|
32
|
-
GLIMMER_OPTIONS = %w[--log-level --quiet]
|
59
|
+
GLIMMER_OPTIONS = %w[--log-level --quiet --bundler --pd]
|
33
60
|
GLIMMER_OPTION_ENV_VAR_MAPPING = {
|
34
|
-
'--log-level' => 'GLIMMER_LOGGER_LEVEL'
|
61
|
+
'--log-level' => 'GLIMMER_LOGGER_LEVEL' ,
|
62
|
+
'--bundler' => 'GLIMMER_BUNDLER_SETUP' ,
|
63
|
+
'--pd' => 'PD' ,
|
35
64
|
}
|
36
65
|
REGEX_RAKE_TASK_WITH_ARGS = /^([^\[]+)\[?([^\]]*)\]?$/
|
37
66
|
|
@@ -45,15 +74,11 @@ module Glimmer
|
|
45
74
|
def swt_jar_file
|
46
75
|
@swt_jar_file ||= File.expand_path(File.join(__FILE__, '..', '..', '..', 'vendor', 'swt', platform_os, 'swt.jar'))
|
47
76
|
end
|
48
|
-
|
77
|
+
|
49
78
|
def jruby_os_specific_options
|
50
79
|
OS.mac? ? "-J-XstartOnFirstThread" : ""
|
51
80
|
end
|
52
81
|
|
53
|
-
def jruby_swt_options
|
54
|
-
"#{jruby_os_specific_options} -J-classpath \"#{swt_jar_file}\""
|
55
|
-
end
|
56
|
-
|
57
82
|
def glimmer_lib
|
58
83
|
@@mutex.synchronize do
|
59
84
|
unless @glimmer_lib
|
data/lib/glimmer/rake_task.rb
CHANGED
@@ -1,90 +1,71 @@
|
|
1
|
-
|
1
|
+
# Copyright (c) 2007-2020 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
module Glimmer
|
23
|
+
module RakeTask
|
24
|
+
RVM_FUNCTION = <<~MULTI_LINE_STRING
|
25
|
+
# Load RVM into a shell session *as a function*
|
26
|
+
if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then
|
27
|
+
|
28
|
+
# First try to load from a user install
|
29
|
+
source "$HOME/.rvm/scripts/rvm"
|
30
|
+
|
31
|
+
elif [[ -s "/usr/local/rvm/scripts/rvm" ]] ; then
|
32
|
+
|
33
|
+
# Then try to load from a root install
|
34
|
+
source "/usr/local/rvm/scripts/rvm"
|
35
|
+
|
36
|
+
fi
|
37
|
+
MULTI_LINE_STRING
|
38
|
+
end
|
39
|
+
end
|
2
40
|
|
3
|
-
|
41
|
+
require 'rake'
|
42
|
+
|
43
|
+
require_relative 'rake_task/package'
|
4
44
|
|
5
45
|
ENV['GLIMMER_LOGGER_ENABLED'] = 'false'
|
6
46
|
require_relative '../ext/glimmer/config.rb'
|
7
47
|
|
8
|
-
|
9
|
-
Glimmer::Config::SAMPLE_DIRECTORIES << File.expand_path('../../../samples/elaborate', __FILE__)
|
48
|
+
require 'puts_debuggerer' if ("#{ENV['pd']}#{ENV['PD']}").to_s.downcase.include?('true')
|
10
49
|
|
11
50
|
namespace :glimmer do
|
12
51
|
namespace :sample do
|
13
|
-
task :requires do
|
14
|
-
|
15
|
-
require 'facets/string/titlecase'
|
16
|
-
require 'facets/string/underscore'
|
17
|
-
|
18
|
-
require_relative 'launcher'
|
52
|
+
task :requires do
|
53
|
+
require_relative 'rake_task/sample'
|
19
54
|
end
|
20
55
|
|
21
|
-
task :glimmer_gems do
|
22
|
-
glimmer_cw_gems = Gem.find_latest_files('glimmer-cw-*')
|
23
|
-
glimmer_cs_gems = Gem.find_latest_files('glimmer-cs-*')
|
24
|
-
glimmer_dsl_gems = Gem.find_latest_files('glimmer-dsl-*')
|
25
|
-
glimmer_gem_lib_files = glimmer_cw_gems + glimmer_cs_gems + glimmer_dsl_gems
|
26
|
-
glimmer_gem_lib_files = glimmer_gem_lib_files.map {|file| file.sub(/\.rb$/, '')}.uniq.reject {|file| file.include?('glimmer-cs-gladiator')}
|
27
|
-
glimmer_gem_lib_files.each {|file| require file}
|
28
|
-
end
|
29
|
-
|
30
56
|
desc 'Runs a Glimmer internal sample [included in gem]. If no name is supplied, it runs all samples.'
|
31
|
-
task :run, [:name] => [:requires
|
32
|
-
|
33
|
-
name = name.underscore.downcase unless name.nil?
|
34
|
-
samples = Glimmer::Config::SAMPLE_DIRECTORIES.map {|dir| Dir.glob(File.join(dir, '*.rb'))}.reduce(:+).sort
|
35
|
-
samples = samples.select {|path| path.include?("#{name}.rb")} unless name.nil?
|
36
|
-
Rake::Task['glimmer:sample:code'].invoke(name) if samples.size == 1
|
37
|
-
Glimmer::Launcher.new(samples << '--quiet=false').launch
|
57
|
+
task :run, [:name] => [:requires] do |t, args|
|
58
|
+
Glimmer::RakeTask::Sample.run(args[:name])
|
38
59
|
end
|
39
60
|
|
40
61
|
desc 'Lists Glimmer internal samples [included in gem]. Filters by query if specified (query is optional)'
|
41
|
-
task :list, [:query] => [:requires
|
42
|
-
Glimmer::
|
43
|
-
sample_group_name = File.basename(dir)
|
44
|
-
human_sample_group_name = sample_group_name.underscore.titlecase
|
45
|
-
array_of_arrays = Dir.glob(File.join(dir, '*.rb')).map do |path|
|
46
|
-
File.basename(path, '.rb')
|
47
|
-
end.select do |path|
|
48
|
-
args[:query].nil? || path.include?(args[:query])
|
49
|
-
end.map do |path|
|
50
|
-
[path, path.underscore.titlecase, "#{'bin/' if Glimmer::Launcher.dev_mode?}glimmer sample:run[#{path}]"]
|
51
|
-
end.sort
|
52
|
-
if array_of_arrays.empty?
|
53
|
-
puts "No Glimmer #{human_sample_group_name} Samples match the query."
|
54
|
-
else
|
55
|
-
puts
|
56
|
-
puts " Glimmer #{human_sample_group_name} Samples:"
|
57
|
-
puts Text::Table.new(
|
58
|
-
:head => %w[Name Description Run],
|
59
|
-
:rows => array_of_arrays,
|
60
|
-
:horizontal_padding => 1,
|
61
|
-
:vertical_boundary => ' ',
|
62
|
-
:horizontal_boundary => ' ',
|
63
|
-
:boundary_intersection => ' '
|
64
|
-
)
|
65
|
-
end
|
66
|
-
end
|
62
|
+
task :list, [:query] => [:requires] do |t, args|
|
63
|
+
Glimmer::RakeTask::Sample.list(args[:query])
|
67
64
|
end
|
68
65
|
|
69
66
|
desc 'Outputs code for a Glimmer internal sample [included in gem] (name is required)'
|
70
|
-
task :code, [:name] => [:requires
|
71
|
-
|
72
|
-
samples = Glimmer::Config::SAMPLE_DIRECTORIES.map {|dir| Dir.glob(File.join(dir, '*.rb'))}.reduce(:+).sort
|
73
|
-
sample = samples.detect {|path| path.include?("#{args[:name].to_s.underscore.downcase}.rb")}
|
74
|
-
sample_additional_files = Dir.glob(File.join(sample.sub('.rb', ''), '**', '*.rb'))
|
75
|
-
code = ([sample] + sample_additional_files).map do |file|
|
76
|
-
<<~RUBY
|
77
|
-
|
78
|
-
# #{file}
|
79
|
-
|
80
|
-
#{File.read(file)}
|
81
|
-
|
82
|
-
# # #
|
83
|
-
|
84
|
-
RUBY
|
85
|
-
end.join("\n")
|
86
|
-
code = TTY::Markdown.parse("```ruby\n#{code}\n```") unless OS.windows?
|
87
|
-
puts code
|
67
|
+
task :code, [:name] => [:requires] do |t, args|
|
68
|
+
Glimmer::RakeTask::Sample.code(args[:name])
|
88
69
|
end
|
89
70
|
|
90
71
|
end
|
@@ -92,28 +73,28 @@ namespace :glimmer do
|
|
92
73
|
namespace :package do
|
93
74
|
desc 'Clean by removing "dist" and "packages" directories'
|
94
75
|
task :clean do
|
95
|
-
Glimmer::Package.clean
|
76
|
+
Glimmer::RakeTask::Package.clean
|
96
77
|
end
|
97
78
|
|
98
79
|
desc 'Generate JAR config file'
|
99
80
|
task :config do
|
100
|
-
Glimmer::Package.config
|
81
|
+
Glimmer::RakeTask::Package.config
|
101
82
|
end
|
102
83
|
|
103
84
|
desc 'Generate JAR file'
|
104
85
|
task :jar do
|
105
|
-
Glimmer::Package.jar
|
86
|
+
Glimmer::RakeTask::Package.jar
|
106
87
|
end
|
107
88
|
|
108
89
|
desc 'Lock JARs'
|
109
90
|
task :lock_jars do
|
110
|
-
Glimmer::Package.lock_jars
|
91
|
+
Glimmer::RakeTask::Package.lock_jars
|
111
92
|
end
|
112
93
|
|
113
94
|
desc 'Generate Native files. type can be dmg/pkg on the Mac, msi/exe on Windows, and rpm/deb on Linux (type is optional)'
|
114
95
|
task :native, [:type] do |t, args|
|
115
96
|
extra_args = ARGV.partition {|arg| arg.include?('package:native')}.last.to_a.join(' ')
|
116
|
-
Glimmer::Package.native(args[:type], extra_args)
|
97
|
+
Glimmer::RakeTask::Package.native(args[:type], extra_args)
|
117
98
|
end
|
118
99
|
end
|
119
100
|
|
@@ -128,15 +109,15 @@ namespace :glimmer do
|
|
128
109
|
|
129
110
|
desc 'Scaffold Glimmer application directory structure to build a new app'
|
130
111
|
task :scaffold, [:app_name] do |t, args|
|
131
|
-
require_relative 'scaffold'
|
132
|
-
Scaffold.app(args[:app_name])
|
112
|
+
require_relative 'rake_task/scaffold'
|
113
|
+
Glimmer::RakeTask::Scaffold.app(args[:app_name])
|
133
114
|
end
|
134
115
|
|
135
116
|
namespace :scaffold do
|
136
117
|
desc 'Scaffold Glimmer::UI::CustomShell subclass (full window view) under app/views (namespace is optional) [alt: scaffold:cs]'
|
137
118
|
task :customshell, [:name, :namespace] do |t, args|
|
138
|
-
require_relative 'scaffold'
|
139
|
-
Scaffold.custom_shell(args[:name], args[:namespace])
|
119
|
+
require_relative 'rake_task/scaffold'
|
120
|
+
Glimmer::RakeTask::Scaffold.custom_shell(args[:name], args[:namespace])
|
140
121
|
end
|
141
122
|
|
142
123
|
task :cs, [:name, :namespace] => :customshell
|
@@ -145,8 +126,8 @@ namespace :glimmer do
|
|
145
126
|
|
146
127
|
desc 'Scaffold Glimmer::UI::CustomWidget subclass (part of a view) under app/views (namespace is optional) [alt: scaffold:cw]'
|
147
128
|
task :customwidget, [:name, :namespace] do |t, args|
|
148
|
-
require_relative 'scaffold'
|
149
|
-
Scaffold.custom_widget(args[:name], args[:namespace])
|
129
|
+
require_relative 'rake_task/scaffold'
|
130
|
+
Glimmer::RakeTask::Scaffold.custom_widget(args[:name], args[:namespace])
|
150
131
|
end
|
151
132
|
|
152
133
|
task :cw, [:name, :namespace] => :customwidget
|
@@ -156,8 +137,8 @@ namespace :glimmer do
|
|
156
137
|
namespace :gem do
|
157
138
|
desc 'Scaffold Glimmer::UI::CustomShell subclass (full window view) under its own Ruby gem + app project (namespace is required) [alt: scaffold:gem:cs]'
|
158
139
|
task :customshell, [:name, :namespace] do |t, args|
|
159
|
-
require_relative 'scaffold'
|
160
|
-
Scaffold.custom_shell_gem(args[:name], args[:namespace])
|
140
|
+
require_relative 'rake_task/scaffold'
|
141
|
+
Glimmer::RakeTask::Scaffold.custom_shell_gem(args[:name], args[:namespace])
|
161
142
|
end
|
162
143
|
|
163
144
|
task :cs, [:name, :namespace] => :customshell
|
@@ -166,8 +147,8 @@ namespace :glimmer do
|
|
166
147
|
|
167
148
|
desc 'Scaffold Glimmer::UI::CustomWidget subclass (part of a view) under its own Ruby gem project (namespace is required) [alt: scaffold:gem:cw]'
|
168
149
|
task :customwidget, [:name, :namespace] do |t, args|
|
169
|
-
require_relative 'scaffold'
|
170
|
-
Scaffold.custom_widget_gem(args[:name], args[:namespace])
|
150
|
+
require_relative 'rake_task/scaffold'
|
151
|
+
Glimmer::RakeTask::Scaffold.custom_widget_gem(args[:name], args[:namespace])
|
171
152
|
end
|
172
153
|
|
173
154
|
task :cw, [:name, :namespace] => :customwidget
|
@@ -1,3 +1,24 @@
|
|
1
|
+
# Copyright (c) 2007-2020 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
1
22
|
require 'facets'
|
2
23
|
require 'text-table'
|
3
24
|
|
@@ -50,8 +71,11 @@ module Glimmer
|
|
50
71
|
|
51
72
|
def tablify(gem_prefix, gems)
|
52
73
|
array_of_arrays = gems.map do |gem|
|
74
|
+
name, namespace = gem[:name].sub(gem_prefix, '').underscore.titlecase.split
|
75
|
+
human_name = name
|
76
|
+
human_name += " (#{namespace})" unless namespace.nil?
|
53
77
|
[
|
54
|
-
|
78
|
+
human_name,
|
55
79
|
gem[:name],
|
56
80
|
gem[:version],
|
57
81
|
gem[:author].sub('Author: ', ''),
|
@@ -0,0 +1,128 @@
|
|
1
|
+
# Copyright (c) 2007-2020 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
require 'os'
|
23
|
+
|
24
|
+
# TODO refactor to nest under RakeTask namespace
|
25
|
+
module Glimmer
|
26
|
+
module RakeTask
|
27
|
+
module Package
|
28
|
+
class << self
|
29
|
+
attr_accessor :javapackager_extra_args
|
30
|
+
alias jpackage_extra_args :javapackager_extra_args
|
31
|
+
|
32
|
+
def clean
|
33
|
+
require 'fileutils'
|
34
|
+
FileUtils.rm_rf('dist')
|
35
|
+
FileUtils.rm_rf('packages')
|
36
|
+
end
|
37
|
+
|
38
|
+
def config
|
39
|
+
project_name = File.basename(File.expand_path('.'))
|
40
|
+
if !File.exists?('config/warble.rb')
|
41
|
+
puts 'Generating JAR configuration (config/warble.rb) to use with Warbler...'
|
42
|
+
FileUtils.mkdir_p('config')
|
43
|
+
if OS.windows?
|
44
|
+
system "jruby -S gem install warbler -v2.0.5 --no-document" unless warbler_exists?
|
45
|
+
else
|
46
|
+
system "bash -c '#{RVM_FUNCTION}\n cd .\n jruby -S gem install warbler -v2.0.5 --no-document\n'" unless warbler_exists?
|
47
|
+
end
|
48
|
+
if system('warble config')
|
49
|
+
new_config = File.read('config/warble.rb').split("\n").inject('') do |output, line|
|
50
|
+
if line.include?('config.dirs =')
|
51
|
+
line = line.sub('# ', '').sub(/=[^=\n]+$/, '= %w(app bin config db docs fonts icons images lib package script sounds vendor videos)')
|
52
|
+
end
|
53
|
+
if line.include?('config.includes =')
|
54
|
+
line = line.sub('# ', '').sub(/=[^=\n]+$/, "= FileList['LICENSE.txt', 'VERSION']")
|
55
|
+
end
|
56
|
+
if line.include?('config.autodeploy_dir =')
|
57
|
+
line = line.sub('# ', '')
|
58
|
+
end
|
59
|
+
output + "\n" + line
|
60
|
+
end
|
61
|
+
File.write('config/warble.rb', new_config)
|
62
|
+
else
|
63
|
+
puts 'Warbler executable "warble" is missing!'
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def jar
|
69
|
+
FileUtils.mkdir_p('dist')
|
70
|
+
puts "Generating JAR with Warbler..."
|
71
|
+
system "jruby -S gem install warbler -v2.0.5 --no-document" unless warbler_exists?
|
72
|
+
system('warble')
|
73
|
+
end
|
74
|
+
|
75
|
+
def lock_jars
|
76
|
+
puts 'Locking gem jar-dependencies by downloading & storing in vendor/jars...'
|
77
|
+
FileUtils.mkdir_p('vendor/jars')
|
78
|
+
command = "lock_jars --vendor-dir vendor/jars"
|
79
|
+
puts command
|
80
|
+
system command
|
81
|
+
end
|
82
|
+
|
83
|
+
def native(native_type=nil, native_extra_args)
|
84
|
+
puts "Generating native executable with javapackager/jpackage..."
|
85
|
+
require 'facets/string/titlecase'
|
86
|
+
require 'facets/string/underscore'
|
87
|
+
project_name = File.basename(File.expand_path('.'))
|
88
|
+
version_file = File.expand_path('./VERSION')
|
89
|
+
version = (File.read(version_file).strip if File.exists?(version_file) && File.file?(version_file)) rescue nil
|
90
|
+
license_file = File.expand_path('./LICENSE.txt')
|
91
|
+
license = (File.read(license_file).strip if File.exists?(license_file) && File.file?(license_file)) rescue nil
|
92
|
+
copyright = license.split("\n").first
|
93
|
+
human_name = project_name.underscore.titlecase
|
94
|
+
icon = "package/#{OS.mac? ? 'macosx' : 'windows'}/#{human_name}.#{OS.mac? ? 'icns' : 'ico'}"
|
95
|
+
if (`javapackager`.to_s.include?('Usage: javapackager') rescue nil)
|
96
|
+
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}\" "
|
97
|
+
command += " -BsystemWide=false " if OS.windows?
|
98
|
+
command += " -BjvmOptions=-XstartOnFirstThread " if OS.mac?
|
99
|
+
command += " -BappVersion=#{version} -Bmac.CFBundleVersion=#{version} " if version
|
100
|
+
command += " -srcfiles LICENSE.txt -BlicenseFile=LICENSE.txt " if license
|
101
|
+
command += " -Bcopyright=\"#{copyright}\" " if copyright
|
102
|
+
elsif (`jpackage`.to_s.include?('Usage: jpackage') rescue nil)
|
103
|
+
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}' "
|
104
|
+
command += " --win-per-user-install --win-dir-chooser --win-menu --win-menu-group '#{human_name}' " if OS.windows?
|
105
|
+
command += " --java-options '-XstartOnFirstThread' --mac-package-name '#{human_name}' --mac-package-identifier 'org.#{project_name}.application.#{project_name}' " if OS.mac?
|
106
|
+
command += " --app-version \"#{version}\" " if version
|
107
|
+
command += " --license-file LICENSE.txt " if license
|
108
|
+
command += " --copyright \"#{copyright}\" " if copyright
|
109
|
+
else
|
110
|
+
puts "Neither javapackager nor jpackage exist in your Java installation. Please ensure javapackager or jpackage is available in PATH environment variable."
|
111
|
+
return
|
112
|
+
end
|
113
|
+
command += " #{javapackager_extra_args} " if javapackager_extra_args
|
114
|
+
command += " #{ENV['JAVAPACKAGER_EXTRA_ARGS']} " if ENV['JAVAPACKAGER_EXTRA_ARGS']
|
115
|
+
command += " #{native_extra_args} " if native_extra_args
|
116
|
+
puts command
|
117
|
+
system command
|
118
|
+
end
|
119
|
+
|
120
|
+
private
|
121
|
+
|
122
|
+
def warbler_exists?
|
123
|
+
OS.windows? ? system('where warble') : system('which warble')
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|