Module: Saruman::Base
- Defined in:
- lib/saruman.rb
Instance Method Summary collapse
- #app_design_frontend_base_layout_local_xml_path ⇒ Object
- #app_design_frontend_base_layout_path ⇒ Object
- #app_design_frontend_base_path ⇒ Object
- #app_design_frontend_base_template_namespace_path ⇒ Object
- #app_design_frontend_base_template_path ⇒ Object
- #author ⇒ Object
- #block_klass_name ⇒ Object
- #combined_namespace ⇒ Object
- #command ⇒ Object
- #config_has_tag?(tag_lookup) ⇒ Boolean
- #controller? ⇒ Boolean
- #controller_block_file_path(controller_name) ⇒ Object
- #controller_block_path ⇒ Object
- #controller_front_name ⇒ Object
- #controller_path ⇒ Object
- #controllers ⇒ Object
- #extension_base_path ⇒ Object
- #extension_config_file_path ⇒ Object
- #extension_config_path ⇒ Object
- #extension_current_version ⇒ Object
- #extension_name_lower ⇒ Object
- #extension_temp_path ⇒ Object
- #extension_upgrade_version ⇒ Object
- #global_config_basepath ⇒ Object
- #global_config_file_path ⇒ Object
- #helper? ⇒ Boolean
- #helper_path ⇒ Object
- #insert_tag_at_node(tag, tag_lookup) ⇒ Object
- #insert_xml_at_node(xml, tag_lookup) ⇒ Object
- #model? ⇒ Boolean
- #model_klass_name ⇒ Object
- #model_path ⇒ Object
- #models ⇒ Object
- #name ⇒ Object
- #name_lower ⇒ Object
- #namespace ⇒ Object
- #namespace_lower ⇒ Object
- #observer? ⇒ Boolean
- #observers ⇒ Object
- #read_extension_config ⇒ Object
- #resource_model_klass_name ⇒ Object
- #resource_model_name ⇒ Object
- #resource_model_path ⇒ Object
- #setup_base_path ⇒ Object
- #version ⇒ Object
- #write_extension_config ⇒ Object
Instance Method Details
#app_design_frontend_base_layout_local_xml_path ⇒ Object
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_path ⇒ Object
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_path ⇒ Object
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_path ⇒ Object
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_path ⇒ Object
119 120 121 |
# File 'lib/saruman.rb', line 119 def app_design_frontend_base_template_path "#{app_design_frontend_base_path}template/" end |
#author ⇒ Object
147 148 149 |
# File 'lib/saruman.rb', line 147 def arguments[:author] end |
#block_klass_name ⇒ Object
73 74 75 |
# File 'lib/saruman.rb', line 73 def block_klass_name "#{combined_namespace}_Block" end |
#combined_namespace ⇒ Object
21 22 23 |
# File 'lib/saruman.rb', line 21 def combined_namespace "#{arguments[:namespace]}_#{arguments[:name]}" end |
#command ⇒ Object
139 140 141 |
# File 'lib/saruman.rb', line 139 def command arguments[:command] end |
#config_has_tag?(tag_lookup) ⇒ 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
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_path ⇒ Object
93 94 95 |
# File 'lib/saruman.rb', line 93 def controller_block_path "#{extension_base_path}Block/" end |
#controller_front_name ⇒ Object
175 176 177 |
# File 'lib/saruman.rb', line 175 def controller_front_name arguments[:controller_front_name] end |
#controller_path ⇒ Object
57 58 59 |
# File 'lib/saruman.rb', line 57 def controller_path "#{extension_base_path}controllers/" end |
#controllers ⇒ Object
171 172 173 |
# File 'lib/saruman.rb', line 171 def controllers arguments[:controllers] end |
#extension_base_path ⇒ Object
41 42 43 |
# File 'lib/saruman.rb', line 41 def extension_base_path "#{Dir.pwd}/app/code/local/#{namespace}/#{name}/" end |
#extension_config_file_path ⇒ Object
187 188 189 |
# File 'lib/saruman.rb', line 187 def extension_config_file_path "#{extension_config_path}config.xml" end |
#extension_config_path ⇒ Object
49 50 51 |
# File 'lib/saruman.rb', line 49 def extension_config_path "#{extension_base_path}etc/" end |
#extension_current_version ⇒ Object
204 205 206 |
# File 'lib/saruman.rb', line 204 def extension_current_version @extension_current_version = @config.css("version").first.content end |
#extension_name_lower ⇒ Object
33 34 35 |
# File 'lib/saruman.rb', line 33 def extension_name_lower name.downcase end |
#extension_temp_path ⇒ Object
45 46 47 |
# File 'lib/saruman.rb', line 45 def extension_temp_path "#{extension_base_path}temp/" end |
#extension_upgrade_version ⇒ Object
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_basepath ⇒ Object
37 38 39 |
# File 'lib/saruman.rb', line 37 def global_config_basepath "#{Dir.pwd}/app/etc/modules/" end |
#global_config_file_path ⇒ Object
89 90 91 |
# File 'lib/saruman.rb', line 89 def global_config_file_path "#{global_config_basepath}#{combined_namespace}.xml" end |
#helper? ⇒ 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_path ⇒ Object
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
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_name ⇒ Object
77 78 79 |
# File 'lib/saruman.rb', line 77 def model_klass_name "#{combined_namespace}_Model" end |
#model_path ⇒ Object
53 54 55 |
# File 'lib/saruman.rb', line 53 def model_path "#{extension_base_path}Model/" end |
#models ⇒ Object
135 136 137 |
# File 'lib/saruman.rb', line 135 def models arguments[:models] end |
#name ⇒ Object
17 18 19 |
# File 'lib/saruman.rb', line 17 def name arguments[:name] end |
#name_lower ⇒ Object
29 30 31 |
# File 'lib/saruman.rb', line 29 def name_lower name.downcase end |
#namespace ⇒ Object
13 14 15 |
# File 'lib/saruman.rb', line 13 def namespace arguments[:namespace] end |
#namespace_lower ⇒ Object
25 26 27 |
# File 'lib/saruman.rb', line 25 def namespace_lower namespace.downcase end |
#observer? ⇒ 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 |
#observers ⇒ Object
159 160 161 |
# File 'lib/saruman.rb', line 159 def observers arguments[:observer_events] end |
#read_extension_config ⇒ Object
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_name ⇒ Object
85 86 87 |
# File 'lib/saruman.rb', line 85 def resource_model_klass_name "#{combined_namespace}_Model_Mysql4" end |
#resource_model_name ⇒ Object
81 82 83 |
# File 'lib/saruman.rb', line 81 def resource_model_name "#{extension_name_lower}_mysql4" end |
#resource_model_path ⇒ Object
65 66 67 |
# File 'lib/saruman.rb', line 65 def resource_model_path "#{model_path}Mysql4/" end |
#setup_base_path ⇒ Object
69 70 71 |
# File 'lib/saruman.rb', line 69 def setup_base_path "#{extension_base_path}sql/#{name_lower}_setup/" end |
#version ⇒ Object
143 144 145 |
# File 'lib/saruman.rb', line 143 def version arguments[:version] end |
#write_extension_config ⇒ Object
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 |