Skip to content
Browse files

calatrava create can be used to create new projects that can be built

for web.
  • Loading branch information...
1 parent e7980ae commit c3f44446f38d9e9217244cc60df2d840d73f326c @gga gga committed Jul 15, 2012
Showing with 464 additions and 183 deletions.
  1. +3 −1 .gitignore
  2. +8 −2 Gemfile
  3. +49 −2 README.md
  4. +14 −94 Rakefile
  5. +4 −1 bin/calatrava
  6. +5 −4 calatrava.gemspec
  7. +14 −0 features/cli.feature
  8. +48 −0 features/project.feature
  9. +8 −0 features/step_definitions/template_steps.rb
  10. +5 −0 features/support/env.rb
  11. +4 −5 lib/calatrava.rb
  12. +30 −0 lib/calatrava/app.rb
  13. +57 −0 lib/calatrava/project.rb
  14. +95 −0 lib/calatrava/tasks.rb
  15. 0 {task_support → lib/calatrava/tasks}/apache.rb
  16. +9 −0 {task_support → lib/calatrava/tasks}/artifact.rb
  17. +3 −0 lib/calatrava/tasks/assets.rb
  18. 0 tasks/automation.rake → lib/calatrava/tasks/automation.rb
  19. +5 −0 lib/calatrava/tasks/bootstrap.rb
  20. 0 {task_support → lib/calatrava/tasks}/calatrava_kernel.rb
  21. +20 −0 {task_support → lib/calatrava/tasks}/configuration.rb
  22. +1 −1 tasks/droid.rake → lib/calatrava/tasks/droid.rb
  23. 0 {task_support → lib/calatrava/tasks}/haml.rb
  24. 0 tasks/ios.rake → lib/calatrava/tasks/ios.rb
  25. +10 −12 tasks/kernel.rake → lib/calatrava/tasks/kernel.rb
  26. 0 tasks/precommit.rake → lib/calatrava/tasks/precommit.rb
  27. 0 tasks/release.rake → lib/calatrava/tasks/release.rb
  28. +17 −0 lib/calatrava/tasks/shell.rb
  29. +6 −6 tasks/web.rake → lib/calatrava/tasks/web.rb
  30. +40 −0 lib/calatrava/template.rb
  31. +2 −0 lib/calatrava/templates/.rvmrc.calatrava
  32. +4 −0 lib/calatrava/templates/Gemfile.calatrava
  33. +1 −0 lib/calatrava/templates/Rakefile
  34. +0 −6 lib/calatrava/templates/ios/.gitignore
  35. 0 lib/calatrava/templates/{kernel → }/package.json
  36. +1 −0 lib/calatrava/templates/shell/shell.scss
  37. +1 −1 lib/calatrava/version.rb
  38. +0 −3 task_support/assets.rb
  39. +0 −8 tasks/artifact.rake
  40. +0 −19 tasks/configuration.rake
  41. +0 −18 tasks/shell.rake
View
4 .gitignore
@@ -2,4 +2,6 @@
.bundle
Gemfile.lock
pkg/*
-/.DS_Store
+.DS_Store
+/lib/calatrava/templates/ios/App/App.xcodeproj/project.xcworkspace/xcuserdata/*
+tmp/*
View
10 Gemfile
@@ -1,13 +1,19 @@
-source "http://rubygems.org"
+source :rubygems
# Specify your gem's dependencies in calatrava.gemspec
gemspec
gem 'rake'
+gem 'trollop'
gem 'haml'
gem 'sass'
gem 'cucumber'
gem 'frank-cucumber'
gem 'watir-webdriver'
+gem 'thor'
+gem 'mustache'
-gem 'aruba'
+group :development do
+ gem 'aruba'
+ gem 'rspec'
+end
View
51 README.md
@@ -1,3 +1,50 @@
-# Set up
+# Dependencies
-Make sure you've run `bundle install` recently.
+It should be as easy to get started with Calatrava as
+possible. However, there are still a small number of dependencies that
+need to be installed beforehand.
+
+1. [rvm](http://rvm.io). Calatrava projects are configured to use
+ `rvm` by default. You could use Calatrava without it, but you will
+ then need to make sure you have Ruby 1.9.3 installed however you
+ prefer.
+
+2. [bundler](http://gembundler.com/). Install in either your `rvm`
+ global gemset, or wherever else makes sense for your setup.
+
+3. Xcode. You'll have to get this from the Mac App Store. Once
+ installed, make sure you download and install the command line
+ tools, and make sure you run `xcode-select`. Calatrava doesn't
+ actually directly use Xcode except when building iOS apps, so you
+ can use it on a non-Mac as long as you don't run the iOS build
+ targets.
+
+4. Android SDK. I recommend installing using
+ [homebrew](http://mxcl.github.com/homebrew/) if you're on a
+ Mac. But however you get hold of it, the `android` command is
+ expected to be on the path.
+
+5. [Node.js](http://nodejs.org/). Only used to run tests, not part of
+ any production code. Again, if you're on a Mac I recommend
+ installing using homebrew.
+
+# Getting Started
+
+Once you have the dependenices installed, there are just six simple
+steps to creating and building your first Calatrava cross-platform
+mobile app.
+
+1. Install the Calatrava gem: `gem install calatrava`
+
+2. Create your Calatrava project: `calatrava create
+ <project-name>`
+
+3. `cd <project-name>`
+
+4. `rake bootstrap`
+
+5. `rake configure:development`
+
+5. `rake [droid|ios|web]:build CALATRAVA_ENV=development`
+
+And you're away! Or at least, you should be.
View
108 Rakefile
@@ -1,97 +1,17 @@
require "bundler/gem_tasks"
-
-$: << File.dirname(__FILE__)
-
-ROOT_DIR = File.dirname(__FILE__).freeze
-BUILD_DIR = File.join(ROOT_DIR, 'build').freeze
-
-SHELL_DIR = File.join(ROOT_DIR, 'shell').freeze
-SHELL_LAYOUTS_DIR = File.join(SHELL_DIR, 'layouts').freeze
-SHELL_VIEWS_DIR = File.join(SHELL_DIR, 'views').freeze
-SHELL_PARTIALS_DIR = File.join(SHELL_DIR, 'partials').freeze
-SHELL_JS_DIR = File.join(SHELL_DIR, 'support').freeze
-
-FEATURES_DIR = File.join(ROOT_DIR, 'features').freeze
-FEATURE_RESULTS_DIR = File.join(ROOT_DIR, 'results').freeze
-
-
-KERNEL_DIR = File.join(ROOT_DIR, 'kernel').freeze
-KERNEL_JS_DIR = File.join(KERNEL_DIR, 'app').freeze
-KERNEL_SPEC_DIR = File.join(KERNEL_DIR, 'spec').freeze
-
-BUILD_CORE_DIR = File.join(BUILD_DIR, 'core').freeze
-BUILD_CORE_KERNEL_DIR = File.join(BUILD_CORE_DIR, 'kernel').freeze
-BUILD_CORE_CSS_DIR = File.join(BUILD_CORE_DIR, 'stylesheets').freeze
-
-ASSETS_DIR = File.join(ROOT_DIR, 'assets').freeze
-ASSETS_IMG_DIR = File.join(ASSETS_DIR, 'images').freeze
-ASSETS_LIB_DIR = File.join(ASSETS_DIR, 'lib').freeze
-ASSETS_CSS_DIR = File.join(ASSETS_DIR, 'stylesheets').freeze
-ASSETS_FONTS_DIR = File.join(ASSETS_DIR, 'fonts').freeze
-
-APACHE_DIR = File.join(ROOT_DIR, 'web', 'apache').freeze
-WEB_DIR = File.join(ROOT_DIR, 'web').freeze
-APACHE_LOGS_DIR = File.join(APACHE_DIR, 'logs').freeze
-
-CONFIG_DIR = File.join(ROOT_DIR, 'config').freeze
-CONFIG_YAML = File.join(CONFIG_DIR, 'environments.yml').freeze
-CONFIG_TEMPLATE_DIR = File.join(CONFIG_DIR, 'templates').freeze
-CONFIG_RESULT_DIR = File.join(CONFIG_DIR, 'result').freeze
-directory CONFIG_RESULT_DIR
-
-CONFIG = {}
-
-[:ios, :droid, :web].each do |os|
- CONFIG[os] = {}
- CONFIG[os][:root] = File.join(ROOT_DIR, os.to_s)
- CONFIG[os][:public] = if os == :ios
- File.join(CONFIG[os][:root], 'Shopping.Booking', 'ShoppingResources', 'public').freeze
- else
- if os == :droid
- File.join(CONFIG[os][:root], app_name, 'assets', 'hybrid').freeze
- else
- File.join(CONFIG[os][:root], 'public').freeze
- end
- end
- CONFIG[os][:html] = File.join(CONFIG[os][:public], 'views').freeze
- CONFIG[os][:assets] = if os == :ios
- File.join(CONFIG[os][:public], 'assets').freeze
- else
- CONFIG[os][:public]
- end
- CONFIG[os][:imgs] = File.join(CONFIG[os][:assets], 'images').freeze
- CONFIG[os][:js] = File.join(CONFIG[os][:assets], 'scripts').freeze
- CONFIG[os][:css] = File.join(CONFIG[os][:assets], 'styles').freeze
- CONFIG[os][:fonts] = File.join(CONFIG[os][:assets], 'fonts').freeze
- CONFIG[os][:layout] = File.join(CONFIG[os][:root], "app", "views").freeze
-
- directory CONFIG[os][:public]
- directory CONFIG[os][:html]
- directory CONFIG[os][:assets]
- directory CONFIG[os][:imgs]
- directory CONFIG[os][:js]
- directory CONFIG[os][:css]
- directory CONFIG[os][:fonts]
+require 'rspec/core/rake_task'
+require 'cucumber'
+require 'cucumber/rake/task'
+
+namespace :test do
+ RSpec::Core::RakeTask.new(:rspec) do |t|
+ t.rspec_opts = "--color"
+ end
+
+ Cucumber::Rake::Task.new(:features) do |t|
+ t.cucumber_opts = "features --format pretty"
+ end
end
-CONFIG[:ios][:project_name] = app_name
-CONFIG[:ios][:app_dir] = File.join(CONFIG[:ios][:root], 'Source', app_name)
-CONFIG[:ios][:cucumber] = FEATURES_DIR
-
-directory BUILD_CORE_DIR
-directory BUILD_CORE_CSS_DIR
-directory BUILD_CORE_KERNEL_DIR
-
-require 'task_support/assets'
-require 'task_support/calatrava_kernel'
-require 'task_support/haml'
-require 'task_support/apache'
-require 'task_support/artifact'
-require 'task_support/configuration'
-
-Dir.glob('tasks/*.rake').each { |r| import r }
-
-desc "Clean all directories"
-task :clean => ["core:clean", "ios:clean", "bb:clean", "web:clean", "artifact:clean", "droid:clean"] do
- rm_rf BUILD_DIR
-end
+desc "Run all tests"
+task :test => ['test:rspec', 'test:features']
View
5 bin/calatrava 100644 → 100755
@@ -1,3 +1,6 @@
#!/usr/bin/env ruby
-require "calatrava"
+$: << File.join(File.dirname(__FILE__), '..', 'lib')
+require 'calatrava'
+
+Calatrava::App.start
View
9 calatrava.gemspec
@@ -4,9 +4,9 @@ require "calatrava/version"
Gem::Specification.new do |s|
s.name = "calatrava"
- s.version = Calatrava::VERSION
+ s.version = Calatrava::Version
s.authors = ["Giles Alexander"]
- s.email = ["giles.alexander@gmail.com"]
+ s.email = ["gga@thoughtworks.com"]
s.homepage = ""
s.summary = %q{TODO: Write a gem summary}
s.description = %q{TODO: Write a gem description}
@@ -18,7 +18,8 @@ Gem::Specification.new do |s|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]
- # specify any dependencies here; for example:
# s.add_development_dependency "rspec"
- # s.add_runtime_dependency "rest-client"
+ s.add_runtime_dependency "mustache"
+ s.add_runtime_dependency "haml"
+ s.add_runtime_dependency "sass"
end
View
14 features/cli.feature
@@ -0,0 +1,14 @@
+Feature: Command line interface
+
+ In order to create cross platform mobile apps
+ As a mobile developer
+ I want an easy to use command line tool
+
+ Scenario: Command-line validations
+ When I run `calatrava create`
+ Then the output should contain "calatrava create requires at least 1 argument"
+ When I run `calatrava create project --template nonexistentdirectory`
+ Then the output should contain "template must exist"
+ Given an empty file named "alt-template-file"
+ When I run `calatrava create project --template alt-template-file`
+ Then the output should contain "template must be a directory"
View
48 features/project.feature
@@ -0,0 +1,48 @@
+Feature: Projects
+
+ In order to save money but still create the most awesome mobile app
+ As a cross-platform mobile developer
+ I want to use Calatrava to create a project
+
+ Scenario: Create a project using the standard Calatrava template
+ When I run `calatrava create simple`
+ Then the exit status should be 0
+ And the following directories should exist:
+ | simple |
+ | simple/config |
+ | simple/droid |
+ | simple/features |
+ | simple/ios |
+ | simple/kernel |
+ | simple/shell |
+ | simple/web |
+ And the file "simple/calatrava.yml" should contain "project_name: simple"
+
+ Scenario: Templates can have deeply nested directories and files
+ Given the following directories exist:
+ | nested |
+ | nested/dir |
+ | nested/dir/sub |
+ And the following files exist:
+ | nested/sample |
+ | nested/.config |
+ | nested/dir/sub/sample2 |
+ When I run `calatrava create proj --template nested`
+ Then the following directories should exist:
+ | proj |
+ | proj/dir |
+ | proj/dir/sub |
+ And the following files should exist:
+ | proj/sample |
+ | proj/.config |
+ | proj/dir/sub/sample2 |
+
+ Scenario: Template files can themselves be templates
+ Given a directory named "template"
+ And a file named "template/.tmpl.calatrava" with:
+ """
+ Sample {{ project_name }}
+ """
+ When I run `calatrava create templatized --template template`
+ Then a file named "templatized/.tmpl" should exist
+ And the file "templatized/.tmpl" should contain "Sample templatized"
View
8 features/step_definitions/template_steps.rb
@@ -0,0 +1,8 @@
+Given /^the following directories exist:$/ do |directories|
+ directories.raw.each { |dir_row| create_dir(dir_row[0]) }
+end
+
+Given /^the following files exist:$/ do |files|
+ files.raw.each { |file_row| write_file(file_row[0], "") }
+end
+
View
5 features/support/env.rb
@@ -0,0 +1,5 @@
+require 'aruba/cucumber'
+
+ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
+
+ENV['RUBYLIB'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../lib')}#{File::PATH_SEPARATOR}#{ENV['RUBYLIB']}"
View
9 lib/calatrava.rb
@@ -1,5 +1,4 @@
-require "calatrava/version"
-
-module Calatrava
- # Your code goes here...
-end
+require 'calatrava/version'
+require 'calatrava/app'
+require 'calatrava/project'
+require 'calatrava/template'
View
30 lib/calatrava/app.rb
@@ -0,0 +1,30 @@
+require 'thor'
+
+module Calatrava
+
+ class App < Thor
+
+ desc "create <project-name>", "creates a new calatrava app project"
+ method_options :template => File.join(File.dirname(__FILE__), 'templates'), :dev => false
+ def create(project_name)
+ die "template must exist" unless File.exist?(options[:template])
+ die "template must be a directory" unless File.directory?(options[:template])
+
+ proj = Project.new(project_name,
+ :is_dev => options.dev?)
+ proj.create(Template.new(options[:template]))
+ end
+
+ no_tasks do
+
+ def die(message)
+ $stderr.puts message
+ exit 1
+ end
+
+ end
+
+ end
+
+end
+
View
57 lib/calatrava/project.rb
@@ -0,0 +1,57 @@
+require 'mustache'
+require 'yaml'
+
+module Calatrava
+
+ class Project
+
+ attr_reader :name
+
+ def initialize(name, overrides = {})
+ @name = name
+ @options = {}
+ if File.exists?(@name) && File.directory?(@name)
+ @options = YAML.load(IO.read(File.join(@name, 'calatrava.yml')))
+ @name = @options[:project_name]
+ end
+ @options.merge! overrides
+ end
+
+ def dev?
+ @options[:is_dev]
+ end
+
+ def create(template)
+ create_project(template)
+ create_directory_tree(template)
+ create_files(template)
+ end
+
+ def create_project(template)
+ FileUtils.mkdir_p @name
+ File.open(File.join(@name, 'calatrava.yml'), "w+") do |f|
+ f.print({:project_name => @name}.to_yaml)
+ end
+ end
+
+ def create_directory_tree(template)
+ template.walk_directories do |dir|
+ FileUtils.mkdir_p(File.join(@name, dir))
+ end
+ end
+
+ def create_files(template)
+ template.walk_files do |file_info|
+ if File.extname(file_info[:name]) == ".calatrava"
+ File.open(File.join(@name, file_info[:name].gsub(".calatrava", "")), "w+") do |f|
+ f.print(Mustache.render(IO.read(file_info[:path]), :project_name => @name, :dev? => dev?))
+ end
+ else
+ FileUtils.cp(file_info[:path], File.join(@name, file_info[:name]))
+ end
+ end
+ end
+
+ end
+
+end
View
95 lib/calatrava/tasks.rb
@@ -0,0 +1,95 @@
+$: << File.dirname(__FILE__)
+require 'calatrava/project'
+
+def cp_ne(source, dest_dir)
+ cp Dir[source], dest_dir
+end
+
+project = Calatrava::Project.new(".")
+
+ROOT_DIR = "."
+BUILD_DIR = File.join(ROOT_DIR, 'build').freeze
+
+SHELL_DIR = File.join(ROOT_DIR, 'shell').freeze
+SHELL_LAYOUTS_DIR = File.join(SHELL_DIR, 'layouts').freeze
+SHELL_VIEWS_DIR = File.join(SHELL_DIR, 'views').freeze
+SHELL_PARTIALS_DIR = File.join(SHELL_DIR, 'partials').freeze
+SHELL_JS_DIR = File.join(SHELL_DIR, 'support').freeze
+
+FEATURES_DIR = File.join(ROOT_DIR, 'features').freeze
+FEATURE_RESULTS_DIR = File.join(ROOT_DIR, 'results').freeze
+
+
+KERNEL_DIR = File.join(ROOT_DIR, 'kernel').freeze
+KERNEL_JS_DIR = File.join(KERNEL_DIR, 'app').freeze
+KERNEL_SPEC_DIR = File.join(KERNEL_DIR, 'spec').freeze
+
+BUILD_CORE_DIR = File.join(BUILD_DIR, 'core').freeze
+BUILD_CORE_KERNEL_DIR = File.join(BUILD_CORE_DIR, 'kernel').freeze
+BUILD_CORE_CSS_DIR = File.join(BUILD_CORE_DIR, 'stylesheets').freeze
+
+ASSETS_DIR = File.join(ROOT_DIR, 'assets').freeze
+ASSETS_IMG_DIR = File.join(ASSETS_DIR, 'images').freeze
+ASSETS_LIB_DIR = File.join(ASSETS_DIR, 'lib').freeze
+ASSETS_CSS_DIR = File.join(ASSETS_DIR, 'stylesheets').freeze
+ASSETS_FONTS_DIR = File.join(ASSETS_DIR, 'fonts').freeze
+
+APACHE_DIR = File.join(ROOT_DIR, 'web', 'apache').freeze
+WEB_DIR = File.join(ROOT_DIR, 'web').freeze
+APACHE_LOGS_DIR = File.join(APACHE_DIR, 'logs').freeze
+
+CONFIG_DIR = File.join(ROOT_DIR, 'config').freeze
+CONFIG_YAML = File.join(CONFIG_DIR, 'environments.yml').freeze
+CONFIG_TEMPLATE_DIR = File.join(CONFIG_DIR, 'templates').freeze
+CONFIG_RESULT_DIR = File.join(CONFIG_DIR, 'result').freeze
+directory CONFIG_RESULT_DIR
+
+CONFIG = {}
+
+[:ios, :droid, :web].each do |os|
+ CONFIG[os] = {}
+ CONFIG[os][:root] = File.join(ROOT_DIR, os.to_s)
+ CONFIG[os][:public] = if os == :ios
+ File.join(CONFIG[os][:root], 'Shopping.Booking', 'ShoppingResources', 'public').freeze
+ else
+ if os == :droid
+ File.join(CONFIG[os][:root], project.name, 'assets', 'hybrid').freeze
+ else
+ File.join(CONFIG[os][:root], 'public').freeze
+ end
+ end
+ CONFIG[os][:html] = File.join(CONFIG[os][:public], 'views').freeze
+ CONFIG[os][:assets] = if os == :ios
+ File.join(CONFIG[os][:public], 'assets').freeze
+ else
+ CONFIG[os][:public]
+ end
+ CONFIG[os][:imgs] = File.join(CONFIG[os][:assets], 'images').freeze
+ CONFIG[os][:js] = File.join(CONFIG[os][:assets], 'scripts').freeze
+ CONFIG[os][:css] = File.join(CONFIG[os][:assets], 'styles').freeze
+ CONFIG[os][:fonts] = File.join(CONFIG[os][:assets], 'fonts').freeze
+ CONFIG[os][:layout] = File.join(CONFIG[os][:root], "app", "views").freeze
+
+ directory CONFIG[os][:public]
+ directory CONFIG[os][:html]
+ directory CONFIG[os][:assets]
+ directory CONFIG[os][:imgs]
+ directory CONFIG[os][:js]
+ directory CONFIG[os][:css]
+ directory CONFIG[os][:fonts]
+end
+
+CONFIG[:ios][:project_name] = project.name
+CONFIG[:ios][:app_dir] = File.join(CONFIG[:ios][:root], 'Source', project.name)
+CONFIG[:ios][:cucumber] = FEATURES_DIR
+
+directory BUILD_CORE_DIR
+directory BUILD_CORE_CSS_DIR
+directory BUILD_CORE_KERNEL_DIR
+
+Dir["#{File.join(File.dirname(__FILE__), 'tasks')}/*.rb"].each { |t| require t }
+
+desc "Clean all directories"
+task :clean => ["core:clean", "ios:clean", "bb:clean", "web:clean", "artifact:clean", "droid:clean"] do
+ rm_rf BUILD_DIR
+end
View
0 task_support/apache.rb → lib/calatrava/tasks/apache.rb
File renamed without changes.
View
9 task_support/artifact.rb → lib/calatrava/tasks/artifact.rb
@@ -13,3 +13,12 @@ def artifact_dir(source_path, name)
def artifact_path(sub_path)
File.join("artifacts", sub_path)
end
+
+namespace :artifact do
+
+ desc "Removes all pre-existing artifacts"
+ task :clean do
+ rm_rf "artifacts/*.*"
+ end
+
+end
View
3 lib/calatrava/tasks/assets.rb
@@ -0,0 +1,3 @@
+def coffee(in_dir, out_dir)
+ sh "node_modules/coffee-script/bin/coffee --compile --output #{out_dir} #{in_dir}" unless Dir["in_dir/**/*.coffee"].empty?
+end
View
0 tasks/automation.rake → lib/calatrava/tasks/automation.rb
File renamed without changes.
View
5 lib/calatrava/tasks/bootstrap.rb
@@ -0,0 +1,5 @@
+desc "Installs all required Ruby gems and Node.js packages for your new Calatrava project."
+task :bootstrap do
+ sh "bundle install"
+ sh "npm install"
+end
View
0 task_support/calatrava_kernel.rb → lib/calatrava/tasks/calatrava_kernel.rb
File renamed without changes.
View
20 task_support/configuration.rb → lib/calatrava/tasks/configuration.rb
@@ -19,3 +19,23 @@ def config_path(file)
def app_name
end
+
+TEMPLATES = FileList["#{CONFIG_TEMPLATE_DIR}/*.erb"]
+
+namespace :configure do
+
+ %w{local development test automation production}.each do |environment|
+ desc "Create config files for #{environment} environment"
+ task environment.to_sym => [:clean, CONFIG_RESULT_DIR] do
+ configuration = config_for(environment)
+ TEMPLATES.each do |template|
+ evaluate_template(template, configuration)
+ end
+ artifact_dir(CONFIG_RESULT_DIR, environment)
+ end
+ end
+
+ task :clean do
+ rm_rf CONFIG_RESULT_DIR
+ end
+end
View
2 tasks/droid.rake → lib/calatrava/tasks/droid.rb
@@ -14,7 +14,7 @@
desc "Compile droid-specific coffee to javascript"
task :coffee => CONFIG[:droid][:assets] do
- sh "coffee --compile --output #{CONFIG[:droid][:js]} #{File.join(CONFIG[:droid][:root], "app")}"
+ coffee File.join(CONFIG[:droid][:root], "app"), CONFIG[:droid][:js]
end
desc "Copies required assets for droid"
View
0 task_support/haml.rb → lib/calatrava/tasks/haml.rb
File renamed without changes.
View
0 tasks/ios.rake → lib/calatrava/tasks/ios.rb
File renamed without changes.
View
22 tasks/kernel.rake → lib/calatrava/tasks/kernel.rb
@@ -1,9 +1,9 @@
namespace :kernel do
- directory "build/kernel/js" => "build"
+ directory "build/kernel/js"
desc "Build kernel js files"
- task :kernel => "build/kernel/js" do
+ task :coffee => "build/kernel/js" do
coffee "kernel/app", "build/kernel/js"
end
@@ -16,31 +16,29 @@
task :spec => 'kernel/.node_updated' do |t, args|
cd "kernel" do
ENV['NODE_PATH'] = "app:#{Calatrava.src_paths}:spec:../assets/lib"
- sh "node_modules/jasmine-node/bin/jasmine-node --coffee --test-dir kernel/spec"
+ sh "../node_modules/jasmine-node/bin/jasmine-node --coffee --test-dir kernel/spec"
end
end
- file 'kernel/.node_updated' => 'kernel/package.json' do
- cd "kernel" do
- sh "npm install"
- sh "touch .node_updated"
- end
+ file '.node_updated' => 'package.json' do
+ sh "npm install"
+ sh "touch .node_updated"
end
desc "Run cucumber.js features for kernel"
- task :features, [:file] => ['kernel/.node_updated', :create_sim_link] do |t, args|
+ task :features, [:file] => ['.node_updated', :create_sim_link] do |t, args|
cd "kernel" do
ENV['NODE_PATH'] = "#{CalatravaKernel.src_paths}:features/support:../assets/lib:features/step_definitions:../features/testdata"
features_to_be_run = args[:file] ? "#{kernel/features}/#{args[:file]}" : "features"
- sh "node_modules/cucumber/bin/cucumber.js --tags @all,@kernel --tags ~@wip '#{features_to_be_run}'"
+ sh "../node_modules/cucumber/bin/cucumber.js --tags @all,@kernel --tags ~@wip '#{features_to_be_run}'"
end
end
namespace :features do
- task :wip => ['kernel/.node_updated', :create_sim_link] do
+ task :wip => ['.node_updated', :create_sim_link] do
cd "kernel" do
ENV['NODE_PATH'] = "#{CalatravaKernel.src_paths}:features/support:../assets/lib:features/step_definitions:../features/testdata"
- sh "node_modules/cucumber/bin/cucumber.js --tags @wip --tags @kernel features"
+ sh "../node_modules/cucumber/bin/cucumber.js --tags @wip --tags @kernel features"
end
end
end
View
0 tasks/precommit.rake → lib/calatrava/tasks/precommit.rb
File renamed without changes.
View
0 tasks/release.rake → lib/calatrava/tasks/release.rb
File renamed without changes.
View
17 lib/calatrava/tasks/shell.rb
@@ -0,0 +1,17 @@
+namespace :shell do
+
+ directory "build/shell/css"
+ directory "build/shell/js"
+
+ desc "Convert core scss to css"
+ task :scss => "build/shell/css" do
+ sh "sass --update shell/stylesheets"
+ cp_ne "shell/stylesheets/*.css", "build/shell/css"
+ end
+
+ desc "Build shell js files"
+ task :coffee => "build/shell/js" do
+ coffee "shell/app/", "build/shell/js"
+ end
+
+end
View
12 tasks/web.rake → lib/calatrava/tasks/web.rb
@@ -10,18 +10,18 @@
coffee File.join(CONFIG[:web][:root], "app", "source"), CONFIG[:web][:js]
end
- task :shared => ["core:scss", "core:shell", "core:kernel", :haml, :coffee,
+ task :shared => ["shell:scss", "shell:coffee", "kernel:coffee", :haml, :coffee,
CONFIG[:web][:css], CONFIG[:web][:imgs], CONFIG[:web][:js], CONFIG[:web][:fonts]] do
- sh "cp #{BUILD_CORE_CSS_DIR}/*.css #{CONFIG[:web][:css]}"
- sh "cp #{ASSETS_IMG_DIR}/* #{CONFIG[:web][:imgs]}"
- sh "cp #{ASSETS_LIB_DIR}/*.js #{CONFIG[:web][:js]}"
+ cp_ne "#{BUILD_CORE_CSS_DIR}/*.css", CONFIG[:web][:css]
+ cp_ne "#{ASSETS_IMG_DIR}/*", CONFIG[:web][:imgs]
+ cp_ne "#{ASSETS_LIB_DIR}/*.js", CONFIG[:web][:js]
CalatravaKernel.modules.each do |library|
sh "cp #{BUILD_CORE_KERNEL_DIR}/#{library}/*.js #{CONFIG[:web][:js]}"
end
- sh "cp #{BUILD_CORE_KERNEL_DIR}/*.js #{CONFIG[:web][:js]}"
- sh "cp #{ASSETS_FONTS_DIR}/* #{CONFIG[:web][:fonts]}"
+ cp_ne "#{BUILD_CORE_KERNEL_DIR}/*.js", CONFIG[:web][:js]
+ cp_ne "#{ASSETS_FONTS_DIR}/*", CONFIG[:web][:fonts]
end
desc "Prepares config for the app"
View
40 lib/calatrava/template.rb
@@ -0,0 +1,40 @@
+module Calatrava
+
+ class Template
+
+ def initialize(directory)
+ @directory = directory
+ end
+
+ def target_name(item)
+ item.sub("#{@directory}/", "")
+ end
+
+ def walk_tree(start_dir, &blk)
+ Dir["#{start_dir}/{*,.*}"].each do |item|
+ blk.call item
+ if File.directory?(item) && !(item =~ /\/\.$/) && !(item =~ /\/\.\.$/)
+ walk_tree(item, &blk)
+ end
+ end
+ end
+
+ def walk_directories(&blk)
+ walk_tree(@directory) do |item|
+ if File.directory?(item)
+ blk.call target_name(item)
+ end
+ end
+ end
+
+ def walk_files(&blk)
+ walk_tree(@directory) do |item|
+ if File.file? item
+ blk.call(:path => item, :name => target_name(item))
+ end
+ end
+ end
+
+ end
+
+end
View
2 lib/calatrava/templates/.rvmrc.calatrava
@@ -0,0 +1,2 @@
+rvm_install_on_use_flag=1
+rvm --create use ruby-1.9.3-p0@{{ project_name }}
View
4 lib/calatrava/templates/Gemfile.calatrava
@@ -0,0 +1,4 @@
+source :rubygems
+
+gem "rake"
+gem "calatrava"{{#dev?}}, :path => '../'{{/dev?}}
View
1 lib/calatrava/templates/Rakefile
@@ -0,0 +1 @@
+require 'calatrava/tasks'
View
6 lib/calatrava/templates/ios/.gitignore
@@ -1,6 +0,0 @@
-.DS_Store
-chromedriver.log
-*xcuserdata*
-
-FlightsApp/DerivedData/
-
View
0 lib/calatrava/templates/kernel/package.json → lib/calatrava/templates/package.json
File renamed without changes.
View
1 lib/calatrava/templates/shell/shell.scss
@@ -0,0 +1 @@
+# Define your custom styles for all platforms here.
View
2 lib/calatrava/version.rb
@@ -1,3 +1,3 @@
module Calatrava
- VERSION = "0.0.1"
+ Version = "0.0.1"
end
View
3 task_support/assets.rb
@@ -1,3 +0,0 @@
-def coffee(in_dir, out_dir)
- sh "coffee --compile --output #{out_dir} #{in_dir}"
-end
View
8 tasks/artifact.rake
@@ -1,8 +0,0 @@
-namespace :artifact do
-
- desc "Removes all pre-existing artifacts"
- task :clean do
- rm_rf "artifacts/*.*"
- end
-
-end
View
19 tasks/configuration.rake
@@ -1,19 +0,0 @@
-TEMPLATES = FileList["#{CONFIG_TEMPLATE_DIR}/*.erb"]
-
-namespace :configure do
-
- %w{local development test automation production}.each do |environment|
- desc "Create config files for #{environment} environment"
- task environment.to_sym => [:clean, CONFIG_RESULT_DIR] do
- configuration = config_for(environment)
- TEMPLATES.each do |template|
- evaluate_template(template, configuration)
- end
- artifact_dir(CONFIG_RESULT_DIR, environment)
- end
- end
-
- task :clean do
- rm_rf CONFIG_RESULT_DIR
- end
-end
View
18 tasks/shell.rake
@@ -1,18 +0,0 @@
-namespace :shell do
-
- directory "build/shell" => "build"
- directory "build/shell/css" => "build/shell"
- directory "build/shell/js" => "build/shell"
-
- desc "Convert core scss to css"
- task :scss => "build/shell/css" do
- sh "sass --update shell/stylesheets"
- sh "cp shell/stylesheets/*.css build/shell/css"
- end
-
- desc "Build shell js files"
- task :shell => "build/shell/js" do
- coffee "shell/app", "build/shell/js"
- end
-
-end

0 comments on commit c3f4444

Please sign in to comment.
Something went wrong with that request. Please try again.