Class: Meanbee::Modbuild::PackageXml
- Inherits:
-
Object
- Object
- Meanbee::Modbuild::PackageXml
- Defined in:
- lib/modbuild.rb
Instance Method Summary collapse
- #add_author(name, user, email) ⇒ Object
- #add_extension_dependency(name, min, max) ⇒ Object
- #add_file(name) ⇒ Object
- #add_package_dependency(name, channel, min, max, files) ⇒ Object
- #identify_file(name) ⇒ Object
-
#initialize(name, version, summary, description) ⇒ PackageXml
constructor
A new instance of PackageXml.
- #to_string ⇒ Object
Constructor Details
#initialize(name, version, summary, description) ⇒ PackageXml
Returns a new instance of PackageXml.
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/modbuild.rb', line 113 def initialize(name, version, summary, description) @php_min = '5.2.0' @php_max = '6.0.0' @stability = 'stable' @license = 'Open Software License v3.0 (OSL-3.0)' @license_uri = 'http://opensource.org/licenses/OSL-3.0' @name = name @channel = 'community' @summary = summary @description = description @version = version @authors = [] @depends_packages = [] @depends_extensions = [] @files = [] add_extension_dependency 'Core', '', '' end |
Instance Method Details
#add_author(name, user, email) ⇒ Object
132 133 134 135 136 137 138 |
# File 'lib/modbuild.rb', line 132 def (name, user, email) @authors << { :name => name, :user => user, :email => email } end |
#add_extension_dependency(name, min, max) ⇒ Object
150 151 152 153 154 155 156 |
# File 'lib/modbuild.rb', line 150 def add_extension_dependency(name, min, max) @depends_extensions << { :name => name, :min => min, :max => max } end |
#add_file(name) ⇒ Object
158 159 160 |
# File 'lib/modbuild.rb', line 158 def add_file(name) @files << identify_file(name) end |
#add_package_dependency(name, channel, min, max, files) ⇒ Object
140 141 142 143 144 145 146 147 148 |
# File 'lib/modbuild.rb', line 140 def add_package_dependency(name, channel, min, max, files) @depends_packages << { :name => name, :channel => channel, :min => min, :max => max, :files => files } end |
#identify_file(name) ⇒ Object
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 |
# File 'lib/modbuild.rb', line 240 def identify_file(name) targets = { :magelocal => 'app/code/local', :magecommunity => 'app/code/community', :magecore => 'app/code/core', :mageetc => 'app/etc', :magedesign => 'app/design', :mageskin => 'skin' # :mageweb is for everything else } file_type = (name =~ /\w*\.\w+$/) ? 'file' : 'dir' targets.each do |key, value| if name =~ /^#{value}/ return { :target => key.to_s, :path => name.gsub(/^#{value}\/?/, ''), :type => file_type } end end return { :target => 'mageweb', :path => name, :type => file_type } end |
#to_string ⇒ Object
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 |
# File 'lib/modbuild.rb', line 162 def to_string xml = Builder::XmlMarkup.new(:indent => 4) xml._ { xml.form_key "imtotallyirrelevant" xml.name @name xml.channel @channel xml.version_id { xml.version_ids 2 } xml.summary @summary xml.description @description xml.license @license xml.license_uri @license_uri xml.version @version xml.stability @stability xml.notes @notes xml. { xml.names { @authors.each do |a| xml.name a[:name] end } xml.user { @authors.each do |a| xml.user a[:user] end } xml.email { @authors.each do |a| xml.email a[:email] end } } xml.depends_php_min @php_min xml.depends_php_max @php_max xml.depends { xml.package { [:name, :channel, :min, :max, :files].each do |key| @depends_packages.each do |pkg| xml.tag!(key) { xml.tag!(key, pkg[key]) } end end } xml.extension { [:name, :min, :max].each do |key| @depends_extensions.each do |pkg| xml.tag!(key) { xml.tag!(key, pkg[key]) } end end } } xml.contents { [:target, :path, :type].each do |key| xml.tag!(key) { @files.each do |f| xml.tag!(key, f[key]) end } end [:include, :ignore].each do |key| xml.tag!(key) { @files.length.times do |i| xml.tag!(key) end } end } } return xml.target! end |