haplo 2.1.6-java → 2.2.0-java

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2580e89728f71a5f2e81403599254853ebd038ca
4
- data.tar.gz: 8c968ba0d72039f7808074c9f446537ed276f374
3
+ metadata.gz: 5c0a878dd42f37f3aec318b396740eb2673cb94d
4
+ data.tar.gz: 24bba608eb2e1aa21b5def4f12f8965e0e31e6e9
5
5
  SHA512:
6
- metadata.gz: 87d9fb09cf7626aade9acc0d551e4a4512c9df50c12e1fc85e3130709c8c063ac61f0c1515d1e0def2b79222e702bcf9080e13a12d150617b78584a97ec29f7e
7
- data.tar.gz: 2422f6a43b7ab1680d56e165be2f07896773f527e2e6cdc7e2e2a8f6d985a522cb77cd13ccc6aeeeed8d3534b4e9ea9c2632e193378f3e6488efa4d90eafabe1
6
+ metadata.gz: eeb2c6fe5e9c54846f8c8b7c697981adda3cd20b5ab45ca032597b9ac174c5d0b3a7f545c5a79677b88a4d2249099664f90d177514f0568521857e14f5fcfc4a
7
+ data.tar.gz: ac136d52d8c9a2bacef648d826d72f142ef640c91b9e47f805f686bf062554ea6b7a65c85b545eec6b9d9e008b2e04858b6bd620a3b3b580caa5d312dd4cdd26
@@ -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.1.6'
7
- s.date = '2016-04-28'
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"]
@@ -10,12 +10,22 @@ module PluginTool
10
10
  class Plugin
11
11
  DEFAULT_PLUGIN_LOAD_PRIORITY = 9999999
12
12
 
13
- def initialize(name, options)
14
- @name = name
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
 
@@ -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
- plugin_names = argument.split(',').map {|n| n.gsub(/[\/\\]+\z/,'')} # remove trailing dir separators
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
- # Plugin names handling
76
- def find_all_plugins()
77
- all_plugins = []
78
- Dir.glob("**/plugin.json").each do |p|
79
- if p =~ /\A([a-zA-Z0-9_]+)\/plugin\.json\z/
80
- all_plugins << $1
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 plugin_names.length == 1 && plugin_names[0] == 'ALL'
87
- plugin_names = find_all_plugins()
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 plugin_names.empty?
95
- end_on_error "Only one plugin name should be specified for new command" if plugin_names.length > 1
96
- PluginTool.make_new_plugin(plugin_names.first)
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
- # Find a plugin if none was specified
107
- if plugin_names.empty?
108
- all_plugins = find_all_plugins()
109
- end_on_error "No plugin found" if all_plugins.length == 0
110
- if all_plugins.length > 1
111
- puts "Too many plugins in the current directory for automatic selection."
112
- puts "Use -p plugin_name to specify. Eg:"
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 = plugin_names.map do |name|
123
- PluginTool::Plugin.new(name, options)
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|
@@ -1 +1 @@
1
- 6c3573a
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.1.6
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-04-28 00:00:00.000000000 Z
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