haplo 2.1.6-java → 2.2.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/haplo.gemspec +2 -2
- data/lib/plugin.rb +12 -8
- data/lib/plugin_tool.rb +89 -32
- data/lib/version.txt +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c0a878dd42f37f3aec318b396740eb2673cb94d
|
4
|
+
data.tar.gz: 24bba608eb2e1aa21b5def4f12f8965e0e31e6e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eeb2c6fe5e9c54846f8c8b7c697981adda3cd20b5ab45ca032597b9ac174c5d0b3a7f545c5a79677b88a4d2249099664f90d177514f0568521857e14f5fcfc4a
|
7
|
+
data.tar.gz: ac136d52d8c9a2bacef648d826d72f142ef640c91b9e47f805f686bf062554ea6b7a65c85b545eec6b9d9e008b2e04858b6bd620a3b3b580caa5d312dd4cdd26
|
data/haplo.gemspec
CHANGED
@@ -3,8 +3,8 @@ Gem::Specification.new do |s|
|
|
3
3
|
files = Dir.glob("#{root_dir}/**/*.*").map { |x| x[root_dir.length + 1, x.length]}
|
4
4
|
|
5
5
|
s.name = 'haplo'
|
6
|
-
s.version = '2.
|
7
|
-
s.date = '2016-
|
6
|
+
s.version = '2.2.0'
|
7
|
+
s.date = '2016-05-13'
|
8
8
|
s.summary = "Haplo Plugin Tool"
|
9
9
|
s.description = "Development tools for developing Haplo plugins, see http://haplo.org"
|
10
10
|
s.licenses = ["MPL-2.0"]
|
data/lib/plugin.rb
CHANGED
@@ -10,12 +10,22 @@ module PluginTool
|
|
10
10
|
class Plugin
|
11
11
|
DEFAULT_PLUGIN_LOAD_PRIORITY = 9999999
|
12
12
|
|
13
|
-
def initialize(
|
14
|
-
@
|
13
|
+
def initialize(dir, options)
|
14
|
+
@plugin_dir = dir
|
15
15
|
@options = options
|
16
|
+
# Check to see if the plugin is valid
|
17
|
+
unless File.file?("#{@plugin_dir}/plugin.json")
|
18
|
+
end_on_error "Plugin #{@plugin_dir} does not exist (no plugin.json file)"
|
19
|
+
end
|
20
|
+
pj = File.open("#{@plugin_dir}/plugin.json") { |f| JSON.parse(f.read) }
|
21
|
+
@name = pj["pluginName"]
|
22
|
+
end_on_error "#{@plugin_dir}/plugin.json: invalid pluginName" unless @name.kind_of?(String)
|
23
|
+
@depend = pj["depend"] || []
|
24
|
+
end_on_error "#{@plugin_dir}/plugin.json: invalid pluginName" unless @depend.kind_of?(Array)
|
16
25
|
end
|
17
26
|
attr_accessor :name
|
18
27
|
attr_accessor :plugin_dir
|
28
|
+
attr_accessor :depend
|
19
29
|
attr_accessor :loaded_plugin_id
|
20
30
|
|
21
31
|
# ---------------------------------------------------------------------------------------------------------
|
@@ -25,13 +35,7 @@ module PluginTool
|
|
25
35
|
# ---------------------------------------------------------------------------------------------------------
|
26
36
|
|
27
37
|
def start
|
28
|
-
# Check to see if the plugin is valid
|
29
|
-
unless File.file?("#{@name}/plugin.json")
|
30
|
-
end_on_error "Plugin #{@name} does not exist (no plugin.json file)"
|
31
|
-
end
|
32
38
|
# Setup for using the plugin
|
33
|
-
@plugin_dir = @name
|
34
|
-
end_on_error "logic error" unless @plugin_dir =~ /\A[a-zA-Z0-9_-]+\z/
|
35
39
|
@loaded_plugin_id = nil
|
36
40
|
end
|
37
41
|
|
data/lib/plugin_tool.rb
CHANGED
@@ -20,18 +20,20 @@ PluginTool::LocalConfig.load
|
|
20
20
|
|
21
21
|
# Commands not needing server
|
22
22
|
LOCAL_ONLY_COMMANDS = {"license-key" => true, "pack" => true, "check" => true}
|
23
|
-
|
24
|
-
# Plugin names
|
25
|
-
plugin_names = []
|
23
|
+
PLUGIN_SEARCH_PATH = ['.']
|
26
24
|
|
27
25
|
# Options for passing to plugin objects
|
28
|
-
options = Struct.new(:output, :minimiser, :no_console, :show_system_audit, :args, :force, :server_substring).new
|
26
|
+
options = Struct.new(:output, :minimiser, :no_dependency, :no_console, :show_system_audit, :args, :force, :server_substring).new
|
29
27
|
|
30
28
|
# Parse arguments
|
31
29
|
show_help = false
|
30
|
+
workspace_file = nil
|
31
|
+
requested_plugins = []
|
32
32
|
opts = GetoptLong.new(
|
33
33
|
['--help', '-h', GetoptLong::NO_ARGUMENT],
|
34
|
+
['--workspace', '-w', GetoptLong::REQUIRED_ARGUMENT],
|
34
35
|
['--plugin', '-p', GetoptLong::OPTIONAL_ARGUMENT],
|
36
|
+
['--no-dependency', GetoptLong::NO_ARGUMENT],
|
35
37
|
['--server', '-s', GetoptLong::REQUIRED_ARGUMENT],
|
36
38
|
['--force', GetoptLong::NO_ARGUMENT],
|
37
39
|
['--output', GetoptLong::REQUIRED_ARGUMENT],
|
@@ -44,8 +46,12 @@ opts.each do |opt, argument|
|
|
44
46
|
case opt
|
45
47
|
when '--help'
|
46
48
|
show_help = true
|
49
|
+
when '--workspace'
|
50
|
+
workspace_file = argument
|
47
51
|
when '--plugin'
|
48
|
-
|
52
|
+
requested_plugins = argument.split(',').map {|n| n.gsub(/[\/\\]+\z/,'')} # remove trailing dir separators
|
53
|
+
when '--no-dependency'
|
54
|
+
options.no_dependency = true
|
49
55
|
when '--server'
|
50
56
|
options.server_substring = argument
|
51
57
|
when '--output'
|
@@ -64,6 +70,35 @@ end
|
|
64
70
|
PLUGIN_TOOL_COMMAND = (ARGV.shift || 'develop')
|
65
71
|
options.args = ARGV
|
66
72
|
|
73
|
+
# Parse workspace file
|
74
|
+
if workspace_file
|
75
|
+
workspace_json = JSON.parse(File.read(workspace_file))
|
76
|
+
if workspace_json.has_key?("base")
|
77
|
+
workspace_base_json = JSON.parse(File.read(File.dirname(workspace_file)+'/'+workspace_json["base"]))
|
78
|
+
workspace_json = workspace_base_json.merge(workspace_json)
|
79
|
+
end
|
80
|
+
if workspace_json.has_key?("search")
|
81
|
+
PLUGIN_SEARCH_PATH.clear
|
82
|
+
workspace_json["search"].each do |entry|
|
83
|
+
if entry.has_key?("path")
|
84
|
+
path = File.expand_path(File.dirname(workspace_file)+'/'+entry["path"])
|
85
|
+
unless Dir.exist?(path)
|
86
|
+
puts "Can't find directory: #{path}"
|
87
|
+
puts " #{entry["name"]}" if entry.has_key?("name")
|
88
|
+
puts " #{entry["obtain"]}" if entry.has_key?("obtain")
|
89
|
+
exit 1
|
90
|
+
end
|
91
|
+
PLUGIN_SEARCH_PATH.push(path)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
if workspace_json.has_key?("plugins")
|
96
|
+
if requested_plugins.empty?
|
97
|
+
requested_plugins = workspace_json["plugins"]
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
67
102
|
automatic_plugin_exclusion = false
|
68
103
|
|
69
104
|
# Help message?
|
@@ -72,28 +107,27 @@ if show_help || PLUGIN_TOOL_COMMAND == 'help'
|
|
72
107
|
exit 0
|
73
108
|
end
|
74
109
|
|
75
|
-
#
|
76
|
-
|
77
|
-
|
78
|
-
Dir.glob("
|
79
|
-
if p =~ /\A(
|
80
|
-
|
110
|
+
# Find all plugins in the repository
|
111
|
+
plugin_paths = []
|
112
|
+
PLUGIN_SEARCH_PATH.each do |directory|
|
113
|
+
Dir.glob("#{directory}/*/plugin.json").each do |p|
|
114
|
+
if p =~ /\A(.+)\/plugin\.json\z/
|
115
|
+
plugin_paths << $1
|
81
116
|
end
|
82
117
|
end
|
83
|
-
all_plugins
|
84
118
|
end
|
85
119
|
|
86
|
-
if
|
87
|
-
|
120
|
+
if plugin_paths.length == 1 && plugin_paths[0] == 'ALL'
|
121
|
+
plugin_paths = find_all_plugins()
|
88
122
|
automatic_plugin_exclusion = true
|
89
123
|
end
|
90
124
|
|
91
125
|
# Some commands don't require a server or plugin to be specified
|
92
126
|
case PLUGIN_TOOL_COMMAND
|
93
127
|
when 'new'
|
94
|
-
end_on_error "Plugin name not specified, use --plugin option." if
|
95
|
-
end_on_error "Only one plugin name should be specified for new command" if
|
96
|
-
PluginTool.make_new_plugin(
|
128
|
+
end_on_error "Plugin name not specified, use --plugin option." if requested_plugins.empty?
|
129
|
+
end_on_error "Only one plugin name should be specified for new command" if requested_plugins.length > 1
|
130
|
+
PluginTool.make_new_plugin(requested_plugins.first)
|
97
131
|
exit 0
|
98
132
|
when 'auth'
|
99
133
|
PluginTool.cmd_auth options
|
@@ -103,24 +137,47 @@ when 'server'
|
|
103
137
|
exit 0
|
104
138
|
end
|
105
139
|
|
106
|
-
#
|
107
|
-
if
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
all_plugins.each do |name|
|
114
|
-
puts " #{$0} -p #{name}"
|
115
|
-
end
|
116
|
-
exit 1
|
117
|
-
end
|
118
|
-
plugin_names = all_plugins
|
140
|
+
# Check that the user requested a plugin
|
141
|
+
if requested_plugins.empty?
|
142
|
+
end_on_error "No plugin specified, use -p plugin_name to specify or use workspace"
|
143
|
+
end
|
144
|
+
|
145
|
+
def find_plugin_in_list(list, name)
|
146
|
+
list.find { |p| p.name == name }
|
119
147
|
end
|
120
148
|
|
121
149
|
# Make plugin objects, start them, sort by order the server will load them
|
122
|
-
plugins =
|
123
|
-
PluginTool::Plugin.new(
|
150
|
+
plugins = plugin_paths.map do |path|
|
151
|
+
PluginTool::Plugin.new(path, options)
|
152
|
+
end
|
153
|
+
unless requested_plugins == ["ALL"]
|
154
|
+
selected_plugins = plugins.select { |plugin| requested_plugins.include?(plugin.name) }
|
155
|
+
# Attempt to resolve dependencies
|
156
|
+
unless options.no_dependency
|
157
|
+
while true
|
158
|
+
selected_plugins_expanded = selected_plugins.dup
|
159
|
+
selected_plugins.each do |plugin|
|
160
|
+
plugin.depend.each do |name|
|
161
|
+
unless name =~ /\Astd_/
|
162
|
+
unless find_plugin_in_list(selected_plugins_expanded, name)
|
163
|
+
add_plugin = find_plugin_in_list(plugins, name)
|
164
|
+
if add_plugin
|
165
|
+
selected_plugins_expanded << add_plugin
|
166
|
+
else
|
167
|
+
puts "WARNING: Can't find dependency #{name}"
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
break if selected_plugins_expanded.length == selected_plugins.length
|
174
|
+
selected_plugins = selected_plugins_expanded
|
175
|
+
end
|
176
|
+
end
|
177
|
+
plugins = selected_plugins
|
178
|
+
end
|
179
|
+
if plugins.length == 0
|
180
|
+
end_on_error "No plugins selected, check -p option (requested: #{requested_plugins.join(',')})"
|
124
181
|
end
|
125
182
|
plugins.each { |p| p.start }
|
126
183
|
plugins.sort! do |a,b|
|
data/lib/version.txt
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
6a8b347
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: haplo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Haplo Services
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Development tools for developing Haplo plugins, see http://haplo.org
|
14
14
|
email: client.services@haplo-services.com
|