mvn-plugin-config 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +19 -0
- data/Rakefile +30 -0
- data/VERSION +1 -0
- data/bin/mvn-plugin-config +17 -0
- data/bin/mvn-plugin-config.bat +6 -0
- data/lib/mvn_plugin_config/app.rb +134 -0
- data/lib/mvn_plugin_config/directory_scanner.rb +48 -0
- data/lib/mvn_plugin_config/mojo_info.rb +1 -0
- data/lib/mvn_plugin_config/partial.rb +16 -0
- data/lib/mvn_plugin_config/plugin_info.rb +6 -0
- data/lib/mvn_plugin_config.rb +9 -0
- data/lib/start.rb +3 -0
- data/mvn-plugin-config.gemspec +55 -0
- data/views/description.haml +30 -0
- data/views/index.haml +5 -0
- data/views/layout.haml +12 -0
- data/views/stylesheet.sass +62 -0
- metadata +83 -0
data/README.markdown
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
MvnPluginConfig
|
2
|
+
========
|
3
|
+
|
4
|
+
Opens list of maven plugins in browser's window.
|
5
|
+
|
6
|
+
Installation:
|
7
|
+
------------
|
8
|
+
|
9
|
+
Install gem:
|
10
|
+
|
11
|
+
gem install mvn-plugin-config
|
12
|
+
|
13
|
+
Use it:
|
14
|
+
|
15
|
+
mvn-plugin-config
|
16
|
+
|
17
|
+
It will start sinatra application on port 5678 and load start page in the browser.
|
18
|
+
|
19
|
+
Alexander Shvets, alexander.shvets@gmail.com
|
data/Rakefile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'jeweler'
|
7
|
+
Jeweler::Tasks.new do |gemspec|
|
8
|
+
gemspec.name = "mvn-plugin-config"
|
9
|
+
gemspec.summary = "Opens list of maven plugins in browser's window."
|
10
|
+
gemspec.description = "Opens list of maven plugins in browser's window with the ability to see configuration for each of plugins."
|
11
|
+
gemspec.email = "alexander.shvets@gmail.com"
|
12
|
+
gemspec.homepage = "http://github.com/shvets/mvn-plugin-config"
|
13
|
+
gemspec.authors = ["Alexander Shvets"]
|
14
|
+
gemspec.files = FileList["CHANGES", "mvn-plugin-config.gemspec", "Rakefile", "README", "VERSION", "lib/**/*", "bin/**", "public/**", "views/**"]
|
15
|
+
|
16
|
+
gemspec.executables = ['mvn-plugin-config']
|
17
|
+
gemspec.requirements = ["none"]
|
18
|
+
gemspec.bindir = "bin"
|
19
|
+
end
|
20
|
+
rescue LoadError
|
21
|
+
puts "Jeweler not available. Install it for jeweler-related tasks with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
22
|
+
end
|
23
|
+
|
24
|
+
Rake::TestTask.new do |t|
|
25
|
+
t.libs << 'lib'
|
26
|
+
t.pattern = 'test/**/*_test.rb'
|
27
|
+
t.verbose = false
|
28
|
+
end
|
29
|
+
|
30
|
+
task :default => :test
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
require 'rubygems' unless RUBY_VERSION =~ /1.9.*/
|
5
|
+
|
6
|
+
$:.unshift(File::join(File::dirname(File::dirname(__FILE__)), "lib"))
|
7
|
+
|
8
|
+
$KCODE='u'
|
9
|
+
|
10
|
+
require 'mvn_plugin_config'
|
11
|
+
|
12
|
+
require 'vegas'
|
13
|
+
|
14
|
+
trap('INT') { puts "Program was interrupted..."; exit }
|
15
|
+
|
16
|
+
Vegas::Runner.new(MvnPluginConfig::App, 'mvn_plugin_config')
|
17
|
+
|
@@ -0,0 +1,134 @@
|
|
1
|
+
require 'rubygems' unless RUBY_VERSION =~ /1.9.*/
|
2
|
+
|
3
|
+
require 'sinatra/base'
|
4
|
+
require 'haml'
|
5
|
+
require 'sass'
|
6
|
+
require 'zip/zip'
|
7
|
+
require 'nokogiri'
|
8
|
+
|
9
|
+
$:.unshift(File.expand_path(File.join(File.dirname(__FILE__))))
|
10
|
+
|
11
|
+
require 'partial'
|
12
|
+
require 'directory_scanner'
|
13
|
+
require 'plugin_info'
|
14
|
+
require 'mojo_info'
|
15
|
+
|
16
|
+
module MvnPluginConfig
|
17
|
+
class App < Sinatra::Base
|
18
|
+
MAVEN_REPOSITORY = "#{ENV['HOME']}/.m2/repository"
|
19
|
+
|
20
|
+
set :haml, {:format => :html5, :attr_wrapper => '"'}
|
21
|
+
|
22
|
+
# get '/javascripts/*' do
|
23
|
+
# open("#{File.dirname(__FILE__)}/../public/javascripts/#{params[:splat]}")
|
24
|
+
# end
|
25
|
+
|
26
|
+
get '/stylesheet.css' do
|
27
|
+
headers 'Content-Type' => 'text/css; charset=utf-8'
|
28
|
+
sass :stylesheet
|
29
|
+
end
|
30
|
+
|
31
|
+
get '/' do
|
32
|
+
haml :index, :locals => {:plugins => collect_plugins_info}
|
33
|
+
end
|
34
|
+
|
35
|
+
get '/*:*:*' do
|
36
|
+
plugin_file_content = plugin_file_content(params[:splat][0], params[:splat][1], params[:splat][2])
|
37
|
+
|
38
|
+
haml :description, :locals => {:mojos => collect_mojos_info(plugin_file_content)}
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def jar_file_name group_id, artifact_id, version
|
44
|
+
"#{MAVEN_REPOSITORY}/#{group_id.gsub('.', '/')}/#{artifact_id}/#{version}/#{artifact_id}-#{version}.jar"
|
45
|
+
end
|
46
|
+
|
47
|
+
def plugin_file_content group_id, artifact_id, version
|
48
|
+
plugin_file_content = nil
|
49
|
+
|
50
|
+
jar_file_name = jar_file_name(group_id, artifact_id, version)
|
51
|
+
|
52
|
+
Zip::ZipInputStream.open(jar_file_name) do |zis|
|
53
|
+
done = false
|
54
|
+
while (not done) do
|
55
|
+
entry = zis.get_next_entry
|
56
|
+
if entry.name == "META-INF/maven/plugin.xml"
|
57
|
+
plugin_file_content = zis.read
|
58
|
+
done = true
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
plugin_file_content
|
64
|
+
end
|
65
|
+
|
66
|
+
def collect_plugins_info
|
67
|
+
plugins = []
|
68
|
+
|
69
|
+
scanner = DirectoryScanner.new
|
70
|
+
|
71
|
+
scanner.on_dir do |file, path|
|
72
|
+
if file =~ /-plugin$/
|
73
|
+
directories = scanner.directories_in_parent(path)
|
74
|
+
|
75
|
+
directories.each do |version|
|
76
|
+
group_id = path[MAVEN_REPOSITORY.length+1..path.length-file.length-2].gsub('/', '.')
|
77
|
+
artifact_id = file.gsub('/', '.')
|
78
|
+
|
79
|
+
jar_file_name = jar_file_name(group_id, artifact_id, version)
|
80
|
+
|
81
|
+
plugins << PluginInfo.new(group_id, artifact_id, version) if File.exist?(jar_file_name)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
scanner.scan_subtree(MAVEN_REPOSITORY)
|
87
|
+
|
88
|
+
plugins
|
89
|
+
end
|
90
|
+
|
91
|
+
def collect_mojos_info content
|
92
|
+
mojos = []
|
93
|
+
|
94
|
+
doc = Nokogiri::XML(content)
|
95
|
+
|
96
|
+
doc.xpath('//mojos/mojo').each do |node|
|
97
|
+
goal = node.xpath('goal')
|
98
|
+
description = node.xpath('description')
|
99
|
+
|
100
|
+
parameters = collect_parameters(node.xpath('parameters'))
|
101
|
+
configuration = node.xpath('configuration')
|
102
|
+
|
103
|
+
mojos << MojoInfo.new(goal, description, parameters, configuration)
|
104
|
+
end
|
105
|
+
|
106
|
+
mojos
|
107
|
+
end
|
108
|
+
|
109
|
+
def collect_parameters(node)
|
110
|
+
parameters = []
|
111
|
+
|
112
|
+
node.children.each do |param_node|
|
113
|
+
p "1 #{param_node}"
|
114
|
+
if param_node.name == 'parameter'
|
115
|
+
p "2"
|
116
|
+
parameter = {:name => param_node.xpath('name'), :type => param_node.xpath('type'),
|
117
|
+
:required => param_node.xpath('required'), :editable => param_node.xpath('editable'),
|
118
|
+
:description => param_node.xpath('description')}
|
119
|
+
parameters << parameter
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
parameters
|
124
|
+
end
|
125
|
+
|
126
|
+
helpers do
|
127
|
+
include Partial
|
128
|
+
include Rack::Utils
|
129
|
+
|
130
|
+
alias_method :h, :escape_html
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
@@ -0,0 +1,48 @@
|
|
1
|
+
class DirectoryScanner
|
2
|
+
|
3
|
+
def initialize
|
4
|
+
@fileAction = nil
|
5
|
+
@dirAction = nil
|
6
|
+
end
|
7
|
+
|
8
|
+
def on_file(&action)
|
9
|
+
@fileAction = action
|
10
|
+
end
|
11
|
+
|
12
|
+
def on_dir(&action)
|
13
|
+
@dirAction = action
|
14
|
+
end
|
15
|
+
|
16
|
+
def directories_in_parent(parentPath)
|
17
|
+
directories = []
|
18
|
+
Dir.open(parentPath) do |dir|
|
19
|
+
for file in dir
|
20
|
+
next if file == '.';
|
21
|
+
next if file == '..';
|
22
|
+
path = parentPath + File::Separator + file
|
23
|
+
if File.directory? path
|
24
|
+
directories << file
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
directories
|
30
|
+
end
|
31
|
+
|
32
|
+
def scan_subtree(parentPath)
|
33
|
+
Dir.open(parentPath) do |dir|
|
34
|
+
for file in dir
|
35
|
+
next if file == '.';
|
36
|
+
next if file == '..';
|
37
|
+
path = parentPath + File::Separator + file
|
38
|
+
if File.directory? path
|
39
|
+
@dirAction.call(file, path) unless @dirAction.nil?
|
40
|
+
scan_subtree(path)
|
41
|
+
else
|
42
|
+
@fileAction.call(file, path) unless @fileAction.nil?
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
class MojoInfo < Struct.new(:goal, :description, :parameters, :configuration); end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Partial
|
2
|
+
def partial(template, *args)
|
3
|
+
template_array = template.to_s.split('/')
|
4
|
+
template = template_array[0..-2].join('/') + "/_#{template_array[-1]}"
|
5
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
6
|
+
options.merge!(:layout => false)
|
7
|
+
if collection = options.delete(:collection) then
|
8
|
+
collection.inject([]) do |buffer, member|
|
9
|
+
buffer << haml(:"#{template}", options.merge(:layout =>
|
10
|
+
false, :locals => {template_array[-1].to_sym => member}))
|
11
|
+
end.join("\n")
|
12
|
+
else
|
13
|
+
haml(:"#{template}", options)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/start.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{mvn-plugin-config}
|
8
|
+
s.version = "0.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Alexander Shvets"]
|
12
|
+
s.date = %q{2010-05-28}
|
13
|
+
s.default_executable = %q{mvn-plugin-config}
|
14
|
+
s.description = %q{Opens list of maven plugins in browser's window with the ability to see configuration for each of plugins.}
|
15
|
+
s.email = %q{alexander.shvets@gmail.com}
|
16
|
+
s.executables = ["mvn-plugin-config"]
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"README.markdown"
|
19
|
+
]
|
20
|
+
s.files = [
|
21
|
+
"Rakefile",
|
22
|
+
"VERSION",
|
23
|
+
"bin/mvn-plugin-config",
|
24
|
+
"bin/mvn-plugin-config.bat",
|
25
|
+
"lib/mvn_plugin_config.rb",
|
26
|
+
"lib/mvn_plugin_config/app.rb",
|
27
|
+
"lib/mvn_plugin_config/directory_scanner.rb",
|
28
|
+
"lib/mvn_plugin_config/mojo_info.rb",
|
29
|
+
"lib/mvn_plugin_config/partial.rb",
|
30
|
+
"lib/mvn_plugin_config/plugin_info.rb",
|
31
|
+
"lib/start.rb",
|
32
|
+
"mvn-plugin-config.gemspec",
|
33
|
+
"views/description.haml",
|
34
|
+
"views/index.haml",
|
35
|
+
"views/layout.haml",
|
36
|
+
"views/stylesheet.sass"
|
37
|
+
]
|
38
|
+
s.homepage = %q{http://github.com/shvets/mvn-plugin-config}
|
39
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
40
|
+
s.require_paths = ["lib"]
|
41
|
+
s.requirements = ["none"]
|
42
|
+
s.rubygems_version = %q{1.3.7}
|
43
|
+
s.summary = %q{Opens list of maven plugins in browser's window.}
|
44
|
+
|
45
|
+
if s.respond_to? :specification_version then
|
46
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
47
|
+
s.specification_version = 3
|
48
|
+
|
49
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
50
|
+
else
|
51
|
+
end
|
52
|
+
else
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
%table#browse_mojos{:border => "0"}
|
2
|
+
- mojos.each do |mojo_info|
|
3
|
+
%tr
|
4
|
+
%td="Goal: #{mojo_info.goal}"
|
5
|
+
%tr
|
6
|
+
%td="Description: #{mojo_info.description}"
|
7
|
+
%tr
|
8
|
+
%td="Parameters:"
|
9
|
+
%tr
|
10
|
+
%td
|
11
|
+
%table{:border => "1"}
|
12
|
+
- mojo_info.parameters.each do |param|
|
13
|
+
%tr
|
14
|
+
%td="Name"
|
15
|
+
%td="Type"
|
16
|
+
%td="Required"
|
17
|
+
%td="Editable"
|
18
|
+
%td="Description"
|
19
|
+
%tr
|
20
|
+
%td=param[:name]
|
21
|
+
%td=param[:type]
|
22
|
+
%td=param[:required]
|
23
|
+
%td=param[:editable]
|
24
|
+
%td=param[:description]
|
25
|
+
%tr
|
26
|
+
%td="Configuration:"
|
27
|
+
%tr
|
28
|
+
%td
|
29
|
+
%pre=h mojo_info.configuration
|
30
|
+
|
data/views/index.haml
ADDED
data/views/layout.haml
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
!!!
|
2
|
+
%html
|
3
|
+
%head
|
4
|
+
%meta{:'http-equiv' => 'Content-Type', :content => 'text/html; charset=UTF-8'}
|
5
|
+
%title= "Maven Plugin Config"
|
6
|
+
%link{ :href =>"/stylesheet.css", :rel => "stylesheet", :type => "text/css", :media => "screen" }
|
7
|
+
%body
|
8
|
+
#container
|
9
|
+
%p#title=page.page_title if defined?(page.page_title)
|
10
|
+
%p
|
11
|
+
|
12
|
+
= yield
|
@@ -0,0 +1,62 @@
|
|
1
|
+
body
|
2
|
+
:background white
|
3
|
+
:text-align left
|
4
|
+
:font-family Monaco, Verdana
|
5
|
+
:font-size 14px
|
6
|
+
:color black
|
7
|
+
h1
|
8
|
+
:color #97bf0d
|
9
|
+
h2
|
10
|
+
:font-size 14px
|
11
|
+
:font-weight normal
|
12
|
+
|
13
|
+
#title
|
14
|
+
font-weight: bold
|
15
|
+
|
16
|
+
#channel
|
17
|
+
font-style: italic
|
18
|
+
|
19
|
+
td#name
|
20
|
+
:width 550px
|
21
|
+
|
22
|
+
#description
|
23
|
+
:width 900px
|
24
|
+
|
25
|
+
td#channel
|
26
|
+
:width 100px
|
27
|
+
|
28
|
+
tr#page_browser
|
29
|
+
:text-align center
|
30
|
+
|
31
|
+
#container
|
32
|
+
:text-align left
|
33
|
+
:margin 0 auto
|
34
|
+
|
35
|
+
#channel_items
|
36
|
+
:width 600px
|
37
|
+
|
38
|
+
#catalog_items
|
39
|
+
:width 1200px
|
40
|
+
|
41
|
+
#browse_items
|
42
|
+
:width 1200px
|
43
|
+
|
44
|
+
#items
|
45
|
+
:width 1000px
|
46
|
+
|
47
|
+
form
|
48
|
+
label
|
49
|
+
:display block
|
50
|
+
:color #fff
|
51
|
+
input
|
52
|
+
:width 450px
|
53
|
+
:padding 3px
|
54
|
+
:font-size 14px
|
55
|
+
textarea
|
56
|
+
:width 460px
|
57
|
+
:height 150px
|
58
|
+
:font-size 14px
|
59
|
+
:font-family Monaco, Verdana
|
60
|
+
:padding 3px
|
61
|
+
span
|
62
|
+
:color #fff
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mvn-plugin-config
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Alexander Shvets
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-05-28 00:00:00 -04:00
|
19
|
+
default_executable: mvn-plugin-config
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: Opens list of maven plugins in browser's window with the ability to see configuration for each of plugins.
|
23
|
+
email: alexander.shvets@gmail.com
|
24
|
+
executables:
|
25
|
+
- mvn-plugin-config
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files:
|
29
|
+
- README.markdown
|
30
|
+
files:
|
31
|
+
- Rakefile
|
32
|
+
- VERSION
|
33
|
+
- bin/mvn-plugin-config
|
34
|
+
- bin/mvn-plugin-config.bat
|
35
|
+
- lib/mvn_plugin_config.rb
|
36
|
+
- lib/mvn_plugin_config/app.rb
|
37
|
+
- lib/mvn_plugin_config/directory_scanner.rb
|
38
|
+
- lib/mvn_plugin_config/mojo_info.rb
|
39
|
+
- lib/mvn_plugin_config/partial.rb
|
40
|
+
- lib/mvn_plugin_config/plugin_info.rb
|
41
|
+
- lib/start.rb
|
42
|
+
- mvn-plugin-config.gemspec
|
43
|
+
- views/description.haml
|
44
|
+
- views/index.haml
|
45
|
+
- views/layout.haml
|
46
|
+
- views/stylesheet.sass
|
47
|
+
- README.markdown
|
48
|
+
has_rdoc: true
|
49
|
+
homepage: http://github.com/shvets/mvn-plugin-config
|
50
|
+
licenses: []
|
51
|
+
|
52
|
+
post_install_message:
|
53
|
+
rdoc_options:
|
54
|
+
- --charset=UTF-8
|
55
|
+
require_paths:
|
56
|
+
- lib
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
hash: 3
|
63
|
+
segments:
|
64
|
+
- 0
|
65
|
+
version: "0"
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
hash: 3
|
72
|
+
segments:
|
73
|
+
- 0
|
74
|
+
version: "0"
|
75
|
+
requirements:
|
76
|
+
- none
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 1.3.7
|
79
|
+
signing_key:
|
80
|
+
specification_version: 3
|
81
|
+
summary: Opens list of maven plugins in browser's window.
|
82
|
+
test_files: []
|
83
|
+
|