Class: Lanes::Command::GenerateScreen

Inherits:
NamedCommand
  • Object
show all
Defined in:
lib/lanes/command/generate_screen.rb

Constant Summary collapse

OPTIONS =
{
    title:       '',
    description: '',
    icon:        '',
    group_id:    'system',
    model_class: '',
    namespace: nil
}

Instance Attribute Summary collapse

Attributes inherited from NamedCommand

#class_name, #client_dir, #identifier, #namespace, #spec_dir

Instance Method Summary collapse

Methods inherited from NamedCommand

#load_namespace, source_root

Instance Attribute Details

#screen_idObject (readonly)

Returns the value of attribute screen_id.



17
18
19
# File 'lib/lanes/command/generate_screen.rb', line 17

def screen_id
  @screen_id
end

Instance Method Details

#add_definitionObject



33
34
35
36
37
38
# File 'lib/lanes/command/generate_screen.rb', line 33

def add_definition
    append_to_file "config/screens.rb" do
        source = File.expand_path(find_in_source_paths("config/screen.rb"))
        ERB.new(::File.binread(source), nil, "-","@output_buffer").result(binding)
    end
end

#create_screenObject



25
26
27
28
29
30
31
# File 'lib/lanes/command/generate_screen.rb', line 25

def create_screen
    template "client/screens/index.js",      "#{client_dir}/screens/#{screen_id}/index.js"
    template "client/screens/styles.scss",   "#{client_dir}/screens/#{screen_id}/index.scss"
    template "client/screens/Screen.coffee", "#{client_dir}/screens/#{screen_id}/#{class_name}.coffee"
    template "client/screens/layout.html",   "#{client_dir}/screens/#{screen_id}/layout.html"
    template "spec/client/Screen.coffee",    "#{spec_dir}/screens/#{screen_id}/#{class_name}Spec.coffee"
end

#set_variablesObject



19
20
21
22
23
# File 'lib/lanes/command/generate_screen.rb', line 19

def set_variables
    super
    options[:title] = name.titleize if options[:title].blank?
    @screen_id = class_name.underscore.dasherize
end