Class: Serve::Project

Inherits:
Object
  • Object
show all
Includes:
JavaScripts, Out
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

Instance Attribute 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 Out

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

Constructor Details

#initialize(options) ⇒ Project



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

def initialize(options)
  @name       = options[:name]
  @location   = normalize_location(options[:directory], @name)
  @full_name  = git_config('user.name') || 'Your Full Name'
  @framework  = options[:framework]
end

Instance Attribute Details

#frameworkObject (readonly)

:nodoc:



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

def framework
  @framework
end

#locationObject (readonly)

:nodoc:



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

def location
  @location
end

#nameObject (readonly)

:nodoc:



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

def name
  @name
end

Instance Method Details

#convertObject

Convert an existing Compass project to a Serve project



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/serve/project.rb', line 38

def convert
  setup_base
  move_file 'images', 'public/'
  move_file 'stylesheets', 'public/'
  if File.directory? 'javascripts'
    move_file 'javascripts', 'public/'
  else
    make_path 'public/javascripts'
  end
  move_file 'src', 'sass'
  install_javascript_framework @framework
  note_old_compass_config
end

#createObject

Create a new Serve project



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

def create
  setup_base
  %w(
    public/images
    public/javascripts
    public/stylesheets
    sass
  ).each { |path| make_path path } 
  create_file 'sass/application.sass',  read_template('application.sass')
  create_file 'views/_layout.html.erb', read_template('_layout.html.erb')
  create_file 'views/hello.html.erb',   read_template('hello.html.erb')
  create_file 'views/view_helpers.rb',  read_template('view_helpers.rb')
  create_file 'views/index.redirect',   read_template('index.redirect')
  install_javascript_framework @framework
end