Class: Alchemy::Generators::SiteGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/rails/generators/alchemy/site/site_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_javascriptsObject



36
37
38
39
40
41
# File 'lib/rails/generators/alchemy/site/site_generator.rb', line 36

def create_javascripts
  puts "Creating directories and files for site related javascripts..."
  root_js_dir = "#{Rails.root}/app/assets/javascripts"
  empty_directory "#{root_js_dir}/alchemy/sites/#{@parameterized_site_name}"
  template "site.js", "#{root_js_dir}/#{@parameterized_site_name}.js"
end

#create_siteObject



17
18
19
20
21
22
23
24
25
# File 'lib/rails/generators/alchemy/site/site_generator.rb', line 17

def create_site
  site = Alchemy::Site.find_or_initialize_by(name: @site_name, host: @site_host)
  if site.persisted?
    puts "Site #{@site_name} already exists. Skipping creation of Site."
  else
    site.save!
    puts "Created Site #{@site_name} (unpublished)."
  end
end

#create_stylesheetsObject



27
28
29
30
31
32
33
34
# File 'lib/rails/generators/alchemy/site/site_generator.rb', line 27

def create_stylesheets
  puts "Creating directories and files for site related stylesheets..."
  root_css_dir = "#{Rails.root}/app/assets/stylesheets"
  namespaced_site_dir = "#{root_css_dir}/alchemy/sites/#{@parameterized_site_name}"
  empty_directory namespaced_site_dir
  template "site.scss", "#{root_css_dir}/#{@parameterized_site_name}.scss"
  template "_variables.scss", "#{namespaced_site_dir}/_variables.scss"
end

#initObject



11
12
13
14
15
# File 'lib/rails/generators/alchemy/site/site_generator.rb', line 11

def init
  @site_name = site_name
  @parameterized_site_name = site_name.parameterize
  @site_host = site_host
end