Module: Saruman::Base

Instance Method Summary collapse

Instance Method Details

#app_design_frontend_base_layout_local_xml_pathObject



115
116
117
# File 'lib/saruman.rb', line 115

def app_design_frontend_base_layout_local_xml_path
  "#{app_design_frontend_base_path}layout/#{name_lower}.xml"
end

#app_design_frontend_base_layout_pathObject



111
112
113
# File 'lib/saruman.rb', line 111

def app_design_frontend_base_layout_path
  "#{app_design_frontend_base_path}layout/"
end

#app_design_frontend_base_pathObject



101
102
103
104
105
106
107
108
109
# File 'lib/saruman.rb', line 101

def app_design_frontend_base_path
  newer_magento_base_path = "#{Dir.pwd}/app/design/frontend/base/default/"
  older_magento_base_path = "#{Dir.pwd}/app/design/frontend/default/default/"
  if File.directory?(newer_magento_base_path)
    return newer_magento_base_path
  else
    return older_magento_base_path
  end
end

#app_design_frontend_base_template_namespace_pathObject



123
124
125
# File 'lib/saruman.rb', line 123

def app_design_frontend_base_template_namespace_path
  "#{app_design_frontend_base_template_path}#{name_lower}/"
end

#app_design_frontend_base_template_pathObject



119
120
121
# File 'lib/saruman.rb', line 119

def app_design_frontend_base_template_path
  "#{app_design_frontend_base_path}template/"
end

#authorObject



147
148
149
# File 'lib/saruman.rb', line 147

def author
  arguments[:author]
end

#block_klass_nameObject



73
74
75
# File 'lib/saruman.rb', line 73

def block_klass_name
  "#{combined_namespace}_Block"
end

#combined_namespaceObject



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

def combined_namespace
  "#{arguments[:namespace]}_#{arguments[:name]}"
end

#commandObject



139
140
141
# File 'lib/saruman.rb', line 139

def command
  arguments[:command]
end

#config_has_tag?(tag_lookup) ⇒ Boolean

Returns:

  • (Boolean)


214
215
216
217
218
219
220
221
# File 'lib/saruman.rb', line 214

def config_has_tag?(tag_lookup)
  target = @config.css(tag_lookup).first
  if target.nil?
    return false
  else
    return true
  end
end

#controller?Boolean

Returns:

  • (Boolean)


163
164
165
166
167
168
169
# File 'lib/saruman.rb', line 163

def controller?
  if arguments[:controller] == true
    return true
  else
    return false
  end
end

#controller_block_file_path(controller_name) ⇒ Object



97
98
99
# File 'lib/saruman.rb', line 97

def controller_block_file_path(controller_name)
  "#{controller_block_path}#{controller_name.capitalize}.php"      
end

#controller_block_pathObject



93
94
95
# File 'lib/saruman.rb', line 93

def controller_block_path
  "#{extension_base_path}Block/"
end

#controller_front_nameObject



175
176
177
# File 'lib/saruman.rb', line 175

def controller_front_name
  arguments[:controller_front_name]
end

#controller_pathObject



57
58
59
# File 'lib/saruman.rb', line 57

def controller_path
  "#{extension_base_path}controllers/"
end

#controllersObject



171
172
173
# File 'lib/saruman.rb', line 171

def controllers
  arguments[:controllers]
end

#extension_base_pathObject



41
42
43
# File 'lib/saruman.rb', line 41

def extension_base_path
  "#{Dir.pwd}/app/code/local/#{namespace}/#{name}/"
end

#extension_config_file_pathObject



187
188
189
# File 'lib/saruman.rb', line 187

def extension_config_file_path
  "#{extension_config_path}config.xml"
end

#extension_config_pathObject



49
50
51
# File 'lib/saruman.rb', line 49

def extension_config_path
  "#{extension_base_path}etc/"
end

#extension_current_versionObject



204
205
206
# File 'lib/saruman.rb', line 204

def extension_current_version
  @extension_current_version = @config.css("version").first.content
end

#extension_name_lowerObject



33
34
35
# File 'lib/saruman.rb', line 33

def extension_name_lower
  name.downcase
end

#extension_temp_pathObject



45
46
47
# File 'lib/saruman.rb', line 45

def extension_temp_path
  "#{extension_base_path}temp/"
end

#extension_upgrade_versionObject



208
209
210
211
212
# File 'lib/saruman.rb', line 208

def extension_upgrade_version
  digits = extension_current_version.to_s.split(".")
  current_version_float = "#{digits[0]}.#{digits[1]}#{digits[2]}".to_f
  @extension_upgrade_version = (current_version_float + 0.01).to_s.sub(".", "").chars.to_a.join(".")
end

#global_config_basepathObject



37
38
39
# File 'lib/saruman.rb', line 37

def global_config_basepath
  "#{Dir.pwd}/app/etc/modules/"
end

#global_config_file_pathObject



89
90
91
# File 'lib/saruman.rb', line 89

def global_config_file_path
  "#{global_config_basepath}#{combined_namespace}.xml"
end

#helper?Boolean

Returns:

  • (Boolean)


179
180
181
182
183
184
185
# File 'lib/saruman.rb', line 179

def helper?
  if arguments[:helper] == true
    return true
  else
    return false
  end
end

#helper_pathObject



61
62
63
# File 'lib/saruman.rb', line 61

def helper_path
  "#{extension_base_path}Helper/"
end

#insert_tag_at_node(tag, tag_lookup) ⇒ Object



223
224
225
226
227
228
229
# File 'lib/saruman.rb', line 223

def insert_tag_at_node(tag, tag_lookup)
  target_tag = @config.css(tag_lookup).first
  unless target_tag.nil?
    new_tag = "<#{tag}></#{tag}>"
    target_tag.add_child(new_tag)
  end
end

#insert_xml_at_node(xml, tag_lookup) ⇒ Object



231
232
233
234
235
236
# File 'lib/saruman.rb', line 231

def insert_xml_at_node(xml, tag_lookup)
  target_tag = @config.css(tag_lookup).first
  unless target_tag.nil?
    target_tag.add_child(xml)
  end
end

#model?Boolean

Returns:

  • (Boolean)


127
128
129
130
131
132
133
# File 'lib/saruman.rb', line 127

def model?
  if arguments[:model] == true
    return true
  else
    return false
  end
end

#model_klass_nameObject



77
78
79
# File 'lib/saruman.rb', line 77

def model_klass_name
  "#{combined_namespace}_Model"
end

#model_pathObject



53
54
55
# File 'lib/saruman.rb', line 53

def model_path
  "#{extension_base_path}Model/"
end

#modelsObject



135
136
137
# File 'lib/saruman.rb', line 135

def models
  arguments[:models]
end

#nameObject



17
18
19
# File 'lib/saruman.rb', line 17

def name
  arguments[:name]
end

#name_lowerObject



29
30
31
# File 'lib/saruman.rb', line 29

def name_lower
  name.downcase
end

#namespaceObject



13
14
15
# File 'lib/saruman.rb', line 13

def namespace
  arguments[:namespace]
end

#namespace_lowerObject



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

def namespace_lower
  namespace.downcase
end

#observer?Boolean

Returns:

  • (Boolean)


151
152
153
154
155
156
157
# File 'lib/saruman.rb', line 151

def observer?
  if arguments[:observer] == true
    return true
  else
    return false
  end
end

#observersObject



159
160
161
# File 'lib/saruman.rb', line 159

def observers
  arguments[:observer_events]
end

#read_extension_configObject



191
192
193
194
195
196
# File 'lib/saruman.rb', line 191

def read_extension_config
  config = File.open(extension_config_file_path, "r+")
  @config = Nokogiri::XML(config)
  config.close
  @config
end

#resource_model_klass_nameObject



85
86
87
# File 'lib/saruman.rb', line 85

def resource_model_klass_name
  "#{combined_namespace}_Model_Mysql4"
end

#resource_model_nameObject



81
82
83
# File 'lib/saruman.rb', line 81

def resource_model_name
  "#{extension_name_lower}_mysql4"
end

#resource_model_pathObject



65
66
67
# File 'lib/saruman.rb', line 65

def resource_model_path
  "#{model_path}Mysql4/"
end

#setup_base_pathObject



69
70
71
# File 'lib/saruman.rb', line 69

def setup_base_path
  "#{extension_base_path}sql/#{name_lower}_setup/"
end

#versionObject



143
144
145
# File 'lib/saruman.rb', line 143

def version
  arguments[:version]
end

#write_extension_configObject



198
199
200
201
202
# File 'lib/saruman.rb', line 198

def write_extension_config
  file = File.open(extension_config_file_path,'w')
  file.puts @config.to_xml
  file.close
end