glimmer-dsl-swt 4.17.2.3 → 4.17.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +47 -0
- data/README.md +358 -516
- data/VERSION +1 -1
- data/glimmer-dsl-swt.gemspec +10 -6
- data/lib/glimmer-dsl-swt.rb +1 -0
- data/lib/glimmer/dsl/swt/custom_widget_expression.rb +1 -0
- data/lib/glimmer/dsl/swt/widget_expression.rb +2 -0
- data/lib/glimmer/rake_task.rb +32 -20
- data/lib/glimmer/rake_task/package.rb +10 -3
- data/lib/glimmer/rake_task/scaffold.rb +146 -42
- data/lib/glimmer/swt/custom/code_text.rb +95 -0
- data/lib/glimmer/swt/image_proxy.rb +18 -3
- data/lib/glimmer/swt/message_box_proxy.rb +1 -1
- data/lib/glimmer/swt/sash_form_proxy.rb +53 -0
- data/lib/glimmer/swt/style_constantizable.rb +2 -1
- data/lib/glimmer/swt/styled_text_proxy.rb +43 -0
- data/lib/glimmer/swt/widget_proxy.rb +93 -63
- data/samples/elaborate/meta_sample.rb +166 -0
- data/samples/hello/hello_sash_form.rb +137 -0
- metadata +12 -8
- data/lib/glimmer/rake_task/sample.rb +0 -115
@@ -0,0 +1,166 @@
|
|
1
|
+
class Sample
|
2
|
+
attr_accessor :sample_directory, :file, :selected
|
3
|
+
|
4
|
+
def initialize(file, sample_directory: )
|
5
|
+
self.file = file
|
6
|
+
self.sample_directory = sample_directory
|
7
|
+
end
|
8
|
+
|
9
|
+
def name
|
10
|
+
if @name.nil?
|
11
|
+
@name = File.basename(file, '.rb').split('_').map(&:capitalize).join(' ')
|
12
|
+
if @name.start_with?('Hello')
|
13
|
+
name_parts = @name.split
|
14
|
+
name_parts[0] = name_parts.first + ','
|
15
|
+
name_parts[-1] = name_parts.last + '!'
|
16
|
+
@name = name_parts.join(' ')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
@name
|
20
|
+
end
|
21
|
+
|
22
|
+
def content
|
23
|
+
@content ||= File.read(file)
|
24
|
+
end
|
25
|
+
|
26
|
+
def launch
|
27
|
+
load file
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class SampleDirectory
|
32
|
+
class << self
|
33
|
+
attr_accessor :selected_sample
|
34
|
+
|
35
|
+
def sample_directories
|
36
|
+
if @sample_directories.nil?
|
37
|
+
@sample_directories = Dir.glob(File.join(File.expand_path('..', __FILE__), '*')).
|
38
|
+
select { |file| File.directory?(file) }.
|
39
|
+
map { |file| SampleDirectory.new(file) }
|
40
|
+
glimmer_gems = Gem.find_latest_files("glimmer-*-*")
|
41
|
+
sample_directories = glimmer_gems.map do |lib|
|
42
|
+
File.dirname(File.dirname(lib))
|
43
|
+
end.select do |gem|
|
44
|
+
Dir.exist?(File.join(gem, 'samples'))
|
45
|
+
end.map do |gem|
|
46
|
+
Dir.glob(File.join(gem, 'samples', '*')).select {|file_or_dir| Dir.exist?(file_or_dir)}
|
47
|
+
end.flatten.uniq.reverse
|
48
|
+
if Dir.exist?('samples')
|
49
|
+
Dir.glob(File.join('samples', '*')).to_a.reverse.each do |dir|
|
50
|
+
sample_directories << dir if Dir.exist?(dir)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
sample_directories = sample_directories.uniq {|dir| File.basename(dir)}
|
54
|
+
@sample_directories = sample_directories.map { |file| SampleDirectory.new(file) }
|
55
|
+
end
|
56
|
+
@sample_directories
|
57
|
+
end
|
58
|
+
|
59
|
+
def all_samples
|
60
|
+
@all_samples ||= sample_directories.map(&:samples).reduce(:+)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
include Glimmer # used for observe syntax
|
65
|
+
|
66
|
+
attr_accessor :file
|
67
|
+
|
68
|
+
def initialize(file)
|
69
|
+
self.file = file
|
70
|
+
end
|
71
|
+
|
72
|
+
def name
|
73
|
+
File.basename(file).split('_').map(&:capitalize).join(' ')
|
74
|
+
end
|
75
|
+
|
76
|
+
def samples
|
77
|
+
if @samples.nil?
|
78
|
+
@samples = Dir.glob(File.join(file, '*')).
|
79
|
+
select { |file| File.file?(file) }.
|
80
|
+
map { |sample_file| Sample.new(sample_file, sample_directory: self) }.
|
81
|
+
sort_by(&:name)
|
82
|
+
|
83
|
+
@samples.each do |sample|
|
84
|
+
observe(sample, :selected) do |new_selected_value|
|
85
|
+
if new_selected_value
|
86
|
+
self.class.all_samples.reject {|a_sample| a_sample.name == sample.name}.each do |other_sample|
|
87
|
+
other_sample.selected = false
|
88
|
+
end
|
89
|
+
self.class.selected_sample = sample
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
@samples
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
class MetaSampleApplication
|
99
|
+
include Glimmer
|
100
|
+
|
101
|
+
def launch
|
102
|
+
shell {
|
103
|
+
text 'Glimmer Meta-Sample (The Sample of Samples)'
|
104
|
+
|
105
|
+
on_swt_show {
|
106
|
+
SampleDirectory.selected_sample = SampleDirectory.all_samples.first
|
107
|
+
}
|
108
|
+
|
109
|
+
sash_form {
|
110
|
+
composite {
|
111
|
+
grid_layout 1, false
|
112
|
+
|
113
|
+
scrolled_composite {
|
114
|
+
layout_data(:fill, :fill, true, true)
|
115
|
+
|
116
|
+
composite {
|
117
|
+
SampleDirectory.sample_directories.each { |sample_directory|
|
118
|
+
group {
|
119
|
+
layout_data(:fill, :fill, true, true)
|
120
|
+
grid_layout 2, false
|
121
|
+
text "#{sample_directory.name} Samples"
|
122
|
+
font height: 30
|
123
|
+
|
124
|
+
sample_directory.samples.each { |sample|
|
125
|
+
label_radio = radio {
|
126
|
+
selection bind(sample, :selected)
|
127
|
+
}
|
128
|
+
label {
|
129
|
+
text sample.name
|
130
|
+
font height: 30
|
131
|
+
|
132
|
+
on_mouse_up {
|
133
|
+
sample.selected = true
|
134
|
+
}
|
135
|
+
}
|
136
|
+
}
|
137
|
+
}
|
138
|
+
}
|
139
|
+
}
|
140
|
+
}
|
141
|
+
|
142
|
+
button {
|
143
|
+
layout_data(:center, :center, false, false) {
|
144
|
+
height_hint 150
|
145
|
+
}
|
146
|
+
text 'Launch Sample'
|
147
|
+
font height: 45
|
148
|
+
on_widget_selected {
|
149
|
+
SampleDirectory.selected_sample.launch
|
150
|
+
}
|
151
|
+
}
|
152
|
+
}
|
153
|
+
|
154
|
+
code_text {
|
155
|
+
text bind(SampleDirectory, 'selected_sample.content')
|
156
|
+
editable false
|
157
|
+
caret nil
|
158
|
+
}
|
159
|
+
|
160
|
+
weights 1, 2
|
161
|
+
}
|
162
|
+
}.open
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
MetaSampleApplication.new.launch
|
@@ -0,0 +1,137 @@
|
|
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
|
+
class SashFormPresenter
|
23
|
+
include Glimmer
|
24
|
+
|
25
|
+
attr_accessor :sash_width, :orientation, :orientation_style
|
26
|
+
|
27
|
+
def initialize
|
28
|
+
@sash_width = 10
|
29
|
+
self.orientation = 'horizontal'
|
30
|
+
end
|
31
|
+
|
32
|
+
def orientation_options
|
33
|
+
['horizontal', 'vertical']
|
34
|
+
end
|
35
|
+
|
36
|
+
def orientation=(value)
|
37
|
+
@orientation = value
|
38
|
+
self.orientation_style = swt(@orientation)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
@presenter = SashFormPresenter.new
|
43
|
+
|
44
|
+
include Glimmer
|
45
|
+
|
46
|
+
shell {
|
47
|
+
grid_layout 1, false
|
48
|
+
minimum_size 740, 0
|
49
|
+
text 'Hello, Sash Form!'
|
50
|
+
|
51
|
+
@sash_form = sash_form {
|
52
|
+
layout_data(:fill, :fill, true, true) {
|
53
|
+
height_hint 200
|
54
|
+
}
|
55
|
+
sash_width bind(@presenter, :sash_width)
|
56
|
+
orientation bind(@presenter, :orientation_style)
|
57
|
+
weights 1, 2
|
58
|
+
|
59
|
+
@green_label = label {
|
60
|
+
text 'Hello, (resize >>)'
|
61
|
+
background :dark_green
|
62
|
+
foreground :white
|
63
|
+
font height: 30
|
64
|
+
}
|
65
|
+
|
66
|
+
@red_label = label {
|
67
|
+
text '(<< resize) Sash Form!'
|
68
|
+
background :red
|
69
|
+
foreground :white
|
70
|
+
font height: 30
|
71
|
+
}
|
72
|
+
}
|
73
|
+
|
74
|
+
composite {
|
75
|
+
layout_data(:fill, :fill, true, true)
|
76
|
+
grid_layout 2, true
|
77
|
+
|
78
|
+
label {
|
79
|
+
layout_data(:right, :center, true, false)
|
80
|
+
text 'Sash Width:'
|
81
|
+
font height: 16
|
82
|
+
}
|
83
|
+
spinner {
|
84
|
+
layout_data(:fill, :center, true, false) {
|
85
|
+
width_hint 100
|
86
|
+
}
|
87
|
+
selection bind(@presenter, :sash_width)
|
88
|
+
font height: 16
|
89
|
+
}
|
90
|
+
|
91
|
+
label {
|
92
|
+
layout_data(:right, :center, true, false)
|
93
|
+
text 'Orientation:'
|
94
|
+
font height: 16
|
95
|
+
}
|
96
|
+
combo(:read_only, :border) {
|
97
|
+
layout_data(:fill, :center, true, false) {
|
98
|
+
width_hint 100
|
99
|
+
}
|
100
|
+
selection bind(@presenter, :orientation)
|
101
|
+
font height: 16
|
102
|
+
}
|
103
|
+
|
104
|
+
button {
|
105
|
+
layout_data(:fill, :center, true, false)
|
106
|
+
text 'Maximize Green Label'
|
107
|
+
foreground :dark_green
|
108
|
+
font height: 16
|
109
|
+
|
110
|
+
on_widget_selected {
|
111
|
+
@sash_form.maximized_control = @green_label.swt_widget
|
112
|
+
}
|
113
|
+
}
|
114
|
+
button {
|
115
|
+
layout_data(:fill, :center, true, false)
|
116
|
+
text 'Maximize Red Label'
|
117
|
+
foreground :red
|
118
|
+
font height: 16
|
119
|
+
|
120
|
+
on_widget_selected {
|
121
|
+
@sash_form.maximized_control = @red_label.swt_widget
|
122
|
+
}
|
123
|
+
}
|
124
|
+
|
125
|
+
button {
|
126
|
+
layout_data(:fill, :center, true, false) {
|
127
|
+
horizontal_span 2
|
128
|
+
}
|
129
|
+
text 'Maximize None'
|
130
|
+
font height: 16
|
131
|
+
|
132
|
+
on_widget_selected {
|
133
|
+
@sash_form.maximized_control = nil
|
134
|
+
}
|
135
|
+
}
|
136
|
+
}
|
137
|
+
}.open
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glimmer-dsl-swt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.17.2
|
4
|
+
version: 4.17.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AndyMaleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-10-
|
11
|
+
date: 2020-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -185,21 +185,21 @@ dependencies:
|
|
185
185
|
requirements:
|
186
186
|
- - ">="
|
187
187
|
- !ruby/object:Gem::Version
|
188
|
-
version:
|
188
|
+
version: 3.23.0
|
189
189
|
- - "<"
|
190
190
|
- !ruby/object:Gem::Version
|
191
|
-
version:
|
192
|
-
name:
|
191
|
+
version: 4.0.0
|
192
|
+
name: rouge
|
193
193
|
prerelease: false
|
194
194
|
type: :runtime
|
195
195
|
version_requirements: !ruby/object:Gem::Requirement
|
196
196
|
requirements:
|
197
197
|
- - ">="
|
198
198
|
- !ruby/object:Gem::Version
|
199
|
-
version:
|
199
|
+
version: 3.23.0
|
200
200
|
- - "<"
|
201
201
|
- !ruby/object:Gem::Version
|
202
|
-
version:
|
202
|
+
version: 4.0.0
|
203
203
|
- !ruby/object:Gem::Dependency
|
204
204
|
requirement: !ruby/object:Gem::Requirement
|
205
205
|
requirements:
|
@@ -381,10 +381,10 @@ files:
|
|
381
381
|
- lib/glimmer/rake_task.rb
|
382
382
|
- lib/glimmer/rake_task/list.rb
|
383
383
|
- lib/glimmer/rake_task/package.rb
|
384
|
-
- lib/glimmer/rake_task/sample.rb
|
385
384
|
- lib/glimmer/rake_task/scaffold.rb
|
386
385
|
- lib/glimmer/swt/color_proxy.rb
|
387
386
|
- lib/glimmer/swt/cursor_proxy.rb
|
387
|
+
- lib/glimmer/swt/custom/code_text.rb
|
388
388
|
- lib/glimmer/swt/display_proxy.rb
|
389
389
|
- lib/glimmer/swt/dnd_proxy.rb
|
390
390
|
- lib/glimmer/swt/font_proxy.rb
|
@@ -394,9 +394,11 @@ files:
|
|
394
394
|
- lib/glimmer/swt/menu_proxy.rb
|
395
395
|
- lib/glimmer/swt/message_box_proxy.rb
|
396
396
|
- lib/glimmer/swt/packages.rb
|
397
|
+
- lib/glimmer/swt/sash_form_proxy.rb
|
397
398
|
- lib/glimmer/swt/scrolled_composite_proxy.rb
|
398
399
|
- lib/glimmer/swt/shell_proxy.rb
|
399
400
|
- lib/glimmer/swt/style_constantizable.rb
|
401
|
+
- lib/glimmer/swt/styled_text_proxy.rb
|
400
402
|
- lib/glimmer/swt/swt_proxy.rb
|
401
403
|
- lib/glimmer/swt/tab_item_proxy.rb
|
402
404
|
- lib/glimmer/swt/table_column_proxy.rb
|
@@ -412,6 +414,7 @@ files:
|
|
412
414
|
- samples/elaborate/contact_manager/contact_manager_presenter.rb
|
413
415
|
- samples/elaborate/contact_manager/contact_repository.rb
|
414
416
|
- samples/elaborate/login.rb
|
417
|
+
- samples/elaborate/meta_sample.rb
|
415
418
|
- samples/elaborate/tic_tac_toe.rb
|
416
419
|
- samples/elaborate/tic_tac_toe/board.rb
|
417
420
|
- samples/elaborate/tic_tac_toe/cell.rb
|
@@ -428,6 +431,7 @@ files:
|
|
428
431
|
- samples/hello/hello_menu_bar.rb
|
429
432
|
- samples/hello/hello_message_box.rb
|
430
433
|
- samples/hello/hello_pop_up_context_menu.rb
|
434
|
+
- samples/hello/hello_sash_form.rb
|
431
435
|
- samples/hello/hello_tab.rb
|
432
436
|
- samples/hello/hello_world.rb
|
433
437
|
- vendor/swt/linux/swt.jar
|
@@ -1,115 +0,0 @@
|
|
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
|