glimmer-dsl-swt 0.6.7 → 4.17.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +261 -0
  3. data/LICENSE.txt +1 -1
  4. data/README.md +3948 -24
  5. data/VERSION +1 -1
  6. data/bin/girb +21 -0
  7. data/bin/girb_runner.rb +21 -0
  8. data/bin/glimmer +24 -3
  9. data/glimmer-dsl-swt.gemspec +187 -0
  10. data/lib/ext/glimmer.rb +21 -0
  11. data/lib/ext/glimmer/config.rb +26 -2
  12. data/lib/glimmer-dsl-swt.rb +21 -0
  13. data/lib/glimmer/Rakefile +21 -0
  14. data/lib/glimmer/data_binding/list_selection_binding.rb +21 -0
  15. data/lib/glimmer/data_binding/observable_widget.rb +21 -0
  16. data/lib/glimmer/data_binding/shine.rb +22 -1
  17. data/lib/glimmer/data_binding/table_items_binding.rb +21 -0
  18. data/lib/glimmer/data_binding/tree_items_binding.rb +21 -0
  19. data/lib/glimmer/data_binding/widget_binding.rb +21 -0
  20. data/lib/glimmer/dsl/swt/async_exec_expression.rb +21 -0
  21. data/lib/glimmer/dsl/swt/bind_expression.rb +21 -0
  22. data/lib/glimmer/dsl/swt/block_property_expression.rb +21 -0
  23. data/lib/glimmer/dsl/swt/color_expression.rb +21 -0
  24. data/lib/glimmer/dsl/swt/column_properties_expression.rb +21 -0
  25. data/lib/glimmer/dsl/swt/combo_selection_data_binding_expression.rb +21 -0
  26. data/lib/glimmer/dsl/swt/cursor_expression.rb +21 -0
  27. data/lib/glimmer/dsl/swt/custom_widget_expression.rb +20 -0
  28. data/lib/glimmer/dsl/swt/data_binding_expression.rb +21 -0
  29. data/lib/glimmer/dsl/swt/dialog_expression.rb +21 -0
  30. data/lib/glimmer/dsl/swt/display_expression.rb +21 -0
  31. data/lib/glimmer/dsl/swt/dnd_expression.rb +21 -0
  32. data/lib/glimmer/dsl/swt/dsl.rb +21 -0
  33. data/lib/glimmer/dsl/swt/exec_expression.rb +28 -1
  34. data/lib/glimmer/dsl/swt/font_expression.rb +21 -0
  35. data/lib/glimmer/dsl/swt/image_expression.rb +21 -0
  36. data/lib/glimmer/dsl/swt/layout_data_expression.rb +21 -0
  37. data/lib/glimmer/dsl/swt/layout_expression.rb +21 -0
  38. data/lib/glimmer/dsl/swt/list_selection_data_binding_expression.rb +21 -0
  39. data/lib/glimmer/dsl/swt/menu_bar_expression.rb +21 -0
  40. data/lib/glimmer/dsl/swt/menu_expression.rb +21 -0
  41. data/lib/glimmer/dsl/swt/message_box_expression.rb +21 -0
  42. data/lib/glimmer/dsl/swt/observe_expression.rb +21 -0
  43. data/lib/glimmer/dsl/swt/property_expression.rb +21 -0
  44. data/lib/glimmer/dsl/swt/rgb_expression.rb +21 -0
  45. data/lib/glimmer/dsl/swt/rgba_expression.rb +21 -0
  46. data/lib/glimmer/dsl/swt/shell_expression.rb +21 -0
  47. data/lib/glimmer/dsl/swt/swt_expression.rb +21 -0
  48. data/lib/glimmer/dsl/swt/sync_exec_expression.rb +21 -0
  49. data/lib/glimmer/dsl/swt/tab_item_expression.rb +21 -0
  50. data/lib/glimmer/dsl/swt/table_items_data_binding_expression.rb +21 -0
  51. data/lib/glimmer/dsl/swt/tree_items_data_binding_expression.rb +21 -0
  52. data/lib/glimmer/dsl/swt/tree_properties_expression.rb +21 -0
  53. data/lib/glimmer/dsl/swt/widget_expression.rb +21 -0
  54. data/lib/glimmer/dsl/swt/widget_listener_expression.rb +21 -0
  55. data/lib/glimmer/launcher.rb +27 -7
  56. data/lib/glimmer/package.rb +21 -0
  57. data/lib/glimmer/rake_task.rb +36 -98
  58. data/lib/glimmer/rake_task/list.rb +21 -0
  59. data/lib/glimmer/rake_task/sample.rb +115 -0
  60. data/lib/glimmer/scaffold.rb +26 -5
  61. data/lib/glimmer/swt/color_proxy.rb +21 -0
  62. data/lib/glimmer/swt/cursor_proxy.rb +21 -0
  63. data/lib/glimmer/swt/display_proxy.rb +21 -0
  64. data/lib/glimmer/swt/dnd_proxy.rb +21 -0
  65. data/lib/glimmer/swt/font_proxy.rb +21 -0
  66. data/lib/glimmer/swt/image_proxy.rb +21 -0
  67. data/lib/glimmer/swt/layout_data_proxy.rb +21 -0
  68. data/lib/glimmer/swt/layout_proxy.rb +21 -0
  69. data/lib/glimmer/swt/menu_proxy.rb +21 -0
  70. data/lib/glimmer/swt/message_box_proxy.rb +21 -0
  71. data/lib/glimmer/swt/packages.rb +21 -0
  72. data/lib/glimmer/swt/scrolled_composite_proxy.rb +21 -0
  73. data/lib/glimmer/swt/shell_proxy.rb +21 -0
  74. data/lib/glimmer/swt/style_constantizable.rb +22 -0
  75. data/lib/glimmer/swt/swt_proxy.rb +21 -0
  76. data/lib/glimmer/swt/tab_item_proxy.rb +21 -0
  77. data/lib/glimmer/swt/table_column_proxy.rb +21 -0
  78. data/lib/glimmer/swt/table_proxy.rb +27 -4
  79. data/lib/glimmer/swt/tree_proxy.rb +21 -0
  80. data/lib/glimmer/swt/widget_listener_proxy.rb +21 -0
  81. data/lib/glimmer/swt/widget_proxy.rb +64 -25
  82. data/lib/glimmer/ui/custom_shell.rb +21 -0
  83. data/lib/glimmer/ui/custom_widget.rb +22 -0
  84. data/lib/glimmer/util/proc_tracker.rb +21 -0
  85. data/samples/elaborate/contact_manager.rb +21 -0
  86. data/samples/elaborate/contact_manager/contact.rb +21 -0
  87. data/samples/elaborate/contact_manager/contact_manager_presenter.rb +21 -0
  88. data/samples/elaborate/contact_manager/contact_repository.rb +21 -0
  89. data/samples/elaborate/login.rb +20 -2
  90. data/samples/elaborate/tic_tac_toe.rb +21 -0
  91. data/samples/elaborate/tic_tac_toe/board.rb +21 -0
  92. data/samples/elaborate/tic_tac_toe/cell.rb +21 -0
  93. data/samples/elaborate/user_profile.rb +21 -0
  94. data/samples/hello/hello_browser.rb +22 -1
  95. data/samples/hello/hello_combo.rb +21 -0
  96. data/samples/hello/hello_computed.rb +21 -0
  97. data/samples/hello/hello_computed/contact.rb +21 -0
  98. data/samples/hello/hello_drag_and_drop.rb +21 -0
  99. data/samples/hello/hello_list_multi_selection.rb +21 -0
  100. data/samples/hello/hello_list_single_selection.rb +21 -0
  101. data/samples/hello/hello_menu_bar.rb +21 -0
  102. data/samples/hello/hello_message_box.rb +21 -0
  103. data/samples/hello/hello_pop_up_context_menu.rb +21 -0
  104. data/samples/hello/hello_tab.rb +21 -0
  105. data/samples/hello/hello_world.rb +21 -0
  106. data/vendor/swt/linux/swt.jar +0 -0
  107. data/vendor/swt/mac/swt.jar +0 -0
  108. data/vendor/swt/windows/swt.jar +0 -0
  109. metadata +41 -32
@@ -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/static_expression'
2
23
  require 'glimmer/data_binding/model_binding'
3
24
  require 'glimmer/data_binding/tree_items_binding'
@@ -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
 
@@ -1,6 +1,26 @@
1
- require 'fileutils'
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.
2
21
 
3
- require_relative 'rake_task'
22
+ require 'fileutils'
23
+ require 'os'
4
24
 
5
25
  module Glimmer
6
26
  class Launcher
@@ -46,15 +66,11 @@ module Glimmer
46
66
  def swt_jar_file
47
67
  @swt_jar_file ||= File.expand_path(File.join(__FILE__, '..', '..', '..', 'vendor', 'swt', platform_os, 'swt.jar'))
48
68
  end
49
-
69
+
50
70
  def jruby_os_specific_options
51
71
  OS.mac? ? "-J-XstartOnFirstThread" : ""
52
72
  end
53
73
 
54
- def jruby_swt_options
55
- "#{jruby_os_specific_options} -J-classpath \"#{swt_jar_file}\""
56
- end
57
-
58
74
  def glimmer_lib
59
75
  @@mutex.synchronize do
60
76
  unless @glimmer_lib
@@ -100,6 +116,7 @@ module Glimmer
100
116
  if the_glimmer_lib == GLIMMER_LIB_LOCAL
101
117
  devmode_require = '-r puts_debuggerer '
102
118
  end
119
+ require_relative 'rake_task'
103
120
  rake_tasks = Rake.application.tasks.map(&:to_s).map {|t| t.sub('glimmer:', '')}
104
121
 
105
122
  # handle a bash quirk with calling package[msi] while there is a "packages" directory locally (it passes package[msi] as packages)
@@ -190,6 +207,9 @@ module Glimmer
190
207
  end
191
208
  puts task_lines.to_a
192
209
  else
210
+ require 'rake-tui'
211
+ require 'tty-screen'
212
+ require_relative 'rake_task'
193
213
  Rake::TUI.run(branding_header: nil, prompt_question: 'Select a Glimmer task to run:') do |task, tasks|
194
214
  max_task_size = tasks.map(&:name_with_args).map(&:size).max + 1
195
215
  task_name = task.name_with_args.sub('glimmer:', '')
@@ -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 'os'
2
23
 
3
24
  # TODO refactor to nest under RakeTask namespace
@@ -1,116 +1,54 @@
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 'rake'
2
23
 
3
24
  require_relative 'package'
4
25
 
26
+ ENV['GLIMMER_LOGGER_ENABLED'] = 'false'
27
+ require_relative '../ext/glimmer/config.rb'
28
+
29
+ require 'puts_debuggerer' if ("#{ENV['pd']}#{ENV['PD']}").to_s.downcase.include?('true')
30
+
5
31
  namespace :glimmer do
6
32
  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
33
+ task :requires do
34
+ require_relative 'rake_task/sample'
15
35
  end
16
36
 
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
37
+ desc 'Runs a Glimmer internal sample [included in gem]. If no name is supplied, it runs all samples.'
38
+ task :run, [:name] => [:requires] do |t, args|
39
+ Glimmer::RakeTask::Sample.run(args[:name])
27
40
  end
28
-
41
+
29
42
  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])
43
+ task :list, [:query] => [:requires] do |t, args|
44
+ Glimmer::RakeTask::Sample.list(args[:query])
33
45
  end
34
46
 
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
47
  desc 'Outputs code for a Glimmer internal sample [included in gem] (name is required)'
86
- task :code, [:name] => :requires do |t, args|
87
- require 'tty-markdown' unless OS.windows?
88
- samples = (Dir.glob(File.expand_path('../../../samples/hello/*.rb', __FILE__)) + Dir.glob(File.expand_path('../../../samples/elaborate/*.rb', __FILE__))).sort
89
- sample = samples.detect {|path| path.include?("#{args[:name].to_s.underscore.downcase}.rb")}
90
- sample_additional_files = Dir.glob(File.join(sample.sub('.rb', ''), '**', '*.rb'))
91
- code = ([sample] + sample_additional_files).map do |file|
92
- <<~RUBY
93
-
94
- # #{file}
95
-
96
- #{File.read(file)}
97
-
98
- # # #
99
-
100
- RUBY
101
- end.join("\n")
102
- code = TTY::Markdown.parse("```ruby\n#{code}\n```") unless OS.windows?
103
- puts code
48
+ task :code, [:name] => [:requires] do |t, args|
49
+ Glimmer::RakeTask::Sample.code(args[:name])
104
50
  end
105
51
 
106
- task :requires do
107
- require 'text-table'
108
- require 'facets/string/titlecase'
109
- require 'facets/string/underscore'
110
-
111
- require_relative 'launcher'
112
- end
113
-
114
52
  end
115
53
 
116
54
  namespace :package do
@@ -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
 
@@ -0,0 +1,115 @@
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 'text-table'
23
+ require 'facets/string/titlecase'
24
+ require 'facets/string/underscore'
25
+
26
+ require_relative '../launcher'
27
+
28
+ module Glimmer
29
+ module RakeTask
30
+ # Lists Glimmer related gems to use in rake_task.rb
31
+ class Sample
32
+ class << self
33
+ def glimmer_gems(glimmer_gem_type = '*')
34
+ Gem.find_latest_files("glimmer-#{glimmer_gem_type}-*")
35
+ end
36
+
37
+ def glimmer_gem_libs(glimmer_gem_type = '*')
38
+ glimmer_gems(glimmer_gem_type).map {|file| file.sub(/\.rb$/, '')}.uniq.reject {|file| file.include?('glimmer-cs-gladiator')}
39
+ end
40
+
41
+ def glimmer_gem_samples(glimmer_gem_type = '*')
42
+ sample_directories = glimmer_gems(glimmer_gem_type).map do |lib|
43
+ File.dirname(File.dirname(lib))
44
+ end.select do |gem|
45
+ Dir.exist?(File.join(gem, 'samples'))
46
+ end.map do |gem|
47
+ Dir.glob(File.join(gem, 'samples', '*')).select {|file_or_dir| Dir.exist?(file_or_dir)}
48
+ end.flatten.uniq.reverse
49
+ if Dir.exist?('samples')
50
+ Dir.glob(File.join('samples', '*')).to_a.reverse.each do |dir|
51
+ sample_directories << dir if Dir.exist?(dir)
52
+ end
53
+ end
54
+ sample_directories.uniq {|dir| File.basename(dir)}
55
+ end
56
+
57
+ def run(name)
58
+ name = name.underscore.downcase unless name.nil?
59
+ samples = glimmer_gem_samples.map {|dir| Dir.glob(File.join(dir, '*.rb'))}.reduce(:+).sort
60
+ samples = samples.select {|path| path.include?("#{name}.rb")} unless name.nil?
61
+ Rake::Task['glimmer:sample:code'].invoke(name) if samples.size == 1
62
+ Glimmer::Launcher.new(samples << '--quiet=false').launch
63
+ end
64
+
65
+ def list(query)
66
+ glimmer_gem_samples.each do |dir|
67
+ sample_group_name = File.basename(dir)
68
+ human_sample_group_name = sample_group_name.underscore.titlecase
69
+ array_of_arrays = Dir.glob(File.join(dir, '*.rb')).map do |path|
70
+ File.basename(path, '.rb')
71
+ end.select do |path|
72
+ query.nil? || path.include?(query)
73
+ end.map do |path|
74
+ [path, path.underscore.titlecase, "#{'bin/' if Glimmer::Launcher.dev_mode?}glimmer sample:run[#{path}]"]
75
+ end.sort
76
+ if array_of_arrays.empty?
77
+ puts "No Glimmer #{human_sample_group_name} Samples match the query."
78
+ else
79
+ puts
80
+ puts " Glimmer #{human_sample_group_name} Samples:"
81
+ puts Text::Table.new(
82
+ :head => %w[Name Description Run],
83
+ :rows => array_of_arrays,
84
+ :horizontal_padding => 1,
85
+ :vertical_boundary => ' ',
86
+ :horizontal_boundary => ' ',
87
+ :boundary_intersection => ' '
88
+ )
89
+ end
90
+ end
91
+ end
92
+
93
+ def code(name)
94
+ require 'tty-markdown' unless OS.windows?
95
+ samples = glimmer_gem_samples.map {|dir| Dir.glob(File.join(dir, '*.rb'))}.reduce(:+).sort
96
+ sample = samples.detect {|path| path.include?("#{name.to_s.underscore.downcase}.rb")}
97
+ sample_additional_files = Dir.glob(File.join(sample.sub('.rb', ''), '**', '*.rb'))
98
+ code = ([sample] + sample_additional_files).map do |file|
99
+ <<~RUBY
100
+
101
+ # #{file}
102
+
103
+ #{File.read(file)}
104
+
105
+ # # #
106
+
107
+ RUBY
108
+ end.join("\n")
109
+ code = TTY::Markdown.parse("```ruby\n#{code}\n```") unless OS.windows?
110
+ puts code
111
+ end
112
+ end
113
+ end
114
+ end
115
+ end