From 10c6380e619733100b7979a3130653ec2cb8afa8 Mon Sep 17 00:00:00 2001 From: ellemenno Date: Thu, 15 Nov 2018 19:44:24 -0500 Subject: [PATCH 1/7] update version to 3.3.0 --- lib/tasks/rakefiles/support.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tasks/rakefiles/support.rb b/lib/tasks/rakefiles/support.rb index e18a9d0..88d8b75 100644 --- a/lib/tasks/rakefiles/support.rb +++ b/lib/tasks/rakefiles/support.rb @@ -6,7 +6,7 @@ module LoomTasks - VERSION = '3.2.2' + VERSION = '3.3.0' EXIT_OK = 0 From 3daa55aeebaf5e87216aa843625c4e68dfe9e009 Mon Sep 17 00:00:00 2001 From: ellemenno Date: Thu, 15 Nov 2018 19:50:58 -0500 Subject: [PATCH 2/7] warn of missing docs config, suggest remedy --- lib/tasks/rakefiles/loomlib_docs.rake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/tasks/rakefiles/loomlib_docs.rake b/lib/tasks/rakefiles/loomlib_docs.rake index 4045129..1db940d 100644 --- a/lib/tasks/rakefiles/loomlib_docs.rake +++ b/lib/tasks/rakefiles/loomlib_docs.rake @@ -62,7 +62,8 @@ end TOOL_ERRORS = { :lsdoc => 'lsdoc not installed. See https://github.com/pixeldroid/lsdoc', - :bundler => 'gem dependencies not all resolved. Please run `bundle install`', + :bundler => 'gem dependencies not all resolved. Please run: bundle install', + :doc_config => "missing doc config.\nTo scaffold a new docs directory, run: rake -f ~/.loom/tasks/scaffolding.rake new:docs", } lsdoc_exe = LoomTasks.path_to_exe('lsdoc') @@ -79,6 +80,7 @@ namespace :docs do task :check_tools do |t, args| LoomTasks.fail(TOOL_ERRORS[:lsdoc]) unless LoomTasks.path_to_exe('lsdoc') LoomTasks.fail(TOOL_ERRORS[:bundler]) unless (LoomTasks.exec_with_echo('bundle check') == LoomTasks::EXIT_OK) + LoomTasks.fail(TOOL_ERRORS[:doc_config]) if (doc_config.empty?) end task :update_version do |t, args| From 92c683458edc7b9640ab88c0953b4a71b0df34fd Mon Sep 17 00:00:00 2001 From: ellemenno Date: Thu, 15 Nov 2018 19:53:46 -0500 Subject: [PATCH 3/7] =?UTF-8?q?support=20scaffolding=20tasks=20=C3=A0=20la?= =?UTF-8?q?=20carte;=20find=20existing=20lib=20name?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/scaffolding.rake | 64 ++++++++++++++++++++++++++++++++------ 1 file changed, 55 insertions(+), 9 deletions(-) diff --git a/lib/tasks/scaffolding.rake b/lib/tasks/scaffolding.rake index 64e0861..8142805 100644 --- a/lib/tasks/scaffolding.rake +++ b/lib/tasks/scaffolding.rake @@ -12,11 +12,21 @@ def global_config_file end def default_loom_sdk - JSON.parse(File.read(global_config_file))["default_sdk"] + JSON.parse(File.read(global_config_file))['default_sdk'] end def lib_name() - @lib_name || LoomTasks.fail("no lib name defined") + @lib_name || LoomTasks.fail('no lib name defined') +end + +def read_lib_name + LoomTasks.fail('no Rakefile to read lib name from') unless File.exists?(rakefile_pathname) + + File.open(rakefile_pathname,'r').each do |line| + if (match = line.match(/\s*LIB_NAME = ['"](.*)['"]/)) + return match.captures.first + end + end end def template_dir @@ -34,7 +44,7 @@ end def copy_from_template(dir, files) FileUtils.mkdir_p(dir) - FileUtils.cp(files, dir) + FileUtils.cp_r(files, dir) end def create_from_string(pathname, contents) @@ -242,6 +252,10 @@ def loomconfig_demo_contents() end +def gemfile_pathname() + File.join(Dir.pwd, 'Gemfile') +end + def rakefile_pathname() File.join(Dir.pwd, 'Rakefile') end @@ -263,6 +277,7 @@ task :default => [:usage] task :usage do |t, args| this_file = File.basename(__FILE__) + puts '' puts "#{this_file} v#{VERSION}: a utility to create a new loomlib directory structure" puts '' @@ -271,6 +286,12 @@ task :usage do |t, args| puts '$ cd MyLoomlib' puts "$ rake -f #{File.join(Dir.home, '.loom', 'tasks', this_file)} new:loomlib[MyLoomlib]" puts '$ rake' + puts '' + puts 'you can also call the tasks individually to add to an existing project' + puts 'take care, as this will overwrite files, if there are any pre-existing ones:' + puts '' + + system("rake -D -f #{__FILE__}") end namespace :new do @@ -288,7 +309,11 @@ namespace :new do create_from_template(rakefile_pathname, rakefile_template, context) end - task :cli do |t, args| + desc [ + "scaffolds the 'cli' directories and files for a new loomlib project", + "this task assumes (but does not enforce) it is the first to create these files", + ].join("\n") + task :cli => [:read_lib_name] do |t, args| name = "#{lib_name}DemoCLI" context = template_context @@ -299,10 +324,14 @@ namespace :new do create_from_template(cli_wrapper_pathname, cli_wrapper_template, context) end - task :docs do |t, args| + desc [ + "scaffolds the 'docs' directories and files for a new loomlib project", + "this task assumes (but does not enforce) it is the first to create these files", + ].join("\n") + task :docs => [:read_lib_name] do |t, args| context = template_context - copy_from_template(docs_pathname, docs_gemfile) + copy_from_template(Dir.pwd, docs_gemfile) create_from_template(docs_config_pathname, docs_config_template, context) create_from_template(docs_index_pathname, docs_index_template, context) copy_from_template(docs_pathname, File.join(lsdoc_pathname, '_data')) @@ -310,7 +339,11 @@ namespace :new do copy_from_template(docs_pathname, File.join(lsdoc_pathname, '_layouts')) end - task :gui do |t, args| + desc [ + "scaffolds the 'gui' directories and files for a new loomlib project", + "this task assumes (but does not enforce) it is the first to create these files", + ].join("\n") + task :gui => [:read_lib_name] do |t, args| name = "#{lib_name}DemoGUI" context = template_context @@ -322,7 +355,11 @@ namespace :new do copy_from_template(demo_gui_assets_pathname, demo_gui_assets) end - task :lib do |t, args| + desc [ + "scaffolds the 'lib' directories and files for a new loomlib project", + "this task assumes (but does not enforce) it is the first to create these files", + ].join("\n") + task :lib => [:read_lib_name] do |t, args| context = template_context create_from_string(loomconfig_pathname('lib'), loomconfig_cli_contents) @@ -330,7 +367,11 @@ namespace :new do create_from_template(sourcefile_pathname, sourcefile_template, context) end - task :test do |t, args| + desc [ + "scaffolds the 'test' directories and files for a new loomlib project", + "this task assumes (but does not enforce) it is the first to create these files", + ].join("\n") + task :test => [:read_lib_name] do |t, args| name = "#{lib_name}Test" context = template_context @@ -341,6 +382,11 @@ namespace :new do create_from_template(lib_testspec_pathname, lib_testspec_template, context) end + + task :read_lib_name do |t, args| + @lib_name = read_lib_name() + end + task :scaffold => [:gitignore, :rakefile, :lib, :test, :cli, :gui, :docs] desc [ From dd33d508f31b1a3a4861476e2c4421d3828da6df Mon Sep 17 00:00:00 2001 From: ellemenno Date: Fri, 16 Nov 2018 23:20:00 -0500 Subject: [PATCH 4/7] add task to build and auto-regenerate docs site --- lib/tasks/rakefiles/loomlib_docs.rake | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/tasks/rakefiles/loomlib_docs.rake b/lib/tasks/rakefiles/loomlib_docs.rake index 1db940d..0094581 100644 --- a/lib/tasks/rakefiles/loomlib_docs.rake +++ b/lib/tasks/rakefiles/loomlib_docs.rake @@ -36,8 +36,8 @@ def jekyll_build jekyll_cmd('build') end -def jekyll_serve - jekyll_cmd('serve') +def jekyll_watch + jekyll_cmd('serve --watch') end def jekyll_serve_only @@ -122,6 +122,20 @@ namespace :docs do puts "[#{t.name}] task completed, find updated docs in ./_site" end + desc [ + "calls jekyll to watch the docs and rebuild the site when files are changed", + " use CTRL-c to exit", + " cmd: #{jekyll_watch}", + ].join("\n") + task :watch_site do |t, args| + begin # run jekyll + puts jekyll_watch + system(jekyll_watch) + rescue Exception => e # capture the interrupt signal from a quit app + puts ' (quit)' + end + end + desc [ "calls jekyll to serve the docs site, without first building it", " cmd: #{jekyll_serve_only}", From ea952b22cc48b6ee13c8324870172854a4dfce05 Mon Sep 17 00:00:00 2001 From: ellemenno Date: Sun, 18 Nov 2018 18:59:12 -0500 Subject: [PATCH 5/7] ensure library is rebuilt and installed before running docs:gen_api --- lib/tasks/rakefiles/loomlib_docs.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tasks/rakefiles/loomlib_docs.rake b/lib/tasks/rakefiles/loomlib_docs.rake index 0094581..e576fa1 100644 --- a/lib/tasks/rakefiles/loomlib_docs.rake +++ b/lib/tasks/rakefiles/loomlib_docs.rake @@ -100,7 +100,7 @@ namespace :docs do "sets the library version number into #{doc_config_file}", " #{doc_config_file} is expected to have a project.version key", ].join("\n") - task :gen_api => ['docs:check_tools', 'docs:update_version'] do |t, args| + task :gen_api => ['docs:check_tools', 'docs:update_version', 'lib:install'] do |t, args| if (Dir.exists?(doc_api_dir)) FileUtils.rm_r(Dir.glob(File.join(doc_api_dir, '*'))) From 83b0f9d6fe2821745b6218e3fbe06cdec66ddc1b Mon Sep 17 00:00:00 2001 From: ellemenno Date: Sun, 25 Nov 2018 22:44:26 -0500 Subject: [PATCH 6/7] enable incremental build for docs:watch_site --- lib/tasks/rakefiles/loomlib_docs.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tasks/rakefiles/loomlib_docs.rake b/lib/tasks/rakefiles/loomlib_docs.rake index e576fa1..fbdb075 100644 --- a/lib/tasks/rakefiles/loomlib_docs.rake +++ b/lib/tasks/rakefiles/loomlib_docs.rake @@ -37,7 +37,7 @@ def jekyll_build end def jekyll_watch - jekyll_cmd('serve --watch') + jekyll_cmd('serve --watch --incremental') end def jekyll_serve_only From 520e892331b263bcacfad51b2cadc480790b38ea Mon Sep 17 00:00:00 2001 From: ellemenno Date: Mon, 26 Nov 2018 22:50:07 -0500 Subject: [PATCH 7/7] update README --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 3d66dd7..a06f5d5 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,7 @@ Running `rake` in your project directory will execute the default task, which pr rake docs:build_site # calls jekyll to [just] generate the docs site rake docs:gen_api # creates api docs compatible with the programming pages template rake docs:serve_site # calls jekyll to serve the docs site, without first building it + rake docs:watch_site # calls jekyll to watch the docs and rebuild the site when files are changed rake gui # shorthand for 'rake gui:run' rake gui:build # builds gui/bin/FooDemoGUI.loom for sprint34 SDK rake gui:run # launches gui/bin/FooDemoGUI.loom as a GUI app @@ -87,8 +88,8 @@ Running `rake` in your project directory will execute the default task, which pr rake test:run[seed] # runs test/bin/FooTest.loom for the console rake test:sdk[id] # sets the provided SDK version into test/loom.config rake version # reports loomlib version - (using loomtasks 3.2.2) - (using lsdoc 2.0.0) + (using loomtasks 3.3.0) + (using lsdoc 2.1.0) If you are looking for more detail on any of the tasks, use `rake help`, e.g. `rake help test`. @@ -119,8 +120,7 @@ The loomlib rake tasks make the following assumptions about the layout of a proj * the project uses a `Gemfile` for building and serving documentation locally with Jekyll and the Github Pages gem * source for a GUI demo is under `gui/`; the GUI demo app will consume the library and illustrate its use via a graphical user interface * the project uses a `Rakefile` for building, testing, and preparing releases -* library test source is under `test/`; the test app will consume the library and exercise it -* [spec-ls][spec-ls] is the supported testing framework +* library test source is under `test/`; [spec-ls][spec-ls] is the supported testing framework #### documentation