Sha256: 74092fc69d03294ff38b43dfd0c11b561253b12ad8371ab40eb3220d87bdd8b8

Contents?: true

Size: 1.48 KB

Versions: 4

Compression:

Stored size: 1.48 KB

Contents

#!/usr/bin/env ruby
require 'rubygems'
require 'rake'

def cwd
  File.expand_path(File.join(File.dirname(__FILE__), '..'))
end

def expand(*paths)
  File.expand_path(File.join(*paths))
end

def rakefile_path
  expand(cwd, 'templates/Rakefile')
end

if ARGV[0] == 'init'
  require 'ftools'
  File.makedirs('spec/javascripts')
  File.makedirs('spec/helpers')

  dest_root = File.expand_path(Dir.pwd)
  dest_spec = expand(dest_root, 'spec')
  dest_spec_javascripts = expand(dest_root, 'spec/javascripts')
  dest_spec_helpers = expand(dest_root, 'spec/helpers')

  unless File.exist?(expand(dest_spec_helpers, 'spec_helper.js'))
    File.copy(expand(cwd, 'templates/spec_helper.js'), dest_spec_helpers)
  end
  unless File.exist?(expand(dest_spec_helpers, 'jasmine_helper.rb'))
    File.copy(expand(cwd, 'templates/jasmine_helper.rb'), dest_spec_helpers)
  end

  File.copy(expand(cwd, 'templates/example_spec.js'), dest_spec_javascripts)

  rails_tasks_dir = expand(dest_root, 'lib', 'tasks')
  if File.exist?(rails_tasks_dir)
    File.makedirs('lib/tasks/jasmine')
    File.copy(rakefile_path, File.join(rails_tasks_dir, 'jasmine/jasmine.rake'))
  else
    if File.exist?(expand(dest_root, 'Rakefile'))
      existing_rakefile = expand(dest_root, 'Rakefile')
      load existing_rakefile
      unless Rake::Task.task_defined?('jasmine')
        open(existing_rakefile, 'a') do |f|
          f.write(File.read(rakefile_path))
        end
      end
    else
      File.copy(rakefile_path, dest_root)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
xian-test-jasmine-0.1.3 bin/jasmine
xian-test-jasmine-0.1.2 bin/jasmine
xian-test-jasmine-0.1.1 bin/jasmine
xian-test-jasmine-0.1.0 bin/jasmine