classx-pluggable 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. data/ChangeLog +221 -0
  2. data/README +88 -0
  3. data/Rakefile +52 -0
  4. data/doc/output/coverage/-Library-Ruby-Gems-gems-classx-0_0_5-lib-classx-attribute_rb.html +925 -0
  5. data/doc/output/coverage/-Library-Ruby-Gems-gems-classx-0_0_5-lib-classx-attributes_rb.html +772 -0
  6. data/doc/output/coverage/-Library-Ruby-Gems-gems-classx-0_0_5-lib-classx-bracketable_rb.html +671 -0
  7. data/doc/output/coverage/-Library-Ruby-Gems-gems-classx-0_0_5-lib-classx-role-logger_rb.html +716 -0
  8. data/doc/output/coverage/-Library-Ruby-Gems-gems-classx-0_0_5-lib-classx-validate_rb.html +663 -0
  9. data/doc/output/coverage/-Library-Ruby-Gems-gems-classx-0_0_5-lib-classx_rb.html +820 -0
  10. data/doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs-block_rb.html +661 -0
  11. data/doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs-callbacks_rb.html +932 -0
  12. data/doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs-change_rb.html +779 -0
  13. data/doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs-hunk_rb.html +867 -0
  14. data/doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs_rb.html +1715 -0
  15. data/doc/output/coverage/-Library-Ruby-Gems-gems-rcov-0_8_1_2_0-lib-rcov_rb.html +1598 -0
  16. data/doc/output/coverage/examples-test_runner-bin-test_runner_rb.html +628 -0
  17. data/doc/output/coverage/examples-test_runner-lib-test_runner-plugin-setup_fixture_rb.html +641 -0
  18. data/doc/output/coverage/examples-test_runner-lib-test_runner-plugin-test_info_rb.html +638 -0
  19. data/doc/output/coverage/examples-test_runner-lib-test_runner-plugin-test_timer_rb.html +666 -0
  20. data/doc/output/coverage/examples-test_runner-lib-test_runner_rb.html +643 -0
  21. data/doc/output/coverage/index.html +711 -0
  22. data/doc/output/coverage/lib-classx-pluggable-plugin_rb.html +676 -0
  23. data/doc/output/coverage/lib-classx-pluggable_rb.html +841 -0
  24. data/examples/test_runner/bin/test_runner.rb +18 -0
  25. data/examples/test_runner/conf/config.yaml +19 -0
  26. data/examples/test_runner/lib/test_runner.rb +33 -0
  27. data/examples/test_runner/lib/test_runner/plugin/setup_fixture.rb +31 -0
  28. data/examples/test_runner/lib/test_runner/plugin/test_info.rb +28 -0
  29. data/examples/test_runner/lib/test_runner/plugin/test_timer.rb +56 -0
  30. data/lib/classx/pluggable.rb +231 -0
  31. data/lib/classx/pluggable/plugin.rb +66 -0
  32. data/spec/classx-pluggable-util/module2path_spec.rb +30 -0
  33. data/spec/classx-pluggable-util/nested_autoload_spec.rb +48 -0
  34. data/spec/classx-pluggable-util/nested_const_get_spec.rb +48 -0
  35. data/spec/classx-pluggable/component_class_get.rb +18 -0
  36. data/spec/classx-pluggable_spec.rb +5 -0
  37. data/spec/example_spec.rb +20 -0
  38. data/spec/spec.opts +1 -0
  39. data/spec/spec_helper.rb +6 -0
  40. data/tasks/basic_config.rake +22 -0
  41. data/tasks/basic_tasks.rake +139 -0
  42. metadata +127 -0
@@ -0,0 +1,30 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'spec_helper')
2
+
3
+ begin
4
+ require 'spec/fixture'
5
+
6
+ describe ClassX::Pluggable::Util, ".module2path" do
7
+ with_fixtures :mod => :path do
8
+ it "should change :mod to :path " do |mod, path|
9
+ ClassX::Pluggable::Util.module2path(mod).should == path
10
+ end
11
+
12
+ set_fixtures([
13
+ [ "Foo" => "foo" ],
14
+ [ "Foo::Bar" => "foo/bar" ],
15
+ [ "Foo::URI" => "foo/uri" ],
16
+ [ "Foo::CamelCase" => "foo/camel_case" ],
17
+ [ "CamelCamelCase" => "camel_camel_case" ],
18
+ [ "Foo::OpenURI" => "foo/open_uri" ],
19
+ [ "Foo::URIOpen" => "foo/uri_open" ],
20
+ [ "Foo::Open_URI" => "foo/open_uri" ],
21
+ [ "Foo::B_B" => "foo/b_b" ],
22
+ [ "Foo::B2B" => "foo/b2b" ],
23
+ [ "CmlCml::CmlCml" => "cml_cml/cml_cml" ],
24
+ [ "Foo::Bar::Baz" => "foo/bar/baz" ],
25
+ ])
26
+ end
27
+ end
28
+ rescue LoadError => e
29
+ warn "skip this spec because of #{e.message.inspect}. if you want to run, please install rspec-fixture."
30
+ end
@@ -0,0 +1,48 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'spec_helper')
2
+
3
+ describe ClassX::Pluggable::Util, '.nested_autoload' do
4
+ include ClassX::Pluggable::Util
5
+
6
+ before :all do
7
+ one_level_const, two_level_const, three_level_const = nil
8
+ Object.class_eval do
9
+ one_level_const = Module.new
10
+ const_set "ClassXPluggableNestedAutoload", one_level_const
11
+ one_level_const.class_eval do
12
+ two_level_const = Module.new
13
+ const_set "Plugin", two_level_const
14
+ two_level_const.class_eval do
15
+ end
16
+ end
17
+ end
18
+
19
+ @one_level_const = one_level_const
20
+ @two_level_const = two_level_const
21
+ @three_level_const = three_level_const
22
+ end
23
+
24
+ it "should autoload non-nested module" do
25
+ Object.autoload?("Foo").should == nil
26
+ nested_autoload("Foo", "hoge/fuga")
27
+ Object.autoload?("Foo").should == "hoge/fuga"
28
+ lambda { Object.const_get("Foo") }.should raise_error(LoadError)
29
+ lambda { Object.const_get("Foo") }.should raise_error(NameError)
30
+ end
31
+
32
+ it "should autoload two level nested module" do
33
+ @one_level_const.autoload?("Bar") == nil
34
+ nested_autoload("ClassXPluggableNestedAutoload::Bar", "hoge/hoge1")
35
+ @one_level_const.autoload?("Bar").should == "hoge/hoge1"
36
+ lambda { @one_level_const.const_get("Bar") }.should raise_error(LoadError)
37
+ lambda { @one_level_const.const_get("Bar") }.should raise_error(NameError)
38
+ end
39
+
40
+ it "should autoload two level nested module" do
41
+ @two_level_const.autoload?("Baz") == nil
42
+ nested_autoload("ClassXPluggableNestedAutoload::Plugin::Baz", "foo/bar/baz")
43
+ @two_level_const.autoload?("Baz").should == "foo/bar/baz"
44
+ lambda { @two_level_const.const_get("Baz") }.should raise_error(LoadError)
45
+ lambda { @two_level_const.const_get("Baz") }.should raise_error(NameError)
46
+ end
47
+ end
48
+
@@ -0,0 +1,48 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'spec_helper')
2
+
3
+ describe ClassX::Pluggable::Util, '.nested_const_get' do
4
+ include ClassX::Pluggable::Util
5
+ before :all do
6
+
7
+ one_level_const, two_level_const, three_level_const = nil
8
+ Object.class_eval do
9
+ one_level_const = Module.new
10
+ const_set "ClassXPluggableNestedConstGet", one_level_const
11
+ one_level_const.class_eval do
12
+ two_level_const = Module.new
13
+ const_set "Plugin", two_level_const
14
+ two_level_const.class_eval do
15
+ three_level_const = Module.new
16
+ const_set "Foo", three_level_const
17
+ end
18
+ end
19
+ end
20
+
21
+ @one_level_const = one_level_const
22
+ @two_level_const = two_level_const
23
+ @three_level_const = three_level_const
24
+ end
25
+
26
+ it "should not raise error on one level const_get" do
27
+ const = nil
28
+ lambda { const = nested_const_get("ClassXPluggableNestedConstGet") }.should_not raise_error
29
+ const.should == @one_level_const
30
+ end
31
+
32
+ it "should not raise error on one two level nested const_get" do
33
+ const = nil
34
+ lambda { const = nested_const_get("ClassXPluggableNestedConstGet::Plugin") }.should_not raise_error
35
+ const.should == @two_level_const
36
+ end
37
+
38
+ it "should not raise error on one three level nested const_get" do
39
+ const = nil
40
+ lambda { const = nested_const_get("ClassXPluggableNestedConstGet::Plugin::Foo") }.should_not raise_error
41
+ const.should == @three_level_const
42
+ end
43
+
44
+ it "should raise NameError on undefined nested constant" do
45
+ const = nil
46
+ lambda { const = nested_const_get("ClassXPluggableNestedConstGet::Plugin::Bar") }.should raise_error(NameError)
47
+ end
48
+ end
@@ -0,0 +1,18 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'spec_helper')
2
+
3
+ describe ClassX::Pluggable, '.component_class_get' do
4
+ before :all do
5
+ module ClassXPluggableComponentClassGet
6
+ include ClassX::Pluggable
7
+
8
+ module Plugin
9
+ class Foo
10
+ end
11
+ end
12
+ end
13
+ end
14
+
15
+ it 'should not raise error when you specify module name starting with plus and ClassXPluggableComponentClassGet::Plugin::Foo is exist' do
16
+ lambda { ClassXPluggableComponentClassGet.component_class_get("plugin", "+Foo") }.should_not raise_error(Exception)
17
+ end
18
+ end
@@ -0,0 +1,5 @@
1
+ require File.join(File.dirname(__FILE__), 'spec_helper')
2
+ require 'classx/pluggable'
3
+
4
+ describe ClassX::Pluggable do
5
+ end
@@ -0,0 +1,20 @@
1
+ require File.join(File.dirname(__FILE__), 'spec_helper')
2
+ require 'logger'
3
+ require 'stringio'
4
+
5
+ def example_check name
6
+ base_dir = File.expand_path(File.join(File.dirname(__FILE__), '..'))
7
+
8
+ target_runner = File.join(base_dir, 'examples', name, 'bin', "#{name}.rb")
9
+
10
+ describe "example", name do
11
+ it "should not raise Exception" do
12
+ lambda {
13
+ $logger = Logger.new(StringIO.new)
14
+ load target_runner
15
+ }.should_not raise_error(Exception)
16
+ end
17
+ end
18
+ end
19
+
20
+ example_check "test_runner"
@@ -0,0 +1 @@
1
+ -Du -c -fs
@@ -0,0 +1,6 @@
1
+ require 'rubygems'
2
+ require 'spec'
3
+ $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + '/../lib/'))
4
+
5
+ require 'classx/pluggable'
6
+
@@ -0,0 +1,22 @@
1
+ AUTHOR = "Keiji, Yoshimi"
2
+ EMAIL = "walf443 at gmail.com"
3
+ RUBYFORGE_PROJECT = "akasakarb"
4
+ RUBYFORGE_PROJECT_ID = 4314
5
+ HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
6
+ RDOC_OPTS = [
7
+ "--charset", "utf-8",
8
+ "--opname", "index.html",
9
+ "--line-numbers",
10
+ "--main", "README",
11
+ "--inline-source",
12
+ '--exclude', '^(example|extras)/'
13
+ ]
14
+ DEFAULT_EXTRA_RDOC_FILES = ['README', 'ChangeLog']
15
+ PKG_FILES = [ 'Rakefile' ] +
16
+ DEFAULT_EXTRA_RDOC_FILES +
17
+ Dir.glob('{bin,lib,test,spec,doc,tasks,script,generator,templates,extras,website}/**/*') +
18
+ Dir.glob('ext/**/*.{h,c,rb}') +
19
+ Dir.glob('examples/**/*') +
20
+ Dir.glob('tools/*.rb')
21
+
22
+ EXTENSIONS = FileList['ext/**/extconf.rb'].to_a
@@ -0,0 +1,139 @@
1
+
2
+ REV = File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
3
+ CLEAN.include ['**/.*.sw?', '*.gem', '.config']
4
+
5
+ Rake::GemPackageTask.new(SPEC) do |p|
6
+ p.need_tar = true
7
+ p.gem_spec = SPEC
8
+ end
9
+
10
+ task :default => [:spec]
11
+ task :test => [:spec]
12
+ task :package => [:clean]
13
+
14
+ require 'spec/rake/spectask'
15
+ Spec::Rake::SpecTask.new(:spec) do |t|
16
+ t.spec_files = FileList['spec/**/*_spec.rb']
17
+ t.spec_opts = ['--options', 'spec/spec.opts']
18
+ t.warning = true
19
+ t.rcov = true
20
+ t.rcov_dir = 'doc/output/coverage'
21
+ t.rcov_opts = ['--exclude', 'spec,\.autotest']
22
+ end
23
+
24
+ desc "Heckle each module and class in turn"
25
+ task :heckle => :spec do
26
+ root_modules = HECKLE_ROOT_MODULES
27
+ spec_files = FileList['spec/**/*_spec.rb']
28
+
29
+ current_module, current_method = nil, nil
30
+ heckle_caught_modules = Hash.new { |hash, key| hash[key] = [] }
31
+ unhandled_mutations = 0
32
+
33
+ root_modules.each do |root_module|
34
+ IO.popen("heckle #{root_module} -t #{spec_files}") do |pipe|
35
+ while line = pipe.gets
36
+ line = line.chomp
37
+
38
+ if line =~ /^\*\*\* ((?:\w+(?:::)?)+)#(\w+)/
39
+ current_module, current_method = $1, $2
40
+ elsif line == "The following mutations didn't cause test failures:"
41
+ heckle_caught_modules[current_module] << current_method
42
+ elsif line == "+++ mutation"
43
+ unhandled_mutations += 1
44
+ end
45
+
46
+ puts line
47
+ end
48
+ end
49
+ end
50
+
51
+ if unhandled_mutations > 0
52
+ error_message_lines = ["*************\n"]
53
+
54
+ error_message_lines <<
55
+ "Heckle found #{unhandled_mutations} " +
56
+ "mutation#{"s" unless unhandled_mutations == 1} " +
57
+ "that didn't cause spec violations\n"
58
+
59
+ heckle_caught_modules.each do |mod, methods|
60
+ error_message_lines <<
61
+ "#{mod} contains the following poorly-specified methods:"
62
+ methods.each do |m|
63
+ error_message_lines << " - #{m}"
64
+ end
65
+ error_message_lines << ""
66
+ end
67
+
68
+ error_message_lines <<
69
+ "Get your act together and come back " +
70
+ "when your specs are doing their job!"
71
+
72
+ puts "*************"
73
+ raise error_message_lines.join("\n")
74
+ else
75
+ puts "Well done! Your code withstood a heckling."
76
+ end
77
+ end
78
+
79
+ require 'spec/rake/verify_rcov'
80
+ RCov::VerifyTask.new(:rcov => :spec) do |t|
81
+ t.index_html = "doc/output/coverage/index.html"
82
+ t.threshold = 100
83
+ end
84
+
85
+ task :install do
86
+ name = "#{NAME}-#{VERS}.gem"
87
+ sh %{rake package}
88
+ sh %{sudo gem install pkg/#{name}}
89
+ end
90
+
91
+ task :uninstall => [:clean] do
92
+ sh %{sudo gem uninstall #{NAME}}
93
+ end
94
+
95
+
96
+ Rake::RDocTask.new do |rdoc|
97
+ rdoc.rdoc_dir = 'html'
98
+ rdoc.options += RDOC_OPTS
99
+ rdoc.template = "resh"
100
+ #rdoc.template = "#{ENV['template']}.rb" if ENV['template']
101
+ if ENV['DOC_FILES']
102
+ rdoc.rdoc_files.include(ENV['DOC_FILES'].split(/,\s*/))
103
+ else
104
+ rdoc.rdoc_files.include('README', 'ChangeLog')
105
+ rdoc.rdoc_files.include('lib/**/*.rb')
106
+ rdoc.rdoc_files.include('ext/**/*.c')
107
+ end
108
+ end
109
+
110
+ desc "Publish to RubyForge"
111
+ task :rubyforge => [:rdoc, :package] do
112
+ require 'rubyforge'
113
+ Rake::RubyForgePublisher.new(RUBYFORGE_PROJECT, 'yoshimi').upload
114
+ end
115
+
116
+ desc 'Package and upload the release to rubyforge.'
117
+ task :release => [:clean, :package] do |t|
118
+ require 'rubyforge'
119
+ v = ENV["VERSION"] or abort "Must supply VERSION=x.y.z"
120
+ abort "Versions don't match #{v} vs #{VERS}" unless v == VERS
121
+ pkg = "pkg/#{NAME}-#{VERS}"
122
+
123
+ rf = RubyForge.new
124
+ puts "Logging in"
125
+ rf.login
126
+
127
+ c = rf.userconfig
128
+ # c["release_notes"] = description if description
129
+ # c["release_changes"] = changes if changes
130
+ c["preformatted"] = true
131
+
132
+ files = [
133
+ "#{pkg}.tgz",
134
+ "#{pkg}.gem"
135
+ ].compact
136
+
137
+ puts "Releasing #{NAME} v. #{VERS}"
138
+ rf.add_release RUBYFORGE_PROJECT_ID, RUBYFORGE_PACKAGE_ID, VERS, *files
139
+ end
metadata ADDED
@@ -0,0 +1,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: classx-pluggable
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Keiji, Yoshimi
8
+ autorequire: ""
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-11-08 00:00:00 +09:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: classx
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.1
24
+ version:
25
+ description: make your class to pluggable.
26
+ email: walf443 at gmail.com
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - README
33
+ - ChangeLog
34
+ files:
35
+ - Rakefile
36
+ - README
37
+ - ChangeLog
38
+ - lib/classx
39
+ - lib/classx/pluggable
40
+ - lib/classx/pluggable/plugin.rb
41
+ - lib/classx/pluggable.rb
42
+ - spec/classx-pluggable
43
+ - spec/classx-pluggable/component_class_get.rb
44
+ - spec/classx-pluggable-util
45
+ - spec/classx-pluggable-util/module2path_spec.rb
46
+ - spec/classx-pluggable-util/nested_autoload_spec.rb
47
+ - spec/classx-pluggable-util/nested_const_get_spec.rb
48
+ - spec/classx-pluggable_spec.rb
49
+ - spec/example_spec.rb
50
+ - spec/spec.opts
51
+ - spec/spec_helper.rb
52
+ - doc/output
53
+ - doc/output/coverage
54
+ - doc/output/coverage/-Library-Ruby-Gems-gems-classx-0_0_5-lib-classx-attribute_rb.html
55
+ - doc/output/coverage/-Library-Ruby-Gems-gems-classx-0_0_5-lib-classx-attributes_rb.html
56
+ - doc/output/coverage/-Library-Ruby-Gems-gems-classx-0_0_5-lib-classx-bracketable_rb.html
57
+ - doc/output/coverage/-Library-Ruby-Gems-gems-classx-0_0_5-lib-classx-role-logger_rb.html
58
+ - doc/output/coverage/-Library-Ruby-Gems-gems-classx-0_0_5-lib-classx-validate_rb.html
59
+ - doc/output/coverage/-Library-Ruby-Gems-gems-classx-0_0_5-lib-classx_rb.html
60
+ - doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs-block_rb.html
61
+ - doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs-callbacks_rb.html
62
+ - doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs-change_rb.html
63
+ - doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs-hunk_rb.html
64
+ - doc/output/coverage/-Library-Ruby-Gems-gems-diff-lcs-1_1_2-lib-diff-lcs_rb.html
65
+ - doc/output/coverage/-Library-Ruby-Gems-gems-rcov-0_8_1_2_0-lib-rcov_rb.html
66
+ - doc/output/coverage/examples-test_runner-bin-test_runner_rb.html
67
+ - doc/output/coverage/examples-test_runner-lib-test_runner-plugin-setup_fixture_rb.html
68
+ - doc/output/coverage/examples-test_runner-lib-test_runner-plugin-test_info_rb.html
69
+ - doc/output/coverage/examples-test_runner-lib-test_runner-plugin-test_timer_rb.html
70
+ - doc/output/coverage/examples-test_runner-lib-test_runner_rb.html
71
+ - doc/output/coverage/index.html
72
+ - doc/output/coverage/lib-classx-pluggable-plugin_rb.html
73
+ - doc/output/coverage/lib-classx-pluggable_rb.html
74
+ - tasks/basic_config.rake
75
+ - tasks/basic_tasks.rake
76
+ - examples/test_runner
77
+ - examples/test_runner/bin
78
+ - examples/test_runner/bin/test_runner.rb
79
+ - examples/test_runner/conf
80
+ - examples/test_runner/conf/config.yaml
81
+ - examples/test_runner/lib
82
+ - examples/test_runner/lib/test_runner
83
+ - examples/test_runner/lib/test_runner/plugin
84
+ - examples/test_runner/lib/test_runner/plugin/setup_fixture.rb
85
+ - examples/test_runner/lib/test_runner/plugin/test_info.rb
86
+ - examples/test_runner/lib/test_runner/plugin/test_timer.rb
87
+ - examples/test_runner/lib/test_runner.rb
88
+ has_rdoc: true
89
+ homepage: http://akasakarb.rubyforge.org
90
+ post_install_message:
91
+ rdoc_options:
92
+ - --charset
93
+ - utf-8
94
+ - --opname
95
+ - index.html
96
+ - --line-numbers
97
+ - --main
98
+ - README
99
+ - --inline-source
100
+ - --exclude
101
+ - ^(example|extras)/
102
+ - --title
103
+ - classx-pluggable documentation
104
+ require_paths:
105
+ - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: "0"
111
+ version:
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: "0"
117
+ version:
118
+ requirements: []
119
+
120
+ rubyforge_project: akasakarb
121
+ rubygems_version: 1.3.0
122
+ signing_key:
123
+ specification_version: 2
124
+ summary: make your class to pluggable.
125
+ test_files:
126
+ - spec/classx-pluggable_spec.rb
127
+ - spec/example_spec.rb