ronin-gen 0.1.0
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/COPYING.txt +339 -0
- data/History.txt +9 -0
- data/Manifest.txt +37 -0
- data/README.txt +79 -0
- data/Rakefile +15 -0
- data/TODO.txt +3 -0
- data/bin/ronin-gen +16 -0
- data/bin/ronin-gen-extension +12 -0
- data/bin/ronin-gen-overlay +12 -0
- data/lib/ronin/generators.rb +26 -0
- data/lib/ronin/generators/dir_generator.rb +42 -0
- data/lib/ronin/generators/generator.rb +150 -0
- data/lib/ronin/generators/platform/extension.rb +56 -0
- data/lib/ronin/generators/platform/overlay.rb +229 -0
- data/lib/ronin/generators/platform/spec.rb +46 -0
- data/lib/ronin/generators/platform/static.rb +31 -0
- data/lib/ronin/generators/version.rb +28 -0
- data/lib/ronin/ui/command_line/commands/gen_extension.rb +56 -0
- data/lib/ronin/ui/command_line/commands/gen_overlay.rb +97 -0
- data/spec/generated_extension_examples.rb +27 -0
- data/spec/generated_overlay_examples.rb +66 -0
- data/spec/generators/generator_spec.rb +40 -0
- data/spec/generators/generators_spec.rb +9 -0
- data/spec/generators/helpers/generators.rb +7 -0
- data/spec/generators/helpers/generators/dir_generator.rb +11 -0
- data/spec/generators/helpers/generators/file_generator.rb +11 -0
- data/spec/generators/helpers/generators/templated_generator.rb +17 -0
- data/spec/generators/helpers/static/generators/templated.txt.erb +1 -0
- data/spec/generators/platform/extension_spec.rb +25 -0
- data/spec/generators/platform/overlay_spec.rb +38 -0
- data/spec/spec_helper.rb +7 -0
- data/spec/ui/command_line/commands/gen_extension_spec.rb +22 -0
- data/spec/ui/command_line/commands/gen_overlay_spec.rb +38 -0
- data/static/ronin/platform/generators/extension.rb +9 -0
- data/static/ronin/platform/generators/spec/spec_helper.rb +9 -0
- data/tasks/spec.rb +9 -0
- metadata +115 -0
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'hoe'
|
5
|
+
require './tasks/spec.rb'
|
6
|
+
require './lib/ronin/generators/version.rb'
|
7
|
+
|
8
|
+
Hoe.new('ronin-gen', Ronin::Generators::VERSION) do |p|
|
9
|
+
p.rubyforge_name = 'ronin'
|
10
|
+
p.developer('Postmodern', 'postmodern.mod3@gmail.com')
|
11
|
+
p.remote_rdoc_dir = 'docs/ronin-gen'
|
12
|
+
p.extra_deps = [['ronin', '>=0.2.2']]
|
13
|
+
end
|
14
|
+
|
15
|
+
# vim: syntax=Ruby
|
data/TODO.txt
ADDED
data/bin/ronin-gen
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
|
5
|
+
lib_dir = File.expand_path(File.join(File.dirname(__FILE__),'..','lib'))
|
6
|
+
unless $LOAD_PATH.include?(lib_dir)
|
7
|
+
$LOAD_PATH << lib_dir
|
8
|
+
end
|
9
|
+
|
10
|
+
require 'ronin/ui/command_line'
|
11
|
+
|
12
|
+
if ARGV.length > 0
|
13
|
+
ARGV[0] = "gen-#{ARGV.first}"
|
14
|
+
end
|
15
|
+
|
16
|
+
Ronin::UI::CommandLine.run(*ARGV)
|
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
|
5
|
+
lib_dir = File.expand_path(File.join(File.dirname(__FILE__),'..','lib'))
|
6
|
+
unless $LOAD_PATH.include?(lib_dir)
|
7
|
+
$LOAD_PATH << lib_dir
|
8
|
+
end
|
9
|
+
|
10
|
+
require 'ronin/ui/command_line/commands/gen_extension'
|
11
|
+
|
12
|
+
Ronin::UI::CommandLine::Commands::GenExtension.run(*ARGV)
|
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
|
5
|
+
lib_dir = File.expand_path(File.join(File.dirname(__FILE__),'..','lib'))
|
6
|
+
unless $LOAD_PATH.include?(lib_dir)
|
7
|
+
$LOAD_PATH << lib_dir
|
8
|
+
end
|
9
|
+
|
10
|
+
require 'ronin/ui/command_line/commands/gen_overlay'
|
11
|
+
|
12
|
+
Ronin::UI::CommandLine::Commands::GenOverlay.run(*ARGV)
|
@@ -0,0 +1,26 @@
|
|
1
|
+
#
|
2
|
+
#--
|
3
|
+
# Ronin Gen - A Ruby library for Ronin that provides various generators.
|
4
|
+
#
|
5
|
+
# Copyright (c) 2009 Hal Brodigan (postmodern.mod3 at gmail.com)
|
6
|
+
#
|
7
|
+
# This program is free software; you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU General Public License as published by
|
9
|
+
# the Free Software Foundation; either version 2 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# This program is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with this program; if not, write to the Free Software
|
19
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
20
|
+
#++
|
21
|
+
#
|
22
|
+
|
23
|
+
require 'ronin/generators/generator'
|
24
|
+
require 'ronin/generators/dir_generator'
|
25
|
+
require 'ronin/generators/platform'
|
26
|
+
require 'ronin/generators/version'
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#
|
2
|
+
#--
|
3
|
+
# Ronin Gen - A Ruby library for Ronin that provides various generators.
|
4
|
+
#
|
5
|
+
# Copyright (c) 2009 Hal Brodigan (postmodern.mod3 at gmail.com)
|
6
|
+
#
|
7
|
+
# This program is free software; you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU General Public License as published by
|
9
|
+
# the Free Software Foundation; either version 2 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# This program is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with this program; if not, write to the Free Software
|
19
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
20
|
+
#++
|
21
|
+
#
|
22
|
+
|
23
|
+
require 'ronin/generators/generator'
|
24
|
+
|
25
|
+
module Ronin
|
26
|
+
module Generators
|
27
|
+
class DirGenerator < Generator
|
28
|
+
|
29
|
+
#
|
30
|
+
# Creates a directory at the specified _path_ then runs the
|
31
|
+
# generator.
|
32
|
+
#
|
33
|
+
def run(path)
|
34
|
+
path = File.expand_path(path)
|
35
|
+
FileUtils.mkdir_p(path)
|
36
|
+
|
37
|
+
return super(path)
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,150 @@
|
|
1
|
+
#
|
2
|
+
#--
|
3
|
+
# Ronin Gen - A Ruby library for Ronin that provides various generators.
|
4
|
+
#
|
5
|
+
# Copyright (c) 2009 Hal Brodigan (postmodern.mod3 at example.com)
|
6
|
+
#
|
7
|
+
# This program is free software; you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU General Public License as published by
|
9
|
+
# the Free Software Foundation; either version 2 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# This program is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with this program; if not, write to the Free Software
|
19
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
20
|
+
#++
|
21
|
+
#
|
22
|
+
|
23
|
+
require 'ronin/static/finders'
|
24
|
+
|
25
|
+
require 'fileutils'
|
26
|
+
require 'erb'
|
27
|
+
|
28
|
+
module Ronin
|
29
|
+
module Generators
|
30
|
+
class Generator
|
31
|
+
|
32
|
+
include Static::Finders
|
33
|
+
|
34
|
+
#
|
35
|
+
# Runs the generator with the specified _path_.
|
36
|
+
#
|
37
|
+
def run(path)
|
38
|
+
path = File.expand_path(path)
|
39
|
+
@path = path
|
40
|
+
|
41
|
+
generate!
|
42
|
+
|
43
|
+
@path = nil
|
44
|
+
return path
|
45
|
+
end
|
46
|
+
|
47
|
+
protected
|
48
|
+
|
49
|
+
#
|
50
|
+
# Default method which invokes the generator.
|
51
|
+
#
|
52
|
+
def generate!
|
53
|
+
end
|
54
|
+
|
55
|
+
#
|
56
|
+
# Returns the absolute form of the specified _path_, with respect to
|
57
|
+
# the +path+ instance variable.
|
58
|
+
#
|
59
|
+
def expand_path(sub_path)
|
60
|
+
return @path if (sub_path.nil? || sub_path == @path)
|
61
|
+
return File.expand_path(File.join(@path,sub_path))
|
62
|
+
end
|
63
|
+
|
64
|
+
#
|
65
|
+
# Prints the specified _sub_path_.
|
66
|
+
#
|
67
|
+
def print_path(sub_path)
|
68
|
+
full_path = expand_path(sub_path)
|
69
|
+
|
70
|
+
sub_path = File.join('.',sub_path)
|
71
|
+
sub_path << File::SEPARATOR if File.directory?(full_path)
|
72
|
+
|
73
|
+
puts " #{sub_path}"
|
74
|
+
end
|
75
|
+
|
76
|
+
#
|
77
|
+
# Opens the file at the specified _sub_path_. If a _block_ is given,
|
78
|
+
# it will be passed a newly created File object.
|
79
|
+
#
|
80
|
+
# file('metadata.xml') do |file|
|
81
|
+
# ...
|
82
|
+
# end
|
83
|
+
#
|
84
|
+
def file(sub_path,&block)
|
85
|
+
File.open(expand_path(sub_path),'w',&block)
|
86
|
+
|
87
|
+
print_path(sub_path)
|
88
|
+
return sub_path
|
89
|
+
end
|
90
|
+
|
91
|
+
#
|
92
|
+
# Creates a directory at the specified _sub_path_. If a _block_ is
|
93
|
+
# given, it will be passed the _sub_path_ after the directory has
|
94
|
+
# been created.
|
95
|
+
#
|
96
|
+
# directory 'objects'
|
97
|
+
# # => "objects"
|
98
|
+
#
|
99
|
+
def directory(sub_path,&block)
|
100
|
+
FileUtils.mkdir_p(expand_path(sub_path))
|
101
|
+
|
102
|
+
print_path(sub_path)
|
103
|
+
block.call(sub_path) if block
|
104
|
+
return sub_path
|
105
|
+
end
|
106
|
+
|
107
|
+
#
|
108
|
+
# Copies the _static_file_ to the specified _sub_path_.
|
109
|
+
#
|
110
|
+
# copy 'ronin/platform/generators/extension.rb', 'myext/extension.rb'
|
111
|
+
# # => "myext/extension.rb"
|
112
|
+
#
|
113
|
+
def copy(static_file,sub_path)
|
114
|
+
static_file = find_static_file(static_file)
|
115
|
+
|
116
|
+
FileUtils.cp(static_file,expand_path(sub_path))
|
117
|
+
|
118
|
+
print_path(sub_path)
|
119
|
+
return sub_path
|
120
|
+
end
|
121
|
+
|
122
|
+
#
|
123
|
+
# Renders the ERB template using the specified _static_file_.
|
124
|
+
#
|
125
|
+
# render_template 'ronin/platform/generators/Rakefile.erb'
|
126
|
+
# # => "..."
|
127
|
+
#
|
128
|
+
def render_template(static_file)
|
129
|
+
static_file = find_static_file(static_file)
|
130
|
+
erb = ERB.new(File.read(static_file))
|
131
|
+
|
132
|
+
return erb.result(binding)
|
133
|
+
end
|
134
|
+
|
135
|
+
#
|
136
|
+
# Renders the ERB template using the specified _static_file_,
|
137
|
+
# saving the result to the specified _sub_path_.
|
138
|
+
#
|
139
|
+
# render_file 'ronin/platform/generators/Rakefile.erb', 'Rakefile'
|
140
|
+
# # => nil
|
141
|
+
#
|
142
|
+
def render_file(static_file,sub_path)
|
143
|
+
file(sub_path) do |file|
|
144
|
+
file.write(render_template(static_file))
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
#
|
2
|
+
#--
|
3
|
+
# Ronin Gen - A Ruby library for Ronin that provides various generators.
|
4
|
+
#
|
5
|
+
# Copyright (c) 2009 Hal Brodigan (postmodern.mod3 at gmail.com)
|
6
|
+
#
|
7
|
+
# This program is free software; you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU General Public License as published by
|
9
|
+
# the Free Software Foundation; either version 2 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# This program is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with this program; if not, write to the Free Software
|
19
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
20
|
+
#++
|
21
|
+
#
|
22
|
+
|
23
|
+
require 'ronin/generators/platform/static'
|
24
|
+
require 'ronin/generators/dir_generator'
|
25
|
+
require 'ronin/platform/extension'
|
26
|
+
|
27
|
+
module Ronin
|
28
|
+
module Generators
|
29
|
+
module Platform
|
30
|
+
class Extension < DirGenerator
|
31
|
+
|
32
|
+
# The lib/ directory of the extension
|
33
|
+
LIB_DIR = Ronin::Platform::Extension::LIB_DIR
|
34
|
+
|
35
|
+
# The default extension file
|
36
|
+
EXTENSION_FILE = File.join('ronin','platform','generators','extension.rb')
|
37
|
+
|
38
|
+
protected
|
39
|
+
|
40
|
+
#
|
41
|
+
# Generates a skeleton Extension.
|
42
|
+
#
|
43
|
+
def generate!
|
44
|
+
name = File.basename(@path)
|
45
|
+
|
46
|
+
directory LIB_DIR
|
47
|
+
file File.join(LIB_DIR,name + '.rb')
|
48
|
+
directory File.join(LIB_DIR,name)
|
49
|
+
|
50
|
+
copy EXTENSION_FILE, Ronin::Platform::Extension::EXTENSION_FILE
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,229 @@
|
|
1
|
+
#
|
2
|
+
#--
|
3
|
+
# Ronin Gen - A Ruby library for Ronin that provides various generators.
|
4
|
+
#
|
5
|
+
# Copyright (c) 2009 Hal Brodigan (postmodern.mod3 at gmail.com)
|
6
|
+
#
|
7
|
+
# This program is free software; you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU General Public License as published by
|
9
|
+
# the Free Software Foundation; either version 2 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# This program is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with this program; if not, write to the Free Software
|
19
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
20
|
+
#++
|
21
|
+
#
|
22
|
+
|
23
|
+
require 'ronin/generators/platform/static'
|
24
|
+
require 'ronin/generators/dir_generator'
|
25
|
+
require 'ronin/platform/overlay'
|
26
|
+
require 'ronin/version'
|
27
|
+
|
28
|
+
require 'nokogiri'
|
29
|
+
require 'set'
|
30
|
+
|
31
|
+
module Ronin
|
32
|
+
module Generators
|
33
|
+
module Platform
|
34
|
+
class Overlay < DirGenerator
|
35
|
+
|
36
|
+
include Nokogiri
|
37
|
+
|
38
|
+
# The Overlay metadata file
|
39
|
+
METADATA_FILE = Ronin::Platform::Overlay::METADATA_FILE
|
40
|
+
|
41
|
+
# The Overlay metadata XSL URL
|
42
|
+
METADATA_XSL = 'http://ronin.rubyforge.org/static/ronin/platform/overlay.xsl'
|
43
|
+
|
44
|
+
# The Overlay lib directory
|
45
|
+
LIB_DIR = Ronin::Platform::Overlay::LIB_DIR
|
46
|
+
|
47
|
+
# The Overlay objects directory
|
48
|
+
OBJECTS_DIR = Ronin::Platform::Overlay::OBJECTS_DIR
|
49
|
+
|
50
|
+
# Title of the overlay
|
51
|
+
attr_accessor :title
|
52
|
+
|
53
|
+
# Source URL for the overlay
|
54
|
+
attr_accessor :source
|
55
|
+
|
56
|
+
# Source View URL for the overlay
|
57
|
+
attr_accessor :source_view
|
58
|
+
|
59
|
+
# Website of the overlay
|
60
|
+
attr_accessor :website
|
61
|
+
|
62
|
+
# License of the overlay
|
63
|
+
attr_accessor :license
|
64
|
+
|
65
|
+
# Maintainers of the overlay
|
66
|
+
attr_reader :maintainers
|
67
|
+
|
68
|
+
# Description of the overlay
|
69
|
+
attr_accessor :description
|
70
|
+
|
71
|
+
# Tasks to require for the overlay
|
72
|
+
attr_reader :tasks
|
73
|
+
|
74
|
+
#
|
75
|
+
# Creates a new Metadata object with the given _options_.
|
76
|
+
#
|
77
|
+
# _options_ may include the following keys:
|
78
|
+
# <tt>:title</tt>:: Title for the overlay.
|
79
|
+
# <tt>:source</tt>:: Source URL for the overlay.
|
80
|
+
# <tt>:source_view</tt>:: Source View URL for the overlay.
|
81
|
+
# <tt>:website</tt>:: Website for the overlay.
|
82
|
+
# <tt>:license</tt>:: License for the overlay.
|
83
|
+
# <tt>:maintainers</tt>:: List of maintainers for the overlay.
|
84
|
+
# <tt>:description</tt>:: The description of the overlay.
|
85
|
+
#
|
86
|
+
def initialize(options={})
|
87
|
+
@title = options[:title]
|
88
|
+
@source = options[:source]
|
89
|
+
@source_view = options[:source_view]
|
90
|
+
@website = options[:website]
|
91
|
+
@license = options[:license]
|
92
|
+
@maintainers = []
|
93
|
+
|
94
|
+
if options[:maintainers]
|
95
|
+
@maintainers.merge!(options[:maintainers])
|
96
|
+
end
|
97
|
+
|
98
|
+
@description = options[:description]
|
99
|
+
@tasks = Set[]
|
100
|
+
|
101
|
+
if options[:tasks]
|
102
|
+
@tasks.merge!(options[:tasks])
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
#
|
107
|
+
# Adds a new maintainer with the specified _name_ and _email_.
|
108
|
+
#
|
109
|
+
def maintainer(name,email)
|
110
|
+
@maintainers << {:name => name, :email => email}
|
111
|
+
end
|
112
|
+
|
113
|
+
protected
|
114
|
+
|
115
|
+
#
|
116
|
+
# Generates a skeleton Overlay.
|
117
|
+
#
|
118
|
+
def generate!
|
119
|
+
@title ||= File.basename(@path).gsub(/[_\s]+/,' ').capitalize
|
120
|
+
@source_view ||= @source
|
121
|
+
@website ||= @source_view
|
122
|
+
|
123
|
+
directory LIB_DIR
|
124
|
+
directory OBJECTS_DIR
|
125
|
+
directory 'tasks'
|
126
|
+
|
127
|
+
generate_rakefile!
|
128
|
+
generate_metadata!
|
129
|
+
end
|
130
|
+
|
131
|
+
#
|
132
|
+
# Generates the Rakefile of the Overlay.
|
133
|
+
#
|
134
|
+
def generate_rakefile!
|
135
|
+
file('Rakefile') do |rakefile|
|
136
|
+
rakefile << "# -*- ruby -*-\n\n"
|
137
|
+
|
138
|
+
@tasks.each do |task|
|
139
|
+
rakefile << "require 'ronin/platform/tasks/#{task}'"
|
140
|
+
end
|
141
|
+
|
142
|
+
rakefile << "\n# vim: syntax=Ruby"
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
#
|
147
|
+
# Generates the XML metadata file for the Overlay.
|
148
|
+
#
|
149
|
+
def generate_metadata!
|
150
|
+
file(METADATA_FILE) do |metadata_file|
|
151
|
+
doc = XML::Document.new
|
152
|
+
doc << XML::ProcessingInstruction.new(
|
153
|
+
doc,
|
154
|
+
'xml-stylesheet',
|
155
|
+
"type=\"text/xsl\" href=\"#{METADATA_XSL}\""
|
156
|
+
)
|
157
|
+
|
158
|
+
root = XML::Node.new('ronin-overlay',doc)
|
159
|
+
root['version'] = Ronin::VERSION
|
160
|
+
|
161
|
+
title_tag = XML::Node.new('title',doc)
|
162
|
+
title_tag << XML::Text.new(@title,doc)
|
163
|
+
root << title_tag
|
164
|
+
|
165
|
+
if @source
|
166
|
+
source_tag = XML::Node.new('source',doc)
|
167
|
+
source_tag << XML::Text.new(@source,doc)
|
168
|
+
root << source_tag
|
169
|
+
end
|
170
|
+
|
171
|
+
if @source_view
|
172
|
+
source_view_tag = XML::Node.new('source-view',doc)
|
173
|
+
source_view_tag << XML::Text.new(@source_view,doc)
|
174
|
+
root << source_view_tag
|
175
|
+
end
|
176
|
+
|
177
|
+
if @website
|
178
|
+
url_tag = XML::Node.new('website',doc)
|
179
|
+
url_tag << XML::Text.new(@website,doc)
|
180
|
+
root << url_tag
|
181
|
+
end
|
182
|
+
|
183
|
+
if @license
|
184
|
+
license_tag = XML::Node.new('license',doc)
|
185
|
+
license_tag << XML::Text.new(@license,doc)
|
186
|
+
root << license_tag
|
187
|
+
end
|
188
|
+
|
189
|
+
unless @maintainers.empty?
|
190
|
+
maintainers_tag = XML::Node.new('maintainers',doc)
|
191
|
+
|
192
|
+
@maintainers.each do |author|
|
193
|
+
if (author[:name] || author[:email])
|
194
|
+
maintainer_tag = XML::Node.new('maintainer',doc)
|
195
|
+
|
196
|
+
if author[:name]
|
197
|
+
name_tag = XML::Node.new('name',doc)
|
198
|
+
name_tag << XML::Text.new(author[:name],doc)
|
199
|
+
maintainer_tag << name_tag
|
200
|
+
end
|
201
|
+
|
202
|
+
if author[:email]
|
203
|
+
email_tag = XML::Node.new('email',doc)
|
204
|
+
email_tag << XML::Text.new(author[:email],doc)
|
205
|
+
maintainer_tag << email_tag
|
206
|
+
end
|
207
|
+
|
208
|
+
maintainers_tag << maintainer_tag
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
root << maintainers_tag
|
213
|
+
end
|
214
|
+
|
215
|
+
if @description
|
216
|
+
description_tag = XML::Node.new('description',doc)
|
217
|
+
description_tag << XML::Text.new(@description,doc)
|
218
|
+
root << description_tag
|
219
|
+
end
|
220
|
+
|
221
|
+
doc << root
|
222
|
+
doc.write_xml_to(metadata_file)
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
end
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|