Class: Jdt::Manifest
- Inherits:
-
Object
- Object
- Jdt::Manifest
- Defined in:
- lib/jdt/manifest/bump.rb,
lib/jdt/manifest/find.rb,
lib/jdt/manifest/build.rb,
lib/jdt/manifest/secure.rb,
lib/jdt/manifest/manifest.rb,
lib/jdt/manifest/attributes.rb,
lib/jdt/manifest/referenced.rb,
lib/jdt/manifest/validation.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#doc ⇒ Object
Returns the value of attribute doc.
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#file ⇒ Object
Returns the value of attribute file.
-
#warnings ⇒ Object
Returns the value of attribute warnings.
Class Method Summary collapse
Instance Method Summary collapse
- #author ⇒ Object
- #author_email ⇒ Object
- #author_url ⇒ Object
- #build ⇒ Object
- #bump!(type) ⇒ Object
- #copyright ⇒ Object
- #creation_date ⇒ Object
- #description ⇒ Object
- #exists? ⇒ Boolean
- #ext_method ⇒ Object
- #ext_type ⇒ Object
- #ext_type_short ⇒ Object
- #folder ⇒ Object
- #homepage ⇒ Object
-
#initialize(path) ⇒ Manifest
constructor
A new instance of Manifest.
- #license ⇒ Object
- #name ⇒ Object
- #prefixed_name ⇒ Object
- #prefixed_name_with_version ⇒ Object
- #referenced ⇒ Object
- #release ⇒ Object
- #required_joomla_version ⇒ Object
- #secure ⇒ Object
- #to_specific ⇒ Object
- #to_xml ⇒ Object
- #valid? ⇒ Boolean
- #version ⇒ Object
Constructor Details
#initialize(path) ⇒ Manifest
Returns a new instance of Manifest.
9 10 11 12 |
# File 'lib/jdt/manifest/manifest.rb', line 9 def initialize(path) @file = path @doc = Nokogiri::XML(File.read(file)) end |
Instance Attribute Details
#doc ⇒ Object
Returns the value of attribute doc.
7 8 9 |
# File 'lib/jdt/manifest/manifest.rb', line 7 def doc @doc end |
#errors ⇒ Object
Returns the value of attribute errors.
7 8 9 |
# File 'lib/jdt/manifest/validation.rb', line 7 def errors @errors end |
#file ⇒ Object
Returns the value of attribute file.
7 8 9 |
# File 'lib/jdt/manifest/manifest.rb', line 7 def file @file end |
#warnings ⇒ Object
Returns the value of attribute warnings.
7 8 9 |
# File 'lib/jdt/manifest/validation.rb', line 7 def warnings @warnings end |
Class Method Details
.find(path = ".") ⇒ Object
7 8 9 |
# File 'lib/jdt/manifest/find.rb', line 7 def self.find(path = ".") Manifest.new(ManifestFinder.new(path).find).to_specific end |
Instance Method Details
#author ⇒ Object
19 20 21 |
# File 'lib/jdt/manifest/attributes.rb', line 19 def @doc.xpath("//extension/author").text end |
#author_email ⇒ Object
23 24 25 |
# File 'lib/jdt/manifest/attributes.rb', line 23 def @doc.xpath("//extension/authorEmail").text end |
#author_url ⇒ Object
27 28 29 |
# File 'lib/jdt/manifest/attributes.rb', line 27 def @doc.xpath("//extension/authorUrl").text end |
#build ⇒ Object
7 8 9 |
# File 'lib/jdt/manifest/build.rb', line 7 def build ExtensionZipper.new(self).zip(:build) end |
#bump!(type) ⇒ Object
7 8 9 10 11 |
# File 'lib/jdt/manifest/bump.rb', line 7 def bump!(type) new_version = bump_version(type, version) @doc.at_css("extension > version").content = new_version update_file_with_doc end |
#copyright ⇒ Object
59 60 61 |
# File 'lib/jdt/manifest/attributes.rb', line 59 def copyright @doc.xpath("//extension/copyright").text end |
#creation_date ⇒ Object
31 32 33 |
# File 'lib/jdt/manifest/attributes.rb', line 31 def creation_date @doc.xpath("//extension/creationDate").text end |
#description ⇒ Object
47 48 49 |
# File 'lib/jdt/manifest/attributes.rb', line 47 def description @doc.xpath("//extension/description").text end |
#exists? ⇒ Boolean
23 24 25 |
# File 'lib/jdt/manifest/manifest.rb', line 23 def exists? File.exists?(file) end |
#ext_method ⇒ Object
15 16 17 |
# File 'lib/jdt/manifest/attributes.rb', line 15 def ext_method @doc.xpath("//extension").first['method'] end |
#ext_type ⇒ Object
71 72 73 |
# File 'lib/jdt/manifest/attributes.rb', line 71 def ext_type @doc.xpath("//extension").first['type'] end |
#ext_type_short ⇒ Object
67 68 69 |
# File 'lib/jdt/manifest/attributes.rb', line 67 def ext_type_short raise NoMethodError end |
#folder ⇒ Object
19 20 21 |
# File 'lib/jdt/manifest/manifest.rb', line 19 def folder File.dirname(file) end |
#homepage ⇒ Object
55 56 57 |
# File 'lib/jdt/manifest/attributes.rb', line 55 def homepage @doc.xpath("//extension/homepage").text end |
#license ⇒ Object
63 64 65 |
# File 'lib/jdt/manifest/attributes.rb', line 63 def license @doc.xpath("//extension/license").text end |
#name ⇒ Object
35 36 37 |
# File 'lib/jdt/manifest/attributes.rb', line 35 def name @doc.xpath("//extension/name").text end |
#prefixed_name ⇒ Object
39 40 41 |
# File 'lib/jdt/manifest/attributes.rb', line 39 def prefixed_name "#{ext_type_short}_#{name}" end |
#prefixed_name_with_version ⇒ Object
43 44 45 |
# File 'lib/jdt/manifest/attributes.rb', line 43 def prefixed_name_with_version "#{prefixed_name}-v#{version}" end |
#referenced ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/jdt/manifest/referenced.rb', line 5 def referenced list = [] # add files and media @doc.css("files","media").each do |files| parent_folder = files['folder'] files.css("filename").each do |file| list << create_file_ref(file.text,parent_folder) end files.css("folder").each do |file| list << create_folder_ref(file.text,parent_folder) end end # scriptfile @doc.css("scriptfile").each do |file| list << create_file_ref(file.text) end return list end |
#release ⇒ Object
11 12 13 |
# File 'lib/jdt/manifest/build.rb', line 11 def release ExtensionZipper.new(self).zip(:release) end |
#required_joomla_version ⇒ Object
11 12 13 |
# File 'lib/jdt/manifest/attributes.rb', line 11 def required_joomla_version @doc.xpath("//extension").first['version'] end |
#secure ⇒ Object
7 8 9 10 11 |
# File 'lib/jdt/manifest/secure.rb', line 7 def secure "do nothing" # TODO check if every file with the ending .php contains the line::::: defined('_JEXEC') or die('Restricted access'); # TODO if not, insert this directly after the line containing <?php within the file, including the comment: //No direct access to this file and print which files have been changed. end |
#to_specific ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/jdt/manifest/find.rb', line 11 def to_specific if (ext_type == "library") LibraryManifest.new(file) else raise RuntimeError("the current type #{ext_type} is not supported") end end |
#to_xml ⇒ Object
14 15 16 17 |
# File 'lib/jdt/manifest/manifest.rb', line 14 def to_xml xsl = Nokogiri::XSLT(File.read("#{File.dirname(File.(__FILE__))}/xslts/pretty_print.xsl")) xsl.transform(@doc).to_s end |
#valid? ⇒ Boolean
9 10 11 |
# File 'lib/jdt/manifest/validation.rb', line 9 def valid? syntax_valid? and semantics_valid? end |
#version ⇒ Object
51 52 53 |
# File 'lib/jdt/manifest/attributes.rb', line 51 def version @doc.xpath("//extension/version").text end |