rapt 0.1.0 → 0.2.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/CHANGELOG +5 -0
- data/Rakefile +4 -4
- data/bin/rapt +1 -1
- data/lib/commands/plugin.rb +1 -0
- data/lib/commands/plugin/commands.rb +198 -17
- data/lib/commands/plugin/plugin.rb +72 -11
- data/lib/commands/plugin/plugin_pack.rb +73 -0
- data/lib/commands/plugin/rails_environment.rb +3 -0
- data/lib/commands/plugin/recursive_http_fetcher.rb +1 -0
- data/lib/commands/plugin/repository.rb +1 -2
- data/test/commands/plugin/plugin_test.rb +42 -1
- data/test/commands/plugin/repository_test.rb +8 -0
- data/test/commands/plugin_test.rb +85 -2
- metadata +5 -4
data/CHANGELOG
CHANGED
data/Rakefile
CHANGED
@@ -10,7 +10,7 @@ $:.unshift(File.dirname(__FILE__) + "/lib/commands")
|
|
10
10
|
require 'plugin'
|
11
11
|
|
12
12
|
PKG_NAME = 'rapt'
|
13
|
-
PKG_VERSION = '0.
|
13
|
+
PKG_VERSION = '0.2.0'
|
14
14
|
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
|
15
15
|
|
16
16
|
RELEASE_NAME = "REL #{PKG_VERSION}"
|
@@ -30,7 +30,7 @@ end
|
|
30
30
|
# Genereate the RDoc documentation
|
31
31
|
Rake::RDocTask.new { |rdoc|
|
32
32
|
rdoc.rdoc_dir = 'doc'
|
33
|
-
rdoc.title = "
|
33
|
+
rdoc.title = "RaPT -- Rails Plugin Tool"
|
34
34
|
rdoc.template = "#{ENV['template']}.rb" if ENV['template']
|
35
35
|
rdoc.rdoc_files.include('README', 'CHANGELOG')
|
36
36
|
rdoc.rdoc_files.include('lib/plugin.rb')
|
@@ -41,14 +41,14 @@ Rake::RDocTask.new { |rdoc|
|
|
41
41
|
spec = Gem::Specification.new do |s|
|
42
42
|
s.platform = Gem::Platform::RUBY
|
43
43
|
s.name = PKG_NAME
|
44
|
-
s.summary = "Rails
|
44
|
+
s.summary = "Rails Plugin Tool."
|
45
45
|
s.description = %q{Install, remove, and discover new plugins for your Ruby on Rails app.}
|
46
46
|
s.version = PKG_VERSION
|
47
47
|
|
48
48
|
s.authors = ["Ryan Tomayko", "Geoffrey Grosenbach"]
|
49
49
|
s.email = "boss@topfunky.com"
|
50
50
|
s.rubyforge_project = RUBY_FORGE_PROJECT
|
51
|
-
s.homepage = "http://
|
51
|
+
s.homepage = "http://rapt.rubyforge.org"
|
52
52
|
|
53
53
|
s.has_rdoc = false
|
54
54
|
s.requirements << 'none'
|
data/bin/rapt
CHANGED
data/lib/commands/plugin.rb
CHANGED
@@ -60,6 +60,7 @@ require File.dirname(__FILE__) + '/plugin/repositories'
|
|
60
60
|
require File.dirname(__FILE__) + '/plugin/repository'
|
61
61
|
require File.dirname(__FILE__) + '/plugin/commands'
|
62
62
|
require File.dirname(__FILE__) + '/plugin/recursive_http_fetcher'
|
63
|
+
require File.dirname(__FILE__) + '/plugin/plugin_pack'
|
63
64
|
|
64
65
|
|
65
66
|
|
@@ -38,15 +38,19 @@ module Commands
|
|
38
38
|
o.separator ""
|
39
39
|
o.separator "COMMANDS"
|
40
40
|
|
41
|
-
o.separator " discover
|
42
|
-
o.separator " list
|
43
|
-
o.separator "
|
44
|
-
o.separator "
|
45
|
-
o.separator "
|
46
|
-
o.separator "
|
47
|
-
o.separator "
|
48
|
-
o.separator "
|
49
|
-
o.separator "
|
41
|
+
o.separator " discover Discover plugin repositories."
|
42
|
+
o.separator " list List available plugins."
|
43
|
+
o.separator " search Search for available plugins."
|
44
|
+
o.separator " about Show basic info about a plugin."
|
45
|
+
o.separator " install Install plugin(s) from known repositories or URLs."
|
46
|
+
o.separator " update Update installed plugins."
|
47
|
+
o.separator " remove Uninstall plugins."
|
48
|
+
o.separator " source Add a plugin source repository."
|
49
|
+
o.separator " unsource Remove a plugin repository."
|
50
|
+
o.separator " sources List currently configured plugin repositories."
|
51
|
+
o.separator " pack:install Install plugins from plugin pack file or URL"
|
52
|
+
o.separator " pack:uninstall Uninstall plugins from plugin pack file or URL"
|
53
|
+
o.separator " pack:about Display plugin pack information"
|
50
54
|
|
51
55
|
o.separator ""
|
52
56
|
o.separator "EXAMPLES"
|
@@ -62,6 +66,8 @@ module Commands
|
|
62
66
|
o.separator " #{@script_name} list\n"
|
63
67
|
o.separator " List plugins in the specified repository:"
|
64
68
|
o.separator " #{@script_name} list --source=http://dev.rubyonrails.com/svn/rails/plugins/\n"
|
69
|
+
o.separator " Search available plugins:"
|
70
|
+
o.separator " #{@script_name} search \"authentication\"\n"
|
65
71
|
o.separator " Discover and prompt to add new repositories:"
|
66
72
|
o.separator " #{@script_name} discover\n"
|
67
73
|
o.separator " Discover new repositories but just list them, don't add anything:"
|
@@ -74,6 +80,10 @@ module Commands
|
|
74
80
|
o.separator " #{@script_name} sources\n"
|
75
81
|
o.separator " Show the options for the list command:"
|
76
82
|
o.separator " #{@script_name} list -h\n"
|
83
|
+
o.separator " Install a plugin pack:"
|
84
|
+
o.separator " #{@script_name} pack:install http://opensource.agileevolved.com/pluginpacks/standard.pluginpack\n"
|
85
|
+
o.separator " View plugin pack meta data:"
|
86
|
+
o.separator " #{@script_name} pack:about http://opensource.agileevolved.com/pluginpacks/standard.pluginpack\n"
|
77
87
|
end
|
78
88
|
end
|
79
89
|
|
@@ -82,9 +92,13 @@ module Commands
|
|
82
92
|
options.parse!(general)
|
83
93
|
|
84
94
|
command = general.shift
|
85
|
-
if command =~ /^(list|discover|install|source|unsource|sources|remove|update|about)$/
|
95
|
+
if command =~ /^(list|discover|install|source|unsource|sources|remove|update|about|search)$/
|
86
96
|
command = Commands.const_get(command.capitalize).new(self)
|
87
97
|
command.parse!(sub)
|
98
|
+
elsif command =~ /^(pack:install|pack:uninstall|pack:about)$/
|
99
|
+
command_name = command.split(':')[1]
|
100
|
+
command = Commands::Pack.const_get(command_name.capitalize).new(self)
|
101
|
+
command.parse!(sub)
|
88
102
|
else
|
89
103
|
puts "Unknown command: #{command}"
|
90
104
|
puts options
|
@@ -332,10 +346,12 @@ module Commands
|
|
332
346
|
end
|
333
347
|
|
334
348
|
class Install
|
349
|
+
@@default_method = :http
|
350
|
+
|
335
351
|
def initialize(base_command)
|
336
352
|
@base_command = base_command
|
337
|
-
@method =
|
338
|
-
@options = { :quiet => false, :revision => nil, :force => false }
|
353
|
+
@method = @@default_method
|
354
|
+
@options = { :quiet => false, :revision => nil, :force => false, :force_http => false }
|
339
355
|
end
|
340
356
|
|
341
357
|
def options
|
@@ -359,6 +375,12 @@ module Commands
|
|
359
375
|
"Ignored if subversion is not used.") { |v| @options[:revision] = v }
|
360
376
|
o.on( "-f", "--force",
|
361
377
|
"Reinstalls a plugin if it's already installed.") { |v| @options[:force] = true }
|
378
|
+
o.on( "-c", "--svn",
|
379
|
+
"Modify files with subversion. (Note: svn must be in path)") { |v| @options[:svn] = true }
|
380
|
+
o.on( "-h", "--force-http",
|
381
|
+
"Forces download in HTTP mode") { |v| @options[:force_http] = true }
|
382
|
+
o.on( "--version",
|
383
|
+
"Install a specific version of a plugin") { |v| @options[:version] = v }
|
362
384
|
o.separator ""
|
363
385
|
o.separator "You can specify plugin names as given in 'plugin list' output or absolute URLs to "
|
364
386
|
o.separator "a plugin repository."
|
@@ -366,8 +388,9 @@ module Commands
|
|
366
388
|
end
|
367
389
|
|
368
390
|
def determine_install_method
|
391
|
+
return :http if @options[:force_http]
|
369
392
|
best = @base_command.environment.best_install_method?
|
370
|
-
@method =
|
393
|
+
@method = @@default_method if best == :http and @method == :export
|
371
394
|
case
|
372
395
|
when (best == :http and @method != :http)
|
373
396
|
msg = "Cannot install using subversion because `svn' cannot be found in your PATH"
|
@@ -389,11 +412,48 @@ module Commands
|
|
389
412
|
install_method = determine_install_method
|
390
413
|
puts "Plugins will be installed using #{install_method}" if $verbose
|
391
414
|
args.each do |name|
|
392
|
-
::Plugin.find(name)
|
415
|
+
plugin = ::Plugin.find(name)
|
416
|
+
if @options[:version]
|
417
|
+
if plugin.versions[@options[:version]].nil?
|
418
|
+
puts "Invalid plugin version."
|
419
|
+
exit 1
|
420
|
+
end
|
421
|
+
else
|
422
|
+
set_chosen_version(plugin)
|
423
|
+
end
|
424
|
+
plugin.install(install_method, @options)
|
425
|
+
environment.add_plugin_to_svn(plugin.name) if @options[:svn]
|
426
|
+
end
|
427
|
+
#rescue
|
428
|
+
# puts "Plugin not found: #{args.inspect}"
|
429
|
+
# exit 1
|
430
|
+
end
|
431
|
+
|
432
|
+
def get_version(versions)
|
433
|
+
prompt = "Multiple versions found, which version would you like to install?\n"
|
434
|
+
index = 1
|
435
|
+
versions.keys.sort.reverse.each{ |version| prompt << "#{index.to_s}. #{version}\n"; index = index.next }
|
436
|
+
selected_version = nil
|
437
|
+
while selected_version.nil?
|
438
|
+
puts prompt
|
439
|
+
print "> "
|
440
|
+
selected_version = prompt_for_version
|
441
|
+
selected_version = nil unless (1..versions.size).include?(selected_version.to_i)
|
442
|
+
end
|
443
|
+
return versions.keys.sort.reverse[selected_version-1]
|
444
|
+
end
|
445
|
+
|
446
|
+
def prompt_for_version
|
447
|
+
ARGV.pop
|
448
|
+
gets.strip.to_i
|
449
|
+
end
|
450
|
+
|
451
|
+
def set_chosen_version(plugin)
|
452
|
+
if plugin.versions.size > 1
|
453
|
+
@options[:version] = get_version(plugin.versions)
|
454
|
+
else
|
455
|
+
@options[:version] = plugin.versions.keys.first
|
393
456
|
end
|
394
|
-
rescue
|
395
|
-
puts "Plugin not found: #{args.inspect}"
|
396
|
-
exit 1
|
397
457
|
end
|
398
458
|
end
|
399
459
|
|
@@ -482,5 +542,126 @@ module Commands
|
|
482
542
|
end
|
483
543
|
end
|
484
544
|
end
|
545
|
+
|
546
|
+
class Search
|
547
|
+
require 'net/http'
|
548
|
+
require 'rexml/document'
|
549
|
+
|
550
|
+
def initialize(base_command)
|
551
|
+
@base_command = base_command
|
552
|
+
@directory = "http://www.agilewebdevelopment.com/plugins/search?search=%s"
|
553
|
+
end
|
554
|
+
|
555
|
+
def options
|
556
|
+
OptionParser.new do |o|
|
557
|
+
o.set_summary_indent(' ')
|
558
|
+
o.banner = "Usage: #{@base_command.script_name} search \"search string\""
|
559
|
+
o.on( "-d DIRECTORY", "--directory DIRECTORY",
|
560
|
+
"Queries the URL specified by DIRECTORY.") { |v| @directory = v }
|
561
|
+
o.define_head "Search plugins."
|
562
|
+
end
|
563
|
+
end
|
564
|
+
|
565
|
+
def parse!(args)
|
566
|
+
options.parse!(args)
|
567
|
+
uri = URI.parse(@directory % URI.escape(args.first))
|
568
|
+
request = Net::HTTP.new(uri.host, uri.port)
|
569
|
+
root = REXML::Document.new(request.send_request('GET', uri.request_uri, nil, 'Accept' => 'application/xml').body).root
|
570
|
+
root.elements.each('plugin') do |p|
|
571
|
+
puts p.elements['name'].text
|
572
|
+
puts " Info: #{p.elements['link'].text}"
|
573
|
+
puts " Install: #{p.elements['repository'].text}"
|
574
|
+
end
|
575
|
+
rescue
|
576
|
+
nil
|
577
|
+
end
|
578
|
+
end
|
579
|
+
|
580
|
+
module Pack
|
581
|
+
class Install
|
582
|
+
def initialize(base_command)
|
583
|
+
@base_command = base_command
|
584
|
+
end
|
585
|
+
|
586
|
+
def options
|
587
|
+
OptionParser.new do |o|
|
588
|
+
o.set_summary_indent(' ')
|
589
|
+
o.banner = "Usage: #{@base_command.script_name} pack:install pack_file_or_url"
|
590
|
+
o.define_head "Installs plugin pack at pack_file_or_url"
|
591
|
+
end
|
592
|
+
end
|
593
|
+
|
594
|
+
def parse!(args)
|
595
|
+
uri = args.first
|
596
|
+
plugin_pack = PluginPackParser.parse_spec_file(uri)
|
597
|
+
plugin_pack.plugins.each do |plugin|
|
598
|
+
puts "+ [Adding] #{plugin.name}"
|
599
|
+
plugin.install
|
600
|
+
end
|
601
|
+
end
|
602
|
+
end
|
603
|
+
|
604
|
+
class Uninstall
|
605
|
+
def initialize(base_command)
|
606
|
+
@base_command = base_command
|
607
|
+
end
|
608
|
+
|
609
|
+
def options
|
610
|
+
OptionParser.new do |o|
|
611
|
+
o.set_summary_indent(' ')
|
612
|
+
o.banner = "Usage: #{@base_command.script_name} pack:uninstall pack_file_or_url"
|
613
|
+
o.define_head "Uninstalls plugin pack at pack_file_or_url"
|
614
|
+
end
|
615
|
+
end
|
616
|
+
|
617
|
+
def parse!(args)
|
618
|
+
uri = args.first
|
619
|
+
plugin_pack = PluginPackParser.parse_spec_file(uri)
|
620
|
+
plugin_pack.plugins.each do |plugin|
|
621
|
+
puts "+ [Removing] #{plugin.name}"
|
622
|
+
plugin.uninstall
|
623
|
+
end
|
624
|
+
end
|
625
|
+
end
|
626
|
+
|
627
|
+
class About
|
628
|
+
def initialize(base_command)
|
629
|
+
@base_command = base_command
|
630
|
+
end
|
631
|
+
|
632
|
+
def options
|
633
|
+
OptionParser.new do |o|
|
634
|
+
o.set_summary_indent(' ')
|
635
|
+
o.banner = "Usage: #{@base_command.script_name} pack:about pack_file_or_url"
|
636
|
+
o.define_head "Shows meta-data and plugin list for plugin pack at pack_file_or_url"
|
637
|
+
end
|
638
|
+
end
|
639
|
+
|
640
|
+
def parse!(args)
|
641
|
+
uri = args.first
|
642
|
+
plugin_pack = PluginPackParser.parse_spec_file(uri)
|
643
|
+
display_meta(plugin_pack)
|
644
|
+
display_plugins(plugin_pack)
|
645
|
+
end
|
646
|
+
|
647
|
+
protected
|
648
|
+
def display_meta(plugin_pack)
|
649
|
+
puts "Retrieving information for plugin pack #{plugin_pack.name}"
|
650
|
+
[:description, :author, :email, :website].each do |info_attr|
|
651
|
+
info = plugin_pack.send(info_attr)
|
652
|
+
unless info.nil? or info.empty?
|
653
|
+
puts "* #{info_attr.to_s.capitalize}: #{info}"
|
654
|
+
end
|
655
|
+
end
|
656
|
+
end
|
657
|
+
|
658
|
+
def display_plugins(plugin_pack)
|
659
|
+
puts "Pack contents:"
|
660
|
+
plugin_pack.plugins.each do |plugin|
|
661
|
+
puts "* #{plugin.name}"
|
662
|
+
end
|
663
|
+
end
|
664
|
+
end
|
665
|
+
end
|
485
666
|
end
|
486
667
|
|
@@ -1,12 +1,12 @@
|
|
1
1
|
require 'open-uri'
|
2
2
|
|
3
3
|
class Plugin
|
4
|
-
|
5
|
-
attr_reader :name, :uri
|
4
|
+
attr_reader :name, :uri, :versions
|
6
5
|
|
7
6
|
def initialize(uri, name=nil)
|
8
|
-
@uri = uri
|
9
|
-
guess_name(uri)
|
7
|
+
@uri = normalise_uri(uri)
|
8
|
+
name.nil? ? guess_name(uri) : @name = name
|
9
|
+
check_for_versions
|
10
10
|
end
|
11
11
|
|
12
12
|
def self.find(name)
|
@@ -27,6 +27,8 @@ class Plugin
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def install(method=nil, options = {})
|
30
|
+
options = {:version => "bleeding_edge"}.merge(options)
|
31
|
+
|
30
32
|
method ||= rails_env.best_install_method?
|
31
33
|
method = :export if method == :http and svn_url?
|
32
34
|
|
@@ -110,7 +112,7 @@ class Plugin
|
|
110
112
|
|
111
113
|
def install_using_externals(options = {})
|
112
114
|
externals = rails_env.externals
|
113
|
-
externals.push([@name,
|
115
|
+
externals.push([@name, version_uri(options[:version])])
|
114
116
|
rails_env.externals = externals
|
115
117
|
install_using_checkout(options)
|
116
118
|
end
|
@@ -119,18 +121,18 @@ class Plugin
|
|
119
121
|
root = rails_env.root
|
120
122
|
mkdir_p "#{root}/vendor/plugins"
|
121
123
|
Dir.chdir "#{root}/vendor/plugins"
|
122
|
-
puts "fetching from '#{
|
123
|
-
fetcher =
|
124
|
-
fetcher.
|
125
|
-
|
124
|
+
puts "fetching from '#{version_uri(options[:version])}'" if $verbose
|
125
|
+
fetcher = get_http_fetcher(version_uri(options[:version]), options[:quiet])
|
126
|
+
fetcher.fetch(version_uri(options[:version]))
|
127
|
+
rename_version_to_name(options[:version], options[:quiet])
|
126
128
|
end
|
127
129
|
|
128
130
|
def svn_command(cmd, options = {})
|
129
131
|
root = rails_env.root
|
130
132
|
mkdir_p "#{root}/vendor/plugins"
|
131
|
-
base_cmd = "svn #{cmd} #{
|
133
|
+
base_cmd = "svn #{cmd} #{version_uri(options[:version])} \"#{root}/vendor/plugins/#{name}\""
|
132
134
|
base_cmd += ' -q' if options[:quiet] and not $verbose
|
133
|
-
base_cmd += " -r #{options[:revision]}" if options[:revision]
|
135
|
+
base_cmd += " -r #{options[:revision]}" if options[:revision] and (options[:version] == "bleeding_edge")
|
134
136
|
puts base_cmd if $verbose
|
135
137
|
system(base_cmd)
|
136
138
|
end
|
@@ -145,4 +147,63 @@ class Plugin
|
|
145
147
|
def rails_env
|
146
148
|
@rails_env || RailsEnvironment.default
|
147
149
|
end
|
150
|
+
|
151
|
+
def get_http_fetcher(uri, quiet=true)
|
152
|
+
fetcher = RecursiveHTTPFetcher.new(uri)
|
153
|
+
fetcher.quiet = quiet
|
154
|
+
return fetcher
|
155
|
+
end
|
156
|
+
|
157
|
+
def check_for_versions
|
158
|
+
if svn_url?
|
159
|
+
check_svn_versions
|
160
|
+
else
|
161
|
+
check_http_versions
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
# TODO
|
166
|
+
def check_svn_versions
|
167
|
+
@versions = {"bleeding_edge" => ""}
|
168
|
+
end
|
169
|
+
|
170
|
+
def check_http_versions
|
171
|
+
fetcher = get_http_fetcher(@uri)
|
172
|
+
folders = fetcher.ls
|
173
|
+
if has_trunk?(folders)
|
174
|
+
@versions = {"bleeding_edge" => "trunk/"}
|
175
|
+
if has_tags?(folders)
|
176
|
+
tag_fetcher = get_http_fetcher("#{@uri}tags/")
|
177
|
+
available_tags = tag_fetcher.ls.collect { |tag| tag.gsub("/", "") }
|
178
|
+
available_tags.each { |tag| @versions[tag] = "tags/#{tag}/" }
|
179
|
+
end
|
180
|
+
else
|
181
|
+
@versions = {"bleeding_edge" => ""}
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
def version_uri(version)
|
186
|
+
@uri + @versions[version]
|
187
|
+
end
|
188
|
+
|
189
|
+
def has_trunk?(plugin_root_list)
|
190
|
+
plugin_root_list.grep(/trunk/).size == 1
|
191
|
+
end
|
192
|
+
|
193
|
+
def has_tags?(plugin_root_list)
|
194
|
+
plugin_root_list.grep(/tags/).size == 1
|
195
|
+
end
|
196
|
+
|
197
|
+
# make sure uris always have a trailing slash
|
198
|
+
def normalise_uri(uri)
|
199
|
+
return (uri[-1, 1] == "/" ? uri : uri + '/')
|
200
|
+
end
|
201
|
+
|
202
|
+
def rename_version_to_name(version, quiet=false)
|
203
|
+
return if @versions[version].empty?
|
204
|
+
installed_folder = (version == "bleeding_edge") ? "trunk" : version
|
205
|
+
puts "+ Renaming #{installed_folder} to #{name}" unless quiet and not $verbose
|
206
|
+
FileUtils.mv("#{rails_env.root}/vendor/plugins/#{installed_folder}",
|
207
|
+
"#{rails_env.root}/vendor/plugins/#{name}")
|
208
|
+
end
|
148
209
|
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
class PluginPack
|
5
|
+
attr_reader :plugins, :name
|
6
|
+
attr_accessor :description, :author, :email, :website
|
7
|
+
|
8
|
+
def initialize(name)
|
9
|
+
@name = name
|
10
|
+
@plugins = []
|
11
|
+
@description = ''
|
12
|
+
@author = ''
|
13
|
+
@email = ''
|
14
|
+
@website = ''
|
15
|
+
end
|
16
|
+
|
17
|
+
def add_plugin(name, source)
|
18
|
+
@plugins << Plugin.new(source, name)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class PluginPackPlugin
|
23
|
+
attr_reader :name, :source
|
24
|
+
|
25
|
+
def initialize(name, source)
|
26
|
+
@name, @source = name, source
|
27
|
+
end
|
28
|
+
|
29
|
+
def to_svn_external
|
30
|
+
"#{@name} #{@source}"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
class PluginPackParser
|
35
|
+
def self.parse_spec(spec)
|
36
|
+
pack_spec = YAML.parse(spec)
|
37
|
+
pack_meta = self.parse_pack_meta(pack_spec)
|
38
|
+
pack_plugins = self.parse_pack_plugins(pack_spec)
|
39
|
+
return nil if pack_plugins.empty?
|
40
|
+
pack_name = pack_meta.delete('name') || 'Untitled Pack'
|
41
|
+
pack = PluginPack.new(pack_name)
|
42
|
+
pack_meta.each_pair { |key, value| pack.send("#{key}=", value) if pack.respond_to?(key) }
|
43
|
+
pack_plugins.each_pair { |name, source| pack.add_plugin(name, source) }
|
44
|
+
pack
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.parse_spec_file(spec_file_or_url)
|
48
|
+
self.parse_spec(open(spec_file_or_url))
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.parse_pack_meta(pack_spec)
|
52
|
+
pack_meta = {}
|
53
|
+
return pack_meta if pack_spec['about'].nil?
|
54
|
+
pack_spec['about'].children_with_index.each do |meta|
|
55
|
+
key = meta[1].value
|
56
|
+
value = pack_spec['about'][key].value
|
57
|
+
pack_meta[key] = value
|
58
|
+
end
|
59
|
+
pack_meta
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.parse_pack_plugins(pack_spec)
|
63
|
+
plugins = {}
|
64
|
+
return plugins if pack_spec['plugins'].nil? or pack_spec['plugins'].children.nil?
|
65
|
+
pack_spec['plugins'].children_with_index.each do |p|
|
66
|
+
name = p[1].value
|
67
|
+
next if pack_spec['plugins'][name].nil?
|
68
|
+
source = pack_spec['plugins'][name].value
|
69
|
+
plugins[name] = source
|
70
|
+
end
|
71
|
+
plugins
|
72
|
+
end
|
73
|
+
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
class Repository
|
3
2
|
include Enumerable
|
4
3
|
attr_reader :uri, :plugins
|
@@ -16,7 +15,7 @@ class Repository
|
|
16
15
|
end
|
17
16
|
|
18
17
|
@plugins = index.reject{ |line| line !~ /\/$/ }
|
19
|
-
@plugins.map! { |name| Plugin.new(File.join(@uri, name), name) }
|
18
|
+
@plugins.map! { |name| name.gsub!("/", ""); Plugin.new(File.join(@uri, name), name) }
|
20
19
|
end
|
21
20
|
|
22
21
|
@plugins
|
@@ -18,8 +18,13 @@ class Commands::Plugin::PluginTest < Test::Unit::TestCase
|
|
18
18
|
assert_equal @uri, @plugin.uri
|
19
19
|
end
|
20
20
|
|
21
|
+
def test_versions
|
22
|
+
assert_equal 1, @plugin.versions.size
|
23
|
+
assert_equal "bleeding_edge", @plugin.versions.keys.first
|
24
|
+
end
|
25
|
+
|
21
26
|
def test_to_s
|
22
|
-
assert_equal 'exception_notification http://dev.rubyonrails.org/svn/rails/plugins/exception_notification', @plugin.to_s
|
27
|
+
assert_equal 'exception_notification http://dev.rubyonrails.org/svn/rails/plugins/exception_notification/', @plugin.to_s
|
23
28
|
end
|
24
29
|
|
25
30
|
def test_find
|
@@ -56,3 +61,39 @@ class Commands::Plugin::PluginTest < Test::Unit::TestCase
|
|
56
61
|
end
|
57
62
|
|
58
63
|
end
|
64
|
+
|
65
|
+
class Commands::Plugin::PluginWithSubversionRepoStructureTest < Test::Unit::TestCase
|
66
|
+
def setup
|
67
|
+
@uri = "http://opensource.agileevolved.com/svn/root/rails_plugins/unobtrusive_javascript/"
|
68
|
+
@name = "unobtrusive_javascript"
|
69
|
+
@plugin = Plugin.new @uri, @name
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_url_should_have_subversion_repo_structure
|
73
|
+
fetcher = RecursiveHTTPFetcher.new(@uri)
|
74
|
+
links = fetcher.ls
|
75
|
+
assert !links.grep(/trunk/).empty?
|
76
|
+
assert !links.grep(/tags/).empty?
|
77
|
+
assert !links.grep(/branches/).empty?
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_plugin_should_have_at_least_an_bleeding_edge_version
|
81
|
+
# bleeding edge version == trunk
|
82
|
+
assert @plugin.versions.keys.include?("bleeding_edge")
|
83
|
+
assert_equal "trunk/", @plugin.versions["bleeding_edge"]
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_should_have_tagged_versions
|
87
|
+
assert @plugin.versions.keys.include?("rel-0.1")
|
88
|
+
assert_equal "tags/rel-0.1/", @plugin.versions["rel-0.1"]
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_installing_tagged_version
|
92
|
+
$verbose = true
|
93
|
+
@plugin.install :http, :version => "rel-0.1"
|
94
|
+
assert @plugin.installed?
|
95
|
+
|
96
|
+
@plugin.uninstall
|
97
|
+
assert !@plugin.installed?
|
98
|
+
end
|
99
|
+
end
|
@@ -5,6 +5,14 @@ require File.dirname(__FILE__) + "/../../../lib/commands/plugin"
|
|
5
5
|
require File.dirname(__FILE__) + "/../../mocks/rails_environment"
|
6
6
|
|
7
7
|
# TODO Mock the remote repository so we don't have to hit an actual server for the plugins.
|
8
|
+
# LR: heres one way of sorting this out with a stub for the http fetcher
|
9
|
+
class RecursiveHTTPFetcher
|
10
|
+
def ls
|
11
|
+
['/meta_tags/']
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
|
8
16
|
class Commands::Plugin::RepositoryTest < Test::Unit::TestCase
|
9
17
|
|
10
18
|
def setup
|
@@ -1,16 +1,36 @@
|
|
1
1
|
require 'test/unit'
|
2
2
|
require 'rubygems'
|
3
3
|
require 'fileutils'
|
4
|
+
require 'stringio'
|
4
5
|
$testing = true
|
5
6
|
require File.dirname(__FILE__) + "/../../lib/commands/plugin"
|
6
7
|
require File.dirname(__FILE__) + "/../mocks/rails_environment"
|
7
8
|
|
9
|
+
class Commands::Install
|
10
|
+
def self.default_method=(method)
|
11
|
+
@@default_method = method
|
12
|
+
end
|
13
|
+
|
14
|
+
# dont want to use gets in test
|
15
|
+
def prompt_for_version
|
16
|
+
$selected_version
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
8
20
|
# TODO Mock the remote repository so we don't have to hit an actual server for the plugins.
|
9
21
|
class Commands::PluginTest < Test::Unit::TestCase
|
10
22
|
|
11
23
|
def setup
|
12
24
|
@plugin_name = 'meta_tags'
|
13
25
|
@remote_source = 'http://topfunky.net/svn/plugins'
|
26
|
+
@captured_output = StringIO.new("")
|
27
|
+
end
|
28
|
+
|
29
|
+
def teardown
|
30
|
+
$stdout = STDOUT
|
31
|
+
Commands::Install.default_method = :http
|
32
|
+
`svn revert #{plugin_directory} `
|
33
|
+
`svn cleanup`
|
14
34
|
end
|
15
35
|
|
16
36
|
def test_list
|
@@ -34,7 +54,7 @@ class Commands::PluginTest < Test::Unit::TestCase
|
|
34
54
|
}
|
35
55
|
end
|
36
56
|
|
37
|
-
def
|
57
|
+
def xtest_install
|
38
58
|
run_command('install', File.join(@remote_source, @plugin_name))
|
39
59
|
assert File.exists?(path_to_plugin(@plugin_name) + "/lib"),
|
40
60
|
"Plugin should have been installed at #{path_to_plugin(@plugin_name)}"
|
@@ -48,6 +68,54 @@ class Commands::PluginTest < Test::Unit::TestCase
|
|
48
68
|
ensure
|
49
69
|
FileUtils.rm_rf path_to_plugin(@plugin_name)
|
50
70
|
end
|
71
|
+
|
72
|
+
def test_install_with_svn_add
|
73
|
+
run_command('install', "--svn", File.join(@remote_source, @plugin_name))
|
74
|
+
assert File.exists?(path_to_plugin(@plugin_name) + "/lib"),
|
75
|
+
"Plugin should have been installed at #{path_to_plugin(@plugin_name)}"
|
76
|
+
output = `svn stat`.strip.split("\n")
|
77
|
+
scan_directory(path_to_plugin(@plugin_name)) do |plugin_file|
|
78
|
+
plugin_file.slice!(plugin_directory)
|
79
|
+
assert_equal 1, output.grep(/^A[ ]+#{plugin_file}/).size
|
80
|
+
end
|
81
|
+
ensure
|
82
|
+
FileUtils.rm_rf path_to_plugin(@plugin_name)
|
83
|
+
`svn rm #{path_to_plugin(@plugin_name)}`
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_install_with_forced_http
|
87
|
+
$stdout = @captured_output
|
88
|
+
$verbose = true
|
89
|
+
Commands::Install.default_method = :externals # anything but http
|
90
|
+
output = run_command('install', "--force-http", File.join(@remote_source, @plugin_name))
|
91
|
+
assert File.exists?(path_to_plugin(@plugin_name) + "/lib"),
|
92
|
+
"Plugin should have been installed at #{path_to_plugin(@plugin_name)}"
|
93
|
+
assert @captured_output.string.include?("Plugins will be installed using http")
|
94
|
+
$stdout = STDOUT
|
95
|
+
ensure
|
96
|
+
FileUtils.rm_rf path_to_plugin(@plugin_name)
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_install_with_multiple_versions
|
100
|
+
$selected_version = 1
|
101
|
+
$verbose = true
|
102
|
+
output = run_command("install", "http://opensource.agileevolved.com/svn/root/rails_plugins/unobtrusive_javascript")
|
103
|
+
assert File.exists?(path_to_plugin("unobtrusive_javascript") + "/lib")
|
104
|
+
ensure
|
105
|
+
FileUtils.rm_rf path_to_plugin("unobtrusive_javascript")
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_install_with_specifc_version
|
109
|
+
$stdout = @captured_output
|
110
|
+
$selected_version = 1
|
111
|
+
$verbose = true
|
112
|
+
output = run_command("install", "--version=rel-0.1", "http://opensource.agileevolved.com/svn/root/rails_plugins/unobtrusive_javascript")
|
113
|
+
assert File.exists?(path_to_plugin("unobtrusive_javascript") + "/lib")
|
114
|
+
assert @captured_output.string.include?("Renaming rel-0.1 to unobtrusive_javascript")
|
115
|
+
$stdout = STDOUT
|
116
|
+
ensure
|
117
|
+
FileUtils.rm_rf path_to_plugin("unobtrusive_javascript")
|
118
|
+
end
|
51
119
|
|
52
120
|
# TODO Takes too long...find a way to speed it up
|
53
121
|
# def test_sources
|
@@ -57,6 +125,18 @@ class Commands::PluginTest < Test::Unit::TestCase
|
|
57
125
|
# end
|
58
126
|
|
59
127
|
protected
|
128
|
+
def scan_directory(dirname, &block)
|
129
|
+
Dir.new(dirname).each do |entry|
|
130
|
+
full_path = File.join(dirname, entry)
|
131
|
+
if File.directory?(full_path)
|
132
|
+
unless %w(.svn . ..).include?(entry)
|
133
|
+
scan_directory(full_path, &block)
|
134
|
+
end
|
135
|
+
else
|
136
|
+
yield full_path
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
60
140
|
|
61
141
|
def deny(condition, message=nil)
|
62
142
|
assert !condition, message
|
@@ -68,8 +148,11 @@ protected
|
|
68
148
|
|
69
149
|
# Returns the full path to a locally installed plugin
|
70
150
|
def path_to_plugin(name)
|
71
|
-
|
151
|
+
"#{plugin_directory}#{name}"
|
72
152
|
end
|
73
153
|
|
154
|
+
def plugin_directory
|
155
|
+
RailsEnvironment.default.root + "/vendor/plugins/"
|
156
|
+
end
|
74
157
|
end
|
75
158
|
|
metadata
CHANGED
@@ -3,13 +3,13 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: rapt
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2006-
|
8
|
-
summary: Rails
|
6
|
+
version: 0.2.0
|
7
|
+
date: 2006-10-26 00:00:00 -07:00
|
8
|
+
summary: Rails Plugin Tool.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
11
11
|
email: boss@topfunky.com
|
12
|
-
homepage: http://
|
12
|
+
homepage: http://rapt.rubyforge.org
|
13
13
|
rubyforge_project: rapt
|
14
14
|
description: Install, remove, and discover new plugins for your Ruby on Rails app.
|
15
15
|
autorequire:
|
@@ -39,6 +39,7 @@ files:
|
|
39
39
|
- lib/commands/plugin.rb
|
40
40
|
- lib/commands/plugin/commands.rb
|
41
41
|
- lib/commands/plugin/plugin.rb
|
42
|
+
- lib/commands/plugin/plugin_pack.rb
|
42
43
|
- lib/commands/plugin/rails_environment.rb
|
43
44
|
- lib/commands/plugin/recursive_http_fetcher.rb
|
44
45
|
- lib/commands/plugin/repositories.rb
|