Class: Serve::Project

Inherits:
Object
  • Object
show all
Includes:
JavaScripts, Out, Path
Defined in:
lib/serve/project.rb

Overview

Serve::Project.new(options).create Serve::Project.new(options).convert

Constant Summary

Constant Summary

Constants included from JavaScripts

JavaScripts::GOOGLE_AJAX_APIS, JavaScripts::JAVASCRIPT_FRAMEWORKS, JavaScripts::JQUERY_UI_VERSION, JavaScripts::JQUERY_VERSION, JavaScripts::MOOTOOLS_VERSION, JavaScripts::PROTOTYPE_VERSION, JavaScripts::SCRIPTACULOUS_VERSION

Constants included from Out

Out::COLORS, Out::COLUMN_WIDTH

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from JavaScripts

#fetch_javascript, #javascript_filename, #javascript_framework_url, #jquery_ui_url, #jquery_url, #mootools_url, #prototype_url, #scriptaculous_url, #supported_javascript_frameworks, #valid_javascript_framework?

Methods included from Path

#glob_path, #normalize_path

Methods included from Out

#color, #color_msg, #log_action, #log_error, #print, #puts, #stderr, #stderr=, #stdout, #stdout=

Constructor Details

#initialize(options) ⇒ Project

Returns a new instance of Project



14
15
16
17
18
# File 'lib/serve/project.rb', line 14

def initialize(options)
  @location   = normalize_path(options[:directory])
  @framework  = options[:framework]
  @template   = options[:template] || 'default'
end

Instance Attribute Details

#frameworkObject (readonly)

:nodoc:



12
13
14
# File 'lib/serve/project.rb', line 12

def framework
  @framework
end

#locationObject (readonly)

:nodoc:



12
13
14
# File 'lib/serve/project.rb', line 12

def location
  @location
end

#templateObject (readonly)

:nodoc:



12
13
14
# File 'lib/serve/project.rb', line 12

def template
  @template
end

Class Method Details

.convert(options = {}) ⇒ Object



59
60
61
# File 'lib/serve/project.rb', line 59

def self.convert(options={})
  new(options).convert
end

.create(options = {}) ⇒ Object



35
36
37
# File 'lib/serve/project.rb', line 35

def self.create(options={})
  new(options).create
end

Instance Method Details

#convertObject

Convert an existing Compass project to a Serve project



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/serve/project.rb', line 40

def convert
  setup_base
  move_file 'images', 'public/'
  move_file 'stylesheets', 'public/'
  if File.directory? "#{@location}/javascripts"
    move_file 'javascripts', 'public/'
  else
    make_path 'public/javascripts'
  end
  if File.directory? "#{@location}/src"
    move_file 'src', 'stylesheets'
  elsif File.directory? "#{@location}/sass"
    move_file 'sass', 'styleheets'
  end
  install_javascript_framework @framework
  copy_readme
  post_convert_message
end

#createObject

Create a new Serve project



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/serve/project.rb', line 21

def create
  setup_base
  %w(
    public/images
    public/javascripts
    public/stylesheets
    stylesheets
  ).each { |path| make_path path } 
  copy_project_template @template
  install_javascript_framework @framework
  copy_readme
  post_create_message
end