Class: Hippo::Command::GenerateScreen

Inherits:
NamedCommand
  • Object
show all
Defined in:
lib/hippo/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_classObject (readonly)

Returns the value of attribute screen_class


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

def screen_class
  @screen_class
end

#screen_idObject (readonly)

Returns the value of attribute screen_id


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

def screen_id
  @screen_id
end

Instance Method Details

#add_definitionObject


31
32
33
34
35
36
# File 'lib/hippo/command/generate_screen.rb', line 31

def add_definition
    insert_into_file "config/screens.rb", :after => /Hippo::Screen.for_extension.*?\n/ 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


26
27
28
29
# File 'lib/hippo/command/generate_screen.rb', line 26

def create_screen
    template "client/screens/screen.jsx", "#{client_dir}/screens/#{screen_id}.jsx"
    template "spec/client/screen.spec.jsx", "spec/client/screens/#{screen_id}.spec.jsx"
end

#set_variablesObject


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

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