jdt 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +6 -0
- data/.rspec +2 -0
- data/CHANGELOG.md +1 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +64 -0
- data/LICENSE +7 -0
- data/README.md +101 -0
- data/Rakefile +2 -0
- data/bin/jdt +16 -0
- data/features/build.feature +0 -0
- data/features/manifest.feature +25 -0
- data/features/new.feature +97 -0
- data/features/release.feature +47 -0
- data/features/status.feature +22 -0
- data/features/step_definitions/my_steps.rb +37 -0
- data/features/support/env.rb +7 -0
- data/features/support/setup.rb +2 -0
- data/features/validate.feature +0 -0
- data/features/version.feature +9 -0
- data/jdt.gemspec +25 -0
- data/lib/jdt/cli.rb +34 -0
- data/lib/jdt/commands/build.rb +28 -0
- data/lib/jdt/commands/bump.rb +37 -0
- data/lib/jdt/commands/install.rb +20 -0
- data/lib/jdt/commands/new.rb +31 -0
- data/lib/jdt/commands/pretty_print.rb +16 -0
- data/lib/jdt/commands/secure.rb +19 -0
- data/lib/jdt/commands/status.rb +21 -0
- data/lib/jdt/commands/validate.rb +35 -0
- data/lib/jdt/commands/version.rb +18 -0
- data/lib/jdt/generator/generator.rb +262 -0
- data/lib/jdt/generator/templates/access.xml.erb +10 -0
- data/lib/jdt/generator/templates/component/admin/access.xml.erb +0 -0
- data/lib/jdt/generator/templates/component/admin/com_name.erb +0 -0
- data/lib/jdt/generator/templates/component/admin/config.xml.erb +0 -0
- data/lib/jdt/generator/templates/component/admin/controller.erb +0 -0
- data/lib/jdt/generator/templates/component/admin/views/view_name/tmpl/default.erb +0 -0
- data/lib/jdt/generator/templates/component/admin/views/view_name/view.html.erb +0 -0
- data/lib/jdt/generator/templates/component/index.html.erb +1 -0
- data/lib/jdt/generator/templates/component/manifest.xml.erb +46 -0
- data/lib/jdt/generator/templates/component/script.php.erb +66 -0
- data/lib/jdt/generator/templates/component/site/com_name.php.erb +15 -0
- data/lib/jdt/generator/templates/component/site/controller.php.erb +14 -0
- data/lib/jdt/generator/templates/component/site/models/com_model_name.erb +0 -0
- data/lib/jdt/generator/templates/component/site/views/view_name/tmpl/default.php.erb +0 -0
- data/lib/jdt/generator/templates/component/site/views/view_name/tmpl/default.xml.erb +0 -0
- data/lib/jdt/generator/templates/component/site/views/view_name/view.html.erb +0 -0
- data/lib/jdt/generator/templates/config.xml.erb +6 -0
- data/lib/jdt/generator/templates/controller.php.erb +13 -0
- data/lib/jdt/generator/templates/dummy_html.erb +1 -0
- data/lib/jdt/generator/templates/entry.erb +15 -0
- data/lib/jdt/generator/templates/manifest.xml.erb +59 -0
- data/lib/jdt/generator/templates/module/helper.php.erb +14 -0
- data/lib/jdt/generator/templates/module/manifest.xml.erb +16 -0
- data/lib/jdt/generator/templates/module/mod_name.php.erb +10 -0
- data/lib/jdt/generator/templates/module/tmpl/default.php.erb +3 -0
- data/lib/jdt/generator/templates/plugin/main.php.erb +0 -0
- data/lib/jdt/generator/templates/plugin/manifest.xml.erb +16 -0
- data/lib/jdt/generator/templates/script.php.erb +66 -0
- data/lib/jdt/generator.rb +1 -0
- data/lib/jdt/manifest/attributes.rb +77 -0
- data/lib/jdt/manifest/build.rb +106 -0
- data/lib/jdt/manifest/bump.rb +40 -0
- data/lib/jdt/manifest/find.rb +58 -0
- data/lib/jdt/manifest/library_manifest.rb +19 -0
- data/lib/jdt/manifest/manifest.rb +29 -0
- data/lib/jdt/manifest/referenced.rb +96 -0
- data/lib/jdt/manifest/schemas/library.xsd +80 -0
- data/lib/jdt/manifest/schemas/manifest.xsd +32 -0
- data/lib/jdt/manifest/secure.rb +39 -0
- data/lib/jdt/manifest/validation.rb +121 -0
- data/lib/jdt/manifest/xslts/pretty_print.xsl +46 -0
- data/lib/jdt/manifest.rb +9 -0
- data/lib/jdt/version.rb +3 -0
- data/lib/jdt.rb +0 -0
- data/lib/not_yet_added/deploy.rb +54 -0
- data/lib/not_yet_added/xampp.rb +82 -0
- data/spec/jdt/generator/generator_spec.rb +55 -0
- data/spec/jdt/manifest/data/example_library/.gitignore +1 -0
- data/spec/jdt/manifest/data/example_library/ActiveRecord.php +3 -0
- data/spec/jdt/manifest/data/example_library/JoomlaActiveRecord.php +56 -0
- data/spec/jdt/manifest/data/example_library/JoomlaConfig.php +42 -0
- data/spec/jdt/manifest/data/example_library/README.md +51 -0
- data/spec/jdt/manifest/data/example_library/dist/asdf.txt +0 -0
- data/spec/jdt/manifest/data/example_library/manifest.xml +22 -0
- data/spec/jdt/manifest/data/library.xml +33 -0
- data/spec/jdt/manifest/data/library_error.xml +23 -0
- data/spec/jdt/manifest/data/library_minimum.xml +11 -0
- data/spec/jdt/manifest/data/manifest.xml +4 -0
- data/spec/jdt/manifest/example_library_spec.rb +27 -0
- data/spec/jdt/manifest/finder_spec.rb +58 -0
- data/spec/jdt/manifest/library_manifest_spec.rb +17 -0
- data/spec/jdt/manifest/manifest_spec.rb +68 -0
- data/spec/jdt/manifest/referenced_spec.rb +28 -0
- data/spec/jdt/manifest/secure_spec.rb +42 -0
- data/spec/jdt/manifest/validation_spec.rb +45 -0
- data/spec/jdt/version_spec.rb +9 -0
- metadata +211 -0
@@ -0,0 +1,16 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<extension type="module" version="1.6.0" method="upgrade">
|
3
|
+
<name><%= @name %></name>
|
4
|
+
<author><%= @author %></author>
|
5
|
+
<version><%= @version %></version>
|
6
|
+
<description><%= @description %></description>
|
7
|
+
<creationDate><%= @creation_date %></creationDate>
|
8
|
+
<files>
|
9
|
+
<filename>mod_<%= @name %>.xml</filename>
|
10
|
+
<filename module="mod_<%= @name %>">mod_<%= @name %>.php</filename>
|
11
|
+
<filename>helper.php</filename>
|
12
|
+
<filename>tmpl/default.php</filename>
|
13
|
+
</files>
|
14
|
+
<params>
|
15
|
+
</params>
|
16
|
+
</extension>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
// no direct access
|
4
|
+
defined( '_JEXEC' ) or die( 'Restricted access' );
|
5
|
+
|
6
|
+
// Include the syndicate functions only once
|
7
|
+
require_once( dirname(__FILE__).DS.'helper.php' );
|
8
|
+
|
9
|
+
$hello = mod<%= @name.capitalize %>Helper::getHello( $params );
|
10
|
+
require( JModuleHelper::getLayoutPath( 'mod_<%= @name %>' ) );
|
File without changes
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<extension type="plugin" version="1.6.0" method="upgrade">
|
3
|
+
<name><%= @name %></name>
|
4
|
+
<author><%= @author %></author>
|
5
|
+
<version><%= @version %></version>
|
6
|
+
<description><%= @description %></description>
|
7
|
+
<creationDate><%= @creation_date %></creationDate>
|
8
|
+
<files>
|
9
|
+
<filename>mod_<%= @name %>.xml</filename>
|
10
|
+
<filename module="mod_<%= @name %>">mod_<%= @name %>.php</filename>
|
11
|
+
<filename>helper.php</filename>
|
12
|
+
<filename>tmpl/default.php</filename>
|
13
|
+
</files>
|
14
|
+
<params>
|
15
|
+
</params>
|
16
|
+
</extension>
|
@@ -0,0 +1,66 @@
|
|
1
|
+
<?php
|
2
|
+
// No direct access to this file
|
3
|
+
defined('_JEXEC') or die('Restricted access');
|
4
|
+
|
5
|
+
/**
|
6
|
+
* Script file of HelloWorld component
|
7
|
+
*/
|
8
|
+
class com_helloWorldInstallerScript
|
9
|
+
{
|
10
|
+
/**
|
11
|
+
* method to install the component
|
12
|
+
*
|
13
|
+
* @return void
|
14
|
+
*/
|
15
|
+
function install($parent)
|
16
|
+
{
|
17
|
+
// $parent is the class calling this method
|
18
|
+
$parent->getParent()->setRedirectURL('index.php?option=com_helloworld');
|
19
|
+
}
|
20
|
+
|
21
|
+
/**
|
22
|
+
* method to uninstall the component
|
23
|
+
*
|
24
|
+
* @return void
|
25
|
+
*/
|
26
|
+
function uninstall($parent)
|
27
|
+
{
|
28
|
+
// $parent is the class calling this method
|
29
|
+
echo '<p>' . JText::_('COM_HELLOWORLD_UNINSTALL_TEXT') . '</p>';
|
30
|
+
}
|
31
|
+
|
32
|
+
/**
|
33
|
+
* method to update the component
|
34
|
+
*
|
35
|
+
* @return void
|
36
|
+
*/
|
37
|
+
function update($parent)
|
38
|
+
{
|
39
|
+
// $parent is the class calling this method
|
40
|
+
echo '<p>' . JText::_('COM_HELLOWORLD_UPDATE_TEXT') . '</p>';
|
41
|
+
}
|
42
|
+
|
43
|
+
/**
|
44
|
+
* method to run before an install/update/uninstall method
|
45
|
+
*
|
46
|
+
* @return void
|
47
|
+
*/
|
48
|
+
function preflight($type, $parent)
|
49
|
+
{
|
50
|
+
// $parent is the class calling this method
|
51
|
+
// $type is the type of change (install, update or discover_install)
|
52
|
+
echo '<p>' . JText::_('COM_HELLOWORLD_PREFLIGHT_' . $type . '_TEXT') . '</p>';
|
53
|
+
}
|
54
|
+
|
55
|
+
/**
|
56
|
+
* method to run after an install/update/uninstall method
|
57
|
+
*
|
58
|
+
* @return void
|
59
|
+
*/
|
60
|
+
function postflight($type, $parent)
|
61
|
+
{
|
62
|
+
// $parent is the class calling this method
|
63
|
+
// $type is the type of change (install, update or discover_install)
|
64
|
+
echo '<p>' . JText::_('COM_HELLOWORLD_POSTFLIGHT_' . $type . '_TEXT') . '</p>';
|
65
|
+
}
|
66
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
require "jdt/generator/generator"
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require "nokogiri"
|
2
|
+
|
3
|
+
module Jdt
|
4
|
+
|
5
|
+
class ElementNotFoundError < RuntimeError
|
6
|
+
|
7
|
+
end
|
8
|
+
|
9
|
+
class Manifest
|
10
|
+
|
11
|
+
def required_joomla_version
|
12
|
+
@doc.xpath("//extension").first['version']
|
13
|
+
end
|
14
|
+
|
15
|
+
def ext_method
|
16
|
+
@doc.xpath("//extension").first['method']
|
17
|
+
end
|
18
|
+
|
19
|
+
def author
|
20
|
+
@doc.xpath("//extension/author").text
|
21
|
+
end
|
22
|
+
|
23
|
+
def author_email
|
24
|
+
@doc.xpath("//extension/authorEmail").text
|
25
|
+
end
|
26
|
+
|
27
|
+
def author_url
|
28
|
+
@doc.xpath("//extension/authorUrl").text
|
29
|
+
end
|
30
|
+
|
31
|
+
def creation_date
|
32
|
+
@doc.xpath("//extension/creationDate").text
|
33
|
+
end
|
34
|
+
|
35
|
+
def name
|
36
|
+
@doc.xpath("//extension/name").text
|
37
|
+
end
|
38
|
+
|
39
|
+
def prefixed_name
|
40
|
+
"#{ext_type_short}_#{name}"
|
41
|
+
end
|
42
|
+
|
43
|
+
def prefixed_name_with_version
|
44
|
+
"#{prefixed_name}-v#{version}"
|
45
|
+
end
|
46
|
+
|
47
|
+
def description
|
48
|
+
@doc.xpath("//extension/description").text
|
49
|
+
end
|
50
|
+
|
51
|
+
def version
|
52
|
+
@doc.xpath("//extension/version").text
|
53
|
+
end
|
54
|
+
|
55
|
+
def homepage
|
56
|
+
@doc.xpath("//extension/homepage").text
|
57
|
+
end
|
58
|
+
|
59
|
+
def copyright
|
60
|
+
@doc.xpath("//extension/copyright").text
|
61
|
+
end
|
62
|
+
|
63
|
+
def license
|
64
|
+
@doc.xpath("//extension/license").text
|
65
|
+
end
|
66
|
+
|
67
|
+
def ext_type_short
|
68
|
+
raise NoMethodError
|
69
|
+
end
|
70
|
+
|
71
|
+
def ext_type
|
72
|
+
@doc.xpath("//extension").first['type']
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
require 'zip/zip'
|
2
|
+
|
3
|
+
module Jdt
|
4
|
+
|
5
|
+
class Manifest
|
6
|
+
|
7
|
+
def build
|
8
|
+
ExtensionZipper.new(self).zip(:build)
|
9
|
+
end
|
10
|
+
|
11
|
+
def release
|
12
|
+
ExtensionZipper.new(self).zip(:release)
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
class ExtensionZipper
|
18
|
+
|
19
|
+
def initialize(manifest)
|
20
|
+
@manifest = manifest
|
21
|
+
end
|
22
|
+
|
23
|
+
def zip(type)
|
24
|
+
|
25
|
+
if (type == :release)
|
26
|
+
zip_file_name = zip_file
|
27
|
+
elsif (type == :build)
|
28
|
+
zip_file_name = zip_file_with_timestamp
|
29
|
+
else
|
30
|
+
raise ArgumentError("Type is not either :release or :build, but #{type}")
|
31
|
+
end
|
32
|
+
|
33
|
+
# ensure that the file does not exist
|
34
|
+
if (File.exists?(zip_file_name))
|
35
|
+
File.delete(zip_file_name)
|
36
|
+
end
|
37
|
+
|
38
|
+
# ensure that directory exists
|
39
|
+
dir = File.dirname(zip_file_name)
|
40
|
+
if(not File.directory?(dir))
|
41
|
+
Dir.mkdir(dir)
|
42
|
+
end
|
43
|
+
|
44
|
+
# create zip file
|
45
|
+
Zip::ZipFile.open(zip_file_name, Zip::ZipFile::CREATE) do |zos|
|
46
|
+
add_files_to_zip(zos)
|
47
|
+
end
|
48
|
+
|
49
|
+
# return zip file
|
50
|
+
zip_file_name
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def zip_folder
|
56
|
+
"#{@manifest.folder}/zip"
|
57
|
+
end
|
58
|
+
|
59
|
+
def zip_file
|
60
|
+
"#{zip_folder}/#{@manifest.prefixed_name_with_version}.zip"
|
61
|
+
end
|
62
|
+
|
63
|
+
def zip_file_with_timestamp
|
64
|
+
"#{zip_folder}/#{@manifest.prefixed_name_with_version}_#{timestamp}.zip"
|
65
|
+
end
|
66
|
+
|
67
|
+
def timestamp
|
68
|
+
Time.now.strftime("%Y%m%d%H%M%S%L")
|
69
|
+
end
|
70
|
+
|
71
|
+
def add_files_to_zip(zip)
|
72
|
+
|
73
|
+
# add manifest
|
74
|
+
add_manifest(zip)
|
75
|
+
|
76
|
+
# add all referenced files and folders from manifest
|
77
|
+
add_referenced(zip)
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
def add_manifest(zip)
|
82
|
+
zip.add(File.basename(@manifest.file), @manifest.file)
|
83
|
+
end
|
84
|
+
|
85
|
+
def add_referenced(zip)
|
86
|
+
@manifest.referenced.each do |ref|
|
87
|
+
|
88
|
+
if (ref.file?)
|
89
|
+
zip.add(ref.path_in_extension, ref.path_in_filesystem)
|
90
|
+
elsif (ref.folder?)
|
91
|
+
Dir["#{ref.path_in_filesystem}/**/*"].each do |f|
|
92
|
+
if (File.file?(f))
|
93
|
+
absolute_file = File.expand_path(f)
|
94
|
+
relative_file = absolute_file[(@manifest.folder.length + 1) .. -1]
|
95
|
+
zip.add(relative_file, absolute_file)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require "nokogiri"
|
2
|
+
|
3
|
+
module Jdt
|
4
|
+
|
5
|
+
class Manifest
|
6
|
+
|
7
|
+
def bump!(type)
|
8
|
+
new_version = bump_version(type, version)
|
9
|
+
@doc.at_css("extension > version").content = new_version
|
10
|
+
update_file_with_doc
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def update_file_with_doc
|
16
|
+
File.open(file,"w") do |f|
|
17
|
+
f.write(@doc.to_xml)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def bump_version(type, version)
|
22
|
+
new_version = version.split(".").map { |item| item.to_i }
|
23
|
+
if (type == :patch)
|
24
|
+
new_version[2] = new_version[2] + 1
|
25
|
+
elsif (type == :minor)
|
26
|
+
new_version[1] = new_version[1] + 1
|
27
|
+
new_version[2] = 0
|
28
|
+
elsif (type == :major)
|
29
|
+
new_version[0] = new_version[0] + 1
|
30
|
+
new_version[1] = 0
|
31
|
+
new_version[2] = 0
|
32
|
+
else
|
33
|
+
raise RuntimeError("given type (#{type})not found")
|
34
|
+
end
|
35
|
+
new_version.join(".")
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module Jdt
|
2
|
+
|
3
|
+
class Manifest
|
4
|
+
|
5
|
+
def self.find(path = ".")
|
6
|
+
Manifest.new(ManifestFinder.new(path).find).to_specific
|
7
|
+
end
|
8
|
+
|
9
|
+
def to_specific
|
10
|
+
if(ext_type == "library")
|
11
|
+
LibraryManifest.new(file)
|
12
|
+
else
|
13
|
+
raise RuntimeError("the current type #{ext_type} is not supported")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
class NoManifestException < RuntimeError
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
class ManifestFinder
|
24
|
+
|
25
|
+
attr_accessor :path
|
26
|
+
|
27
|
+
def initialize(search_path = ".")
|
28
|
+
@path = search_path
|
29
|
+
end
|
30
|
+
|
31
|
+
def find
|
32
|
+
retrieve_manifest_path
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def retrieve_manifest_path
|
38
|
+
|
39
|
+
# create list of possible files for the manifest
|
40
|
+
manifest_named_after_directory = File.basename(File.expand_path(path))
|
41
|
+
manifest_files = ["#{File.expand_path(path)}/manifest.xml", manifest_named_after_directory]
|
42
|
+
|
43
|
+
# evaluate each possible manifest file
|
44
|
+
manifest_files.each do |file|
|
45
|
+
|
46
|
+
if (File.exists?(file))
|
47
|
+
return file
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
# if no manifest is found, raise error
|
53
|
+
raise NoManifestException, "Manifest not found in current directory"
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require "nokogiri"
|
2
|
+
|
3
|
+
module Jdt
|
4
|
+
|
5
|
+
class Manifest
|
6
|
+
|
7
|
+
attr_accessor :file, :doc
|
8
|
+
|
9
|
+
def initialize(path)
|
10
|
+
@file = path
|
11
|
+
@doc = Nokogiri::XML(File.read(file))
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_xml
|
15
|
+
xsl = Nokogiri::XSLT(File.read("#{File.dirname(File.expand_path(__FILE__))}/xslts/pretty_print.xsl"))
|
16
|
+
xsl.transform(@doc).to_s
|
17
|
+
end
|
18
|
+
|
19
|
+
def folder
|
20
|
+
File.dirname(file)
|
21
|
+
end
|
22
|
+
|
23
|
+
def exists?
|
24
|
+
File.exists?(file)
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
module Jdt
|
2
|
+
|
3
|
+
class Manifest
|
4
|
+
|
5
|
+
def referenced
|
6
|
+
|
7
|
+
list = []
|
8
|
+
|
9
|
+
# add files and media
|
10
|
+
@doc.css("files","media").each do |files|
|
11
|
+
|
12
|
+
parent_folder = files['folder']
|
13
|
+
|
14
|
+
files.css("filename").each do |file|
|
15
|
+
list << create_file_ref(file.text,parent_folder)
|
16
|
+
end
|
17
|
+
|
18
|
+
files.css("folder").each do |file|
|
19
|
+
list << create_folder_ref(file.text,parent_folder)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
# scriptfile
|
25
|
+
@doc.css("scriptfile").each do |file|
|
26
|
+
list << create_file_ref(file.text)
|
27
|
+
end
|
28
|
+
|
29
|
+
return list
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def create_file_ref(path, parent_folder = nil)
|
35
|
+
ref = Referenced.new
|
36
|
+
ref.path = path
|
37
|
+
ref.parent_folder = parent_folder
|
38
|
+
ref.type = :file
|
39
|
+
ref.extension_path = folder
|
40
|
+
|
41
|
+
return ref
|
42
|
+
end
|
43
|
+
|
44
|
+
def create_folder_ref(path, parent_folder = nil)
|
45
|
+
ref = Referenced.new
|
46
|
+
ref.path = path
|
47
|
+
ref.parent_folder = parent_folder
|
48
|
+
ref.type = :folder
|
49
|
+
ref.extension_path = folder
|
50
|
+
|
51
|
+
return ref
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
class Referenced
|
57
|
+
|
58
|
+
attr_accessor :parent_folder, :path, :type, :extension_path
|
59
|
+
|
60
|
+
def path_in_filesystem
|
61
|
+
"#{extension_path}/#{path_in_extension}"
|
62
|
+
end
|
63
|
+
|
64
|
+
def path_in_extension
|
65
|
+
if (parent_folder and parent_folder != "")
|
66
|
+
"#{parent_folder}/#{path}"
|
67
|
+
else
|
68
|
+
"#{path}"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def file?
|
73
|
+
type == :file
|
74
|
+
end
|
75
|
+
|
76
|
+
def folder?
|
77
|
+
type == :folder
|
78
|
+
end
|
79
|
+
|
80
|
+
def exists?
|
81
|
+
if (file?)
|
82
|
+
File.exists?(path_in_filesystem)
|
83
|
+
elsif (folder?)
|
84
|
+
Dir.exists?(path_in_filesystem)
|
85
|
+
else
|
86
|
+
raise RuntimeError("Neither file nor folder.")
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def to_s
|
91
|
+
"Reference to #{type} #{path_in_extension}"
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified"
|
3
|
+
xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
4
|
+
<xs:element name="extension">
|
5
|
+
<xs:complexType>
|
6
|
+
|
7
|
+
<xs:choice maxOccurs="unbounded">
|
8
|
+
<xs:element type="xs:string" name="name"/>
|
9
|
+
<xs:element type="xs:string" name="libraryname"/>
|
10
|
+
|
11
|
+
<xs:element type="xs:string" name="version" minOccurs="0"/>
|
12
|
+
|
13
|
+
<xs:element type="xs:string" name="creationDate" minOccurs="0"/>
|
14
|
+
<xs:element type="xs:string" name="homepage" minOccurs="0"/>
|
15
|
+
|
16
|
+
<xs:element type="xs:string" name="author" minOccurs="0"/>
|
17
|
+
<xs:element type="xs:string" name="authorEmail" minOccurs="0"/>
|
18
|
+
<xs:element type="xs:string" name="authorUrl" minOccurs="0"/>
|
19
|
+
|
20
|
+
<xs:element type="xs:string" name="copyright" minOccurs="0"/>
|
21
|
+
<xs:element type="xs:string" name="license" minOccurs="0"/>
|
22
|
+
<xs:element type="xs:string" name="description" minOccurs="0"/>
|
23
|
+
|
24
|
+
<xs:element type="filesType" name="files"/>
|
25
|
+
|
26
|
+
<xs:element type="xs:string" name="scriptfile" minOccurs="0"/>
|
27
|
+
|
28
|
+
<xs:element name="updateservers">
|
29
|
+
<xs:complexType>
|
30
|
+
<xs:sequence>
|
31
|
+
<xs:element name="server" maxOccurs="unbounded" minOccurs="0">
|
32
|
+
<xs:complexType>
|
33
|
+
<xs:simpleContent>
|
34
|
+
<xs:extension base="xs:string">
|
35
|
+
<xs:attribute type="xs:string" name="type" use="optional"/>
|
36
|
+
<xs:attribute type="xs:string" name="priority" use="optional"/>
|
37
|
+
<xs:attribute type="xs:string" name="name" use="optional"/>
|
38
|
+
</xs:extension>
|
39
|
+
</xs:simpleContent>
|
40
|
+
</xs:complexType>
|
41
|
+
</xs:element>
|
42
|
+
</xs:sequence>
|
43
|
+
</xs:complexType>
|
44
|
+
</xs:element>
|
45
|
+
|
46
|
+
</xs:choice>
|
47
|
+
|
48
|
+
<xs:attribute name="type">
|
49
|
+
<xs:simpleType>
|
50
|
+
<xs:restriction base="xs:string">
|
51
|
+
<xs:enumeration value="library"/>
|
52
|
+
</xs:restriction>
|
53
|
+
</xs:simpleType>
|
54
|
+
</xs:attribute>
|
55
|
+
|
56
|
+
<xs:attribute type="xs:string" name="version"/>
|
57
|
+
|
58
|
+
<xs:attribute name="method">
|
59
|
+
<xs:simpleType>
|
60
|
+
<xs:restriction base="xs:string">
|
61
|
+
<xs:enumeration value="upgrade"/>
|
62
|
+
<xs:enumeration value="install"/>
|
63
|
+
</xs:restriction>
|
64
|
+
</xs:simpleType>
|
65
|
+
</xs:attribute>
|
66
|
+
</xs:complexType>
|
67
|
+
</xs:element>
|
68
|
+
|
69
|
+
|
70
|
+
<xs:complexType name="filesType">
|
71
|
+
<xs:choice maxOccurs="unbounded">
|
72
|
+
<xs:element type="xs:string" name="filename" minOccurs="0"/>
|
73
|
+
<xs:element type="xs:string" name="folder" minOccurs="0"/>
|
74
|
+
</xs:choice>
|
75
|
+
|
76
|
+
<xs:attribute type="xs:string" name="folder"/>
|
77
|
+
</xs:complexType>
|
78
|
+
|
79
|
+
|
80
|
+
</xs:schema>
|
@@ -0,0 +1,32 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified"
|
3
|
+
xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
4
|
+
<xs:element name="extension" type="extensionType"/>
|
5
|
+
<xs:complexType name="extensionType">
|
6
|
+
<xs:sequence maxOccurs="unbounded">
|
7
|
+
<xs:any processContents="lax"/>
|
8
|
+
</xs:sequence>
|
9
|
+
<xs:attribute name="type">
|
10
|
+
<xs:simpleType>
|
11
|
+
<xs:restriction base="xs:string">
|
12
|
+
<xs:enumeration value="component"/>
|
13
|
+
<xs:enumeration value="module"/>
|
14
|
+
<xs:enumeration value="plugin"/>
|
15
|
+
<xs:enumeration value="library"/>
|
16
|
+
<xs:enumeration value="template"/>
|
17
|
+
<xs:enumeration value="language"/>
|
18
|
+
<xs:enumeration value="package"/>
|
19
|
+
</xs:restriction>
|
20
|
+
</xs:simpleType>
|
21
|
+
</xs:attribute>
|
22
|
+
<xs:attribute type="xs:string" name="version"/>
|
23
|
+
<xs:attribute name="method">
|
24
|
+
<xs:simpleType>
|
25
|
+
<xs:restriction base="xs:string">
|
26
|
+
<xs:enumeration value="upgrade"/>
|
27
|
+
<xs:enumeration value="install"/>
|
28
|
+
</xs:restriction>
|
29
|
+
</xs:simpleType>
|
30
|
+
</xs:attribute>
|
31
|
+
</xs:complexType>
|
32
|
+
</xs:schema>
|