Class: Jasmine::CommandLineTool

Inherits:
Object
  • Object
show all
Defined in:
lib/jasmine/command_line_tool.rb

Instance Method Summary collapse

Instance Method Details

#copy_boot_jsObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/jasmine/command_line_tool.rb', line 32

def copy_boot_js
  destination_path = File.join('spec', 'javascripts', 'support', 'boot.js')
  if File.exists?(destination_path)
    puts "#{destination_path} already exists"
  else
    require 'jasmine-core'
    source = File.join(Jasmine::Core.path, 'boot.js')
    FileUtils.mkdir_p(File.dirname(destination_path))
    FileUtils.cp(source, destination_path)

    puts 'Jasmine has copied an example boot.js to spec/javascripts/support'
    puts 'To use it set the boot_dir and boot_files keys in jasmine.yml'
    puts ' to point to your custom boot.js'
  end
end

#examplesObject



26
27
28
29
30
# File 'lib/jasmine/command_line_tool.rb', line 26

def examples
  copy_file_structure('examples')

  puts "Jasmine has installed some examples."
end

#initObject



15
16
17
18
19
20
21
22
23
24
# File 'lib/jasmine/command_line_tool.rb', line 15

def init
  ensure_not_rails!

  copy_file_structure('install')

  update_rakefile

  install_path = File.join(jasmine_gem_path, "lib", "jasmine", "command_line_install.txt")
  puts File.read(install_path)
end

#licenseObject



48
49
50
# File 'lib/jasmine/command_line_tool.rb', line 48

def license
  puts File.read(File.join(jasmine_gem_path, "MIT.LICENSE"))
end


52
53
54
55
56
57
58
# File 'lib/jasmine/command_line_tool.rb', line 52

def print_help
  puts "unknown command #{@argv.join(' ')}" unless @argv.empty?
  puts "Usage: jasmine init"
  puts "               examples"
  puts "               copy_boot_js"
  puts "               license"
end

#process(argv) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/jasmine/command_line_tool.rb', line 5

def process(argv)
  @argv = argv

  if @argv.size > 0 && respond_to?(@argv[0])
    public_send(@argv[0])
  else
    print_help
  end
end