Skip to content

Commit

Permalink
Merge pull request #15 from ellemenno/v3.3.0
Browse files Browse the repository at this point in the history
v3.3.0
  • Loading branch information
pixeldroid authored Nov 27, 2018
2 parents ac3db21 + 520e892 commit 5fccc79
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 18 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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`.

Expand Down Expand Up @@ -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

Expand Down
24 changes: 20 additions & 4 deletions lib/tasks/rakefiles/loomlib_docs.rake
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ def jekyll_build
jekyll_cmd('build')
end

def jekyll_serve
jekyll_cmd('serve')
def jekyll_watch
jekyll_cmd('serve --watch --incremental')
end

def jekyll_serve_only
Expand All @@ -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')
Expand All @@ -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|
Expand All @@ -98,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, '*')))
Expand All @@ -120,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}",
Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/rakefiles/support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

module LoomTasks

VERSION = '3.2.2'
VERSION = '3.3.0'

EXIT_OK = 0

Expand Down
64 changes: 55 additions & 9 deletions lib/tasks/scaffolding.rake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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 ''
Expand All @@ -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
Expand All @@ -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
Expand All @@ -299,18 +324,26 @@ 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'))
copy_from_template(docs_pathname, File.join(lsdoc_pathname, '_includes'))
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
Expand All @@ -322,15 +355,23 @@ 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)
create_from_string(loombuild_pathname('lib', lib_name), loombuild_lib_contents)
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
Expand All @@ -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 [
Expand Down

0 comments on commit 5fccc79

Please sign in to comment.