Class: OTPKickOff

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/otp_kickoff.rb

Overview

Thor classes, the magic of tasks!

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.destination_rootObject



25
26
27
# File 'lib/otp_kickoff.rb', line 25

def self.destination_root
  File.expand_path(File.dirname('.'))
end

.source_rootObject

Setup



21
22
23
# File 'lib/otp_kickoff.rb', line 21

def self.source_root
  File.expand_path(File.dirname(__FILE__) + '/..')
end

Instance Method Details

#configureObject



43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/otp_kickoff.rb', line 43

def configure
  #set data about author
  @author_name  = options[:author]
  @author_email = options[:email]
  
  create_file CONFIGURATION_FILE do
    %Q{
author_name: #{author_name}
author_email: #{author_email}
    }
  end
end

#new_applicationObject



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/otp_kickoff.rb', line 61

def new_application
  # set data to templates
  @application_name = options[:name]
  @supervisor_name  = @application_name
  @server_name      = @application_name
  
  @author_name, @author_email = get_config_info
      
  # generate templates
  template 'resources/template.app',          "#{application_name}/src/#{application_name}.app"
  template 'resources/template_app.erl',      "#{application_name}/src/#{application_name}_app.erl"
  template 'resources/template_sup.erl',      "#{application_name}/src/#{application_name}_sup.erl"
  template 'resources/template_server.erl',   "#{application_name}/src/#{application_name}_server.erl"
  template 'resources/template_appstart.erl', "#{application_name}/src/#{application_name}.erl"
  template 'resources/template_include.hrl',  "#{application_name}/src/#{application_name}.hrl"
  
  # create required directories
  empty_directory "#{application_name}/ebin"
  empty_directory "#{application_name}/deps"
  empty_directory "#{application_name}/priv"
end

#new_event_handlerObject



120
121
122
123
124
125
126
127
128
# File 'lib/otp_kickoff.rb', line 120

def new_event_handler
  # set data to templates
  @handler_name = options[:name]
  
  @author_name, @author_email = get_config_info
  
  # generate templates
  template 'resources/template_handler.erl', "#{handler_name}_handler.erl"
end

#new_gen_serverObject



105
106
107
108
109
110
111
112
113
# File 'lib/otp_kickoff.rb', line 105

def new_gen_server
  # set data to templates
  @server_name = options[:name]
  
  @author_name, @author_email = get_config_info
  
  # generate templates
  template 'resources/template_server.erl', "#{server_name}_server.erl"
end

#new_supervisorObject



89
90
91
92
93
94
95
96
97
98
# File 'lib/otp_kickoff.rb', line 89

def new_supervisor
  # set data to templates
  @supervisor_name  = options[:name]
  @application_name = options[:application_name]
  
  @author_name, @author_email = get_config_info
  
  # generate templates
  template 'resources/template_sup.erl', "#{supervisor_name}_sup.erl"
end