Skip to content

Commit

Permalink
Merge pull request #4 from ellemenno/v1.2.0
Browse files Browse the repository at this point in the history
v1.2.0
  • Loading branch information
pixeldroid authored Aug 1, 2016
2 parents 0e8c534 + 50df9c7 commit d3e69f3
Show file tree
Hide file tree
Showing 10 changed files with 450 additions and 94 deletions.
131 changes: 63 additions & 68 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,64 @@ They are no substitute for something like Gem or Bundler for Ruby, but they're a
loom tasks do not replace or interfere with the [loomcli][loomcli]; the two can be used safely together.


## installation

Clone this repo.

0. Run `rake install` to:
* create a `tasks` folder in your Loom SDK home directory (`~/.loom`)
* install the Rake tasks from this project into it.
0. Run `rake uninstall` to:
* delete the `tasks` folder.
* _**Note:** this deletes the whole folder! So be careful if you decide to put your own tasks in there._


## usage

0. Scaffold a new project structure:
* `rake -f ~/.loom/tasks/scaffolding.rake new:loomlib`
0. Test and see the auto-created library be built, the test harness and run, and the first test fail:
* `rake test`
0. Add your code and tests (in `lib/src/`, and `test/src/`)

### more details

Running `rake` in your project directory will execute the default task, which prints the list of available tasks and some useful info:

Foo v1.2.3 Rakefile running on Ruby 2.3.0 (lib=sprint33, test=sprint33)
rake clean # removes intermediate files to ensure a clean build
rake clobber # removes all generated artifacts to restore project to checkout-like state
rake demo:build # builds FooDemo.loom for sprint33 SDK
rake demo:cli[options] # executes FooDemo.loom as a commandline app, with options
rake demo:gui # launches FooDemo.loom as a GUI app
rake lib:build # builds Foo.loomlib for sprint33 SDK
rake lib:install # installs Foo.loomlib into sprint33 SDK
rake lib:release # prepares sdk-specific Foo.loomlib for release, and updates version in README
rake lib:show # lists libs installed for sprint33 SDK
rake lib:uninstall # removes Foo.loomlib from sprint33 SDK
rake set[sdk] # sets the provided SDK version into lib/loom.config and test/loom.config
rake test # shorthand for rake test:run
rake test:build # builds FooTest.loom against sprint33 SDK
rake test:ci # runs FooTest.loom for CI
rake test:run # runs FooTest.loom for the console
rake version[v] # changes the library version number
(using loomtasks v1.2.0)

use `rake -D` for more detailed task descriptions

If you are looking for more detail on any of the tasks, use `rake -D`, e.g.:

```console
$ rake -D set
rake set[sdk]
sets the provided SDK version into lib/loom.config and test/loom.config
lib/loom.config defines which SDK will be used to compile the loomlib, and also where to install it
test/loom.config defines which SDK will be used to compile the test app and demo app
```

The Rake tasks are defined with dependencies and modification triggers, so you can just run `rake test` every time you edit a source file, and the library and test app will be rebuilt as needed automatically.


## conventions

The loomlib rake tasks make the following assumptions about the layout of a project:
Expand All @@ -28,6 +86,7 @@ The loomlib rake tasks make the following assumptions about the layout of a proj
* library source will go under `lib/`
* the project will use a `Rakefile` for building, testing, and preparing releases
* library test source will go under `test/`; the test app will consume the library and exercise it
* [spec-ls][spec-ls] is the testing framework

#### lib

Expand Down Expand Up @@ -64,7 +123,7 @@ This is used to name the loomlib that gets compiled (and anticipates a correspon
#### test

`test/` is for unit tests of the library code. The tests are not packaged with the loomlib; they are run from a separate test runner app. <br>
Support for test tasks comes from `loomlib.rake`.
Support for test tasks comes from `loomlib.rake`. Use of [spec-ls][spec-ls] is assumed.

└─test
├─assets
Expand Down Expand Up @@ -105,76 +164,12 @@ Support for demo tasks comes from `loomlib_demo.rake`.
* the demo source code is under `test/src/demo/`


## installation

Clone this repo.

0. Run `rake install` to:
* create a `tasks` folder in your Loom SDK home directory (`~/.loom`)
* install the Rake tasks from this project into it.
0. Run `rake uninstall` to:
* delete the `tasks` folder.
* _**Note:** this deletes the whole folder! So be careful if you decide to put your own tasks in there._


## usage

In your project's `Rakefile`, declare the name of your library and path to the file containing version info.

```ruby
LIB_NAME = 'Foo'
LIB_VERSION_FILE = File.join('lib', 'src', 'com', 'bar', 'Foo.ls')
```

Then load the tasks you want to use:

```ruby
load(File.join(ENV['HOME'], '.loom', 'tasks', 'loomlib.rake'))
load(File.join(ENV['HOME'], '.loom', 'tasks', 'loomlib_demo.rake')) # optional
```

> Note: your whole Rakefile may be just those three or four lines if there isn't anything else you need to do
Now run `rake` to execute the default task, which will print the list of available tasks and some useful info:

Foo v1.2.3 Rakefile running on Ruby 2.1.1 (lib=sprint33, test=sprint33)
rake clean # removes intermediate files to ensure a clean build
rake clobber # removes all generated artifacts to restore project to checkout-like state
rake demo:build # builds FooDemo.loom for sprint33 SDK
rake demo:cli[options] # executes FooDemo.loom as a commandline app, with options
rake demo:gui # launches FooDemo.loom as a GUI app
rake lib:build # builds Foo.loomlib for sprint33 SDK
rake lib:install # installs Foo.loomlib into sprint33 SDK
rake lib:release # prepares sdk-specific Foo.loomlib for release, and updates version in README
rake lib:show # lists libs installed for sprint33 SDK
rake lib:uninstall # removes Foo.loomlib from sprint33 SDK
rake set[sdk] # sets the provided SDK version into lib/loom.config and test/loom.config
rake test # shorthand for rake test:run
rake test:build # builds FooTest.loom against sprint33 SDK
rake test:ci # runs FooTest.loom for CI
rake test:run # runs FooTest.loom for the console
(using loomtasks v1.1.0)

use `rake -D` for more detailed task descriptions

If you are looking for more detail on any of the tasks, use `rake -D`:

```console
$ rake -D set
rake set[sdk]
sets the provided SDK version into lib/loom.config and test/loom.config
lib/loom.config defines which SDK will be used to compile the loomlib, and also where to install it
test/loom.config defines which SDK will be used to compile the test app and demo app
```

The Rake tasks are defined with dependencies and modification triggers, so you can just run `rake test` every time you edit a source file, and the library and test app will be rebuilt as needed automatically.


## contributing

Pull requests are welcome!


[rake]: https://rubygems.org/gems/rake "Rake (Ruby make)"
[loomcli]: https://loomsdk.com/#see "See the Loom CLI demo"
[gh-releases]: https://help.github.com/articles/about-releases/ "about GitHub releases"
[loomcli]: https://loomsdk.com/#see "See the Loom CLI demo"
[rake]: https://rubygems.org/gems/rake "Rake (Ruby make)"
[spec-ls]: https://github.com/pixeldroid/spec-ls "spec-ls: a simple specification framework for loom"
6 changes: 6 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ def installed_tasks_dir()
File.join(Dir.home, '.loom', 'tasks')
end

def installed_templates_dir()
File.join(Dir.home, '.loom', 'tasks', 'templates')
end

task :default => :list_targets

task :list_targets do |t, args|
Expand All @@ -29,9 +33,11 @@ desc [
].join("\n")
task :install do |t, args|
Dir.mkdir(installed_tasks_dir) unless Dir.exists?(installed_tasks_dir)
Dir.mkdir(installed_templates_dir) unless Dir.exists?(installed_templates_dir)

FileUtils.cp_r(Dir.glob(File.join('lib', 'tasks', '*.rake')), installed_tasks_dir)
FileUtils.cp_r(Dir.glob(File.join('lib', 'tasks', '*.rb')), installed_tasks_dir)
FileUtils.cp_r(Dir.glob(File.join('lib', 'tasks', 'templates', '*.erb')), installed_templates_dir)

puts "[#{t.name}] task completed, tasks installed to #{installed_tasks_dir}"
puts ''
Expand Down
52 changes: 49 additions & 3 deletions lib/tasks/loomlib.rake
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
# add the following to your project's Rakefile:
#
# load(File.join(ENV['HOME'], '.loom', 'tasks', 'loomlib.rake'))
#
# starting a new project and don't have a rake file?
# use the scaffolding tasks to get set up:
#
# rake -f ~/.loom/tasks/scaffolding.rake new:loomlib

require 'etc'
require 'fileutils'
Expand All @@ -28,6 +33,10 @@ def const_lib_version_file
const_find('LIB_VERSION_FILE')
end

def lib_build_file()
File.join('lib', 'src', "#{const_lib_name}.build")
end

def lib_config_file()
File.join('lib', 'loom.config')
end
Expand All @@ -48,6 +57,10 @@ def lib_config()
@lib_loom_config || (@lib_loom_config = parse_loom_config(lib_config_file))
end

def lib_build_config()
@lib_build_config || (@lib_build_config = parse_loom_config(lib_build_file))
end

def test_config()
@test_loom_config || (@test_loom_config = parse_loom_config(test_config_file))
end
Expand All @@ -56,6 +69,10 @@ def write_lib_config(config)
write_loom_config(lib_config_file, config)
end

def write_lib_build_config(config)
write_loom_config(lib_build_file, config)
end

def write_test_config(config)
write_loom_config(test_config_file, config)
end
Expand Down Expand Up @@ -170,6 +187,25 @@ task :set, [:sdk] => 'lib:uninstall' do |t, args|
puts ''
end

desc [
"changes the library version number",
"this updates #{lib_build_file}",
"this updates #{lib_version_file}",
].join("\n")
task :version, [:v] do |t, args|
args.with_defaults(:v => '1.0.0')
lib_version = args.v

lib_build_config['version'] = lib_version
lib_build_config['modules'].first['version'] = lib_version

write_lib_build_config(lib_build_config)
update_lib_version(lib_version)

puts "[#{t.name}] task completed, lib version updated to #{lib_version}"
puts ''
end

namespace :lib do

desc [
Expand All @@ -195,7 +231,7 @@ namespace :lib do
release_dir = 'releases'

puts "[#{t.name}] updating README to reference version #{lib_version}"
update_readme_version()
update_readme_version(lib_version, sdk)

Dir.mkdir(release_dir) unless Dir.exists?(release_dir)

Expand Down Expand Up @@ -274,7 +310,12 @@ namespace :test do
puts "[#{t.name}] running #{t.prerequisites[0]}..."

sdk_version = test_config['sdk_version']
cmd = "#{loomexec(sdk_version)} test/bin/#{const_lib_name}Test.loom --format ansi"
bin_dir = 'bin'

Dir.mkdir(bin_dir) unless Dir.exists?(bin_dir)

FileUtils.cp(APP, File.join(bin_dir, 'Main.loom'))
cmd = "#{loomexec(sdk_version)} --ignored ignore --format ansi"
try(cmd, "failed to run .loom")

puts ''
Expand All @@ -289,7 +330,12 @@ namespace :test do
puts "[#{t.name}] running #{t.prerequisites[0]}..."

sdk_version = test_config['sdk_version']
cmd = "#{loomexec(sdk_version)} test/bin/#{const_lib_name}Test.loom --format junit --format console"
bin_dir = 'bin'

Dir.mkdir(bin_dir) unless Dir.exists?(bin_dir)

FileUtils.cp(APP, File.join(bin_dir, 'Main.loom'))
cmd = "#{loomexec(sdk_version)} --ignored ignore --format junit --format console"
try(cmd, "failed to run .loom")

puts ''
Expand Down
Loading

0 comments on commit d3e69f3

Please sign in to comment.