gem_plugin 0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,73 @@
1
+ require 'test/unit'
2
+ require 'gem_plugin'
3
+
4
+ include GemPlugin
5
+
6
+ class ATestPlugin < GemPlugin::Plugin "/stuff"
7
+ end
8
+
9
+ class First < GemPlugin::Plugin "/commands"
10
+ def initialize(options = {})
11
+ puts "First with options: #{options.inspect}"
12
+ end
13
+ end
14
+
15
+ class Second < GemPlugin::Plugin "/commands"
16
+ def initialize(options = {})
17
+ puts "Second with options: #{options.inspect}"
18
+ end
19
+ end
20
+
21
+ class Last < GemPlugin::Plugin "/commands"
22
+ def initialize(options = {})
23
+ puts "Last with options: #{options.inspect}"
24
+ end
25
+ end
26
+
27
+
28
+ class PluginTest < Test::Unit::TestCase
29
+
30
+ def setup
31
+ @pmgr = Manager.instance
32
+ @pmgr.load({"rails" => EXCLUDE})
33
+ @categories = ["/commands"]
34
+ @names = ["/first", "/second", "/last", "/atestplugin"]
35
+ end
36
+
37
+ def test_load_plugins
38
+ puts "#{@pmgr.available.inspect}"
39
+ @pmgr.available.each {|cat,plugins|
40
+ plugins.each do |n,p|
41
+ puts "TEST: #{cat}#{n}"
42
+ assert @names.include?(n)
43
+ end
44
+ }
45
+
46
+ @pmgr.load
47
+ @pmgr.available.each do |cat,plugins|
48
+ plugins.each do |n,p|
49
+ STDERR.puts "#{cat}#{n}"
50
+ plugin = @pmgr.create("#{cat}#{n}", options={"name" => p})
51
+ end
52
+ end
53
+ end
54
+
55
+ def test_similar_uris
56
+
57
+ @pmgr.register("/test", "/testme", ATestPlugin)
58
+ @pmgr.register("/test2", "/testme", ATestPlugin)
59
+
60
+ assert_equal @pmgr.create("/test/testme").class, ATestPlugin
61
+ assert_equal @pmgr.create("/test2/testme").class, ATestPlugin
62
+
63
+ end
64
+
65
+
66
+ def test_create
67
+ last = @pmgr.create("/commands/last", "test" => "stuff")
68
+ assert last != nil, "Didn't make the right plugin"
69
+ first = @pmgr.create("/commands/last")
70
+ assert first != nil, "Didn't make the right plugin"
71
+ end
72
+
73
+ end
@@ -0,0 +1,111 @@
1
+
2
+ def make(makedir)
3
+ Dir.chdir(makedir) do
4
+ sh(PLATFORM =~ /win32/ ? 'nmake' : 'make')
5
+ end
6
+ end
7
+
8
+
9
+ def extconf(dir)
10
+ Dir.chdir(dir) do ruby "extconf.rb" end
11
+ end
12
+
13
+
14
+ def setup_tests
15
+ Rake::TestTask.new do |t|
16
+ t.libs << "test"
17
+ t.test_files = FileList['test/test*.rb']
18
+ t.verbose = true
19
+ end
20
+ end
21
+
22
+
23
+ def setup_clean otherfiles
24
+ files = ['build/*', '**/*.o', '**/*.so', '**/*.a', 'lib/*-*', '**/*.log'] + otherfiles
25
+ CLEAN.include(files)
26
+ end
27
+
28
+
29
+ def setup_rdoc files
30
+ Rake::RDocTask.new do |rdoc|
31
+ rdoc.rdoc_dir = 'doc/rdoc'
32
+ rdoc.options << '--line-numbers'
33
+ rdoc.rdoc_files.add(files)
34
+ end
35
+ end
36
+
37
+
38
+ def setup_extension(dir, extension)
39
+ ext = "ext/#{dir}"
40
+ ext_so = "#{ext}/#{extension}.#{Config::CONFIG['DLEXT']}"
41
+ ext_files = FileList[
42
+ "#{ext}/*.c",
43
+ "#{ext}/*.h",
44
+ "#{ext}/extconf.rb",
45
+ "#{ext}/Makefile",
46
+ "lib"
47
+ ]
48
+
49
+ task "lib" do
50
+ directory "lib"
51
+ end
52
+
53
+ desc "Builds just the #{extension} extension"
54
+ task extension.to_sym => ["#{ext}/Makefile", ext_so ]
55
+
56
+ file "#{ext}/Makefile" => ["#{ext}/extconf.rb"] do
57
+ extconf "#{ext}"
58
+ end
59
+
60
+ file ext_so => ext_files do
61
+ make "#{ext}"
62
+ cp ext_so, "lib"
63
+ end
64
+ end
65
+
66
+
67
+ def base_gem_spec(pkg_name, pkg_version, author, summary, executables, test_file)
68
+ pkg_version = pkg_version
69
+ pkg_name = pkg_name
70
+ pkg_file_name = "#{pkg_name}-#{pkg_version}"
71
+ Gem::Specification.new do |s|
72
+ s.name = pkg_name
73
+ s.version = pkg_version
74
+ s.required_ruby_version = '>= 1.8.3'
75
+ s.platform = Gem::Platform::RUBY
76
+ s.author = author
77
+ s.summary = summary
78
+ s.test_file = test_file
79
+ s.has_rdoc = true
80
+ s.extra_rdoc_files = [ "README" ]
81
+
82
+ s.files = %w(COPYING LICENSE README Rakefile) +
83
+ Dir.glob("{bin,doc/rdoc,test,lib}/**/*") +
84
+ Dir.glob("ext/**/*.{h,c,rb}") +
85
+ Dir.glob("examples/**/*.rb") +
86
+ Dir.glob("tools/*.rb")
87
+
88
+ s.require_path = "lib"
89
+ s.extensions = FileList["ext/**/extconf.rb"].to_a
90
+
91
+ s.executables = executables
92
+ s.bindir = "bin"
93
+ end
94
+ end
95
+
96
+ def setup_gem(pkg_name, pkg_version, author, summary, executables, test_file)
97
+ spec = base_gem_spec(pkg_name, pkg_version, author, summary, executables, test_file)
98
+ yield spec if block_given?
99
+
100
+ Rake::GemPackageTask.new(spec) do |p|
101
+ p.gem_spec = spec
102
+ p.need_tar = true
103
+ end
104
+ end
105
+
106
+ def setup_win32_gem(pkg_name, pkg_version, author, summary, executables, test_file)
107
+ spec = base_gem_spec(pkg_name, pkg_version, author, summary, executables, test_file)
108
+ yield spec if block_given?
109
+
110
+ Gem::Builder.new(spec).build
111
+ end
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.8.11
3
+ specification_version: 1
4
+ name: gem_plugin
5
+ version: !ruby/object:Gem::Version
6
+ version: "0.1"
7
+ date: 2006-03-06 00:00:00 -05:00
8
+ summary: A plugin system based only on rubygems
9
+ require_paths:
10
+ - lib
11
+ email:
12
+ homepage:
13
+ rubyforge_project:
14
+ description:
15
+ autorequire: gem_plugin
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.8.3
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ authors:
29
+ - Zed A. Shaw
30
+ files:
31
+ - COPYING
32
+ - LICENSE
33
+ - README
34
+ - Rakefile
35
+ - doc/rdoc/classes
36
+ - doc/rdoc/created.rid
37
+ - doc/rdoc/files
38
+ - doc/rdoc/fr_class_index.html
39
+ - doc/rdoc/fr_file_index.html
40
+ - doc/rdoc/fr_method_index.html
41
+ - doc/rdoc/index.html
42
+ - doc/rdoc/rdoc-style.css
43
+ - doc/rdoc/classes/GemPlugin
44
+ - doc/rdoc/classes/GemPlugin.html
45
+ - doc/rdoc/classes/GemPlugin.src
46
+ - doc/rdoc/classes/GemPlugin/Base.html
47
+ - doc/rdoc/classes/GemPlugin/Base.src
48
+ - doc/rdoc/classes/GemPlugin/Manager.html
49
+ - doc/rdoc/classes/GemPlugin/Manager.src
50
+ - doc/rdoc/classes/GemPlugin/Base.src/M000002.html
51
+ - doc/rdoc/classes/GemPlugin/Base.src/M000003.html
52
+ - doc/rdoc/classes/GemPlugin/Base.src/M000004.html
53
+ - doc/rdoc/classes/GemPlugin/Manager.src/M000005.html
54
+ - doc/rdoc/classes/GemPlugin/Manager.src/M000006.html
55
+ - doc/rdoc/classes/GemPlugin/Manager.src/M000007.html
56
+ - doc/rdoc/classes/GemPlugin/Manager.src/M000008.html
57
+ - doc/rdoc/classes/GemPlugin/Manager.src/M000009.html
58
+ - doc/rdoc/classes/GemPlugin.src/M000001.html
59
+ - doc/rdoc/files/COPYING.html
60
+ - doc/rdoc/files/lib
61
+ - doc/rdoc/files/LICENSE.html
62
+ - doc/rdoc/files/README.html
63
+ - doc/rdoc/files/lib/gem_plugin_rb.html
64
+ - test/test_plugins.rb
65
+ - lib/gem_plugin.rb
66
+ - tools/rakehelp.rb
67
+ test_files:
68
+ - test/test_plugins.rb
69
+ rdoc_options: []
70
+
71
+ extra_rdoc_files:
72
+ - README
73
+ executables: []
74
+
75
+ extensions: []
76
+
77
+ requirements: []
78
+
79
+ dependencies: []
80
+