contextr 1.0.2 → 1.0.3

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/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ website/test
2
+ pkg
3
+ doc
4
+ *.rbc
5
+ .DS_Store
6
+ .*.swp
data/History.txt CHANGED
@@ -1,3 +1,9 @@
1
+ == 1.0.3 2009-12-03
2
+
3
+ * minor changes
4
+ * updated to jeweler
5
+ * releasing on gemcutter
6
+
1
7
  == 1.0.2 2008-04-01
2
8
 
3
9
  * 1 major change
File without changes
data/Rakefile CHANGED
@@ -1,136 +1,53 @@
1
- require 'rubygems'
2
1
  require 'rake'
3
- require 'rake/clean'
4
- require 'rake/testtask'
5
- require 'rake/packagetask'
6
- require 'rake/gempackagetask'
7
2
  require 'rake/rdoctask'
8
- require 'rake/contrib/rubyforgepublisher'
9
- require 'fileutils'
10
- require 'hoe'
11
- begin
12
- require 'spec/rake/spectask'
13
- rescue LoadError
14
- puts 'To use rspec for testing you must install rspec gem:'
15
- puts '$ sudo gem install rspec'
16
- exit
17
- end
18
3
 
19
- include FileUtils
20
- require File.join(File.dirname(__FILE__), 'lib', 'contextr', 'version')
21
-
22
- AUTHOR = 'Gregor Schmidt' # can also be an array of Authors
23
- EMAIL = "ruby@schmidtwisser.de"
24
- DESCRIPTION = "The goal is to equip Ruby with an API to allow context-oriented programming."
25
- GEM_NAME = 'contextr' # what ppl will type to install your gem
26
-
27
- @config_file = "~/.rubyforge/user-config.yml"
28
- @config = nil
29
- def rubyforge_username
30
- unless @config
31
- begin
32
- @config = YAML.load(File.read(File.expand_path(@config_file)))
33
- rescue
34
- puts <<-EOS
35
- ERROR: No rubyforge config file found: #{@config_file}"
36
- Run 'rubyforge setup' to prepare your env for access to Rubyforge
37
- - See http://newgem.rubyforge.org/rubyforge.html for more details
38
- EOS
39
- exit
40
- end
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gemspec|
7
+ gemspec.name = "contextr"
8
+ gemspec.summary = "Context-oriented programming API for Ruby"
9
+ gemspec.description = "The goal is to equip Ruby with an API to allow " +
10
+ "context-oriented programming."
11
+ gemspec.email = "ruby@schmidtwisser.de"
12
+ gemspec.homepage = "http://github.com/schmidt/contextr"
13
+ gemspec.authors = ["Gregor Schmidt"]
14
+
15
+ gemspec.add_development_dependency('rake')
16
+ gemspec.add_development_dependency('markaby')
17
+ gemspec.add_development_dependency('literate_maruku')
18
+ gemspec.add_development_dependency('rspec')
19
+ gemspec.add_development_dependency('jeweler', '>= 1.4.0')
41
20
  end
42
- @rubyforge_username ||= @config["username"]
43
- end
44
-
45
- RUBYFORGE_PROJECT = 'contextr' # The unix name for your project
46
- HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
47
- DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
48
-
49
- NAME = "contextr"
50
- REV = nil
51
- # UNCOMMENT IF REQUIRED:
52
- # REV = `svn info`.each {|line| if line =~ /^Revision:/ then k,v = line.split(': '); break v.chomp; else next; end} rescue nil
53
- VERS = ContextR::VERSION::STRING + (REV ? ".#{REV}" : "")
54
- CLEAN.include ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store']
55
- RDOC_OPTS = ['--quiet', '--title', 'contextr documentation',
56
- "--opname", "index.html",
57
- "--line-numbers",
58
- "--main", "README",
59
- "--inline-source"]
60
21
 
61
- class Hoe
62
- def extra_deps
63
- @extra_deps.reject { |x| Array(x).first == 'hoe' }
64
- end
65
- end
66
-
67
- # Generate all the Rake tasks
68
- # Run 'rake -T' to see list of generated tasks (from gem root directory)
69
- hoe = Hoe.new(GEM_NAME, VERS) do |p|
70
- p.author = AUTHOR
71
- p.description = DESCRIPTION
72
- p.email = EMAIL
73
- p.summary = DESCRIPTION
74
- p.url = HOMEPATH
75
- p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
76
- p.test_globs = ["test/**/test_*.rb"]
77
- p.clean_globs |= CLEAN #An array of file patterns to delete on clean.
78
-
79
- # == Optional
80
- p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
81
- #p.extra_deps = [] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
82
- #p.spec_extras = {} # A hash of extra values to set in the gemspec.
83
- end
84
-
85
- CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\n\n")
86
- PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
87
- hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
88
-
89
- desc 'Generate website files'
90
- task :website_generate do
91
- Dir['website/**/*.txt'].each do |txt|
92
- sh %{ ruby scripts/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
93
- end
22
+ Jeweler::GemcutterTasks.new
23
+ rescue LoadError
24
+ puts "Jeweler not available. Install it with: sudo gem install jeweler"
94
25
  end
95
26
 
96
- desc 'Upload website files to rubyforge'
97
- task :website_upload do
98
- host = "#{rubyforge_username}@rubyforge.org"
99
- remote_dir = "/var/www/gforge-projects/#{PATH}/"
100
- local_dir = 'website'
101
- sh %{rsync -aCv #{local_dir}/ #{host}:#{remote_dir}}
27
+ desc 'Generate documentation for the literate_maruku gem.'
28
+ Rake::RDocTask.new(:doc) do |doc|
29
+ doc.rdoc_dir = 'doc'
30
+ doc.title = 'ContextR'
31
+ doc.options << '--line-numbers' << '--inline-source'
32
+ doc.rdoc_files.include('README.rdoc')
33
+ doc.rdoc_files.include('lib/**/*.rb')
102
34
  end
103
35
 
104
- desc 'Generate and upload website files'
105
- task :website => [:website_generate, :website_upload, :publish_docs]
106
-
107
- desc 'Release the website and new gem version'
108
- task :deploy => [:check_version, :website, :release] do
109
- puts "Remember to create SVN tag:"
110
- puts "svn copy svn+ssh://rubyforge.org/var/svn/#{PATH}/trunk " +
111
- "svn+ssh://rubyforge.org/var/svn/#{PATH}/tags/contextr-#{VERS} "
112
- puts "Suggested comment:"
113
- puts "Tagging release #{CHANGES}"
36
+ desc "Run the tests under test"
37
+ task :test do
38
+ require 'rake/runtest'
39
+ Rake.run_tests 'test/**/test_*.rb'
114
40
  end
115
41
 
116
- desc 'Runs tasks website_generate and install_gem as a local deployment of the gem'
117
- task :local_deploy => [:website_generate, :install_gem]
118
-
119
- task :check_version do
120
- unless ENV['VERSION']
121
- puts 'Must pass a VERSION=x.y.z release version'
122
- exit
123
- end
124
- unless ENV['VERSION'] == VERS
125
- puts "Please update your version.rb to match the release version, currently #{VERS}"
126
- exit
42
+ begin
43
+ require 'spec/rake/spectask'
44
+ desc "Run the specs under spec"
45
+ Spec::Rake::SpecTask.new do |t|
46
+ t.spec_opts = ['--options', "spec/spec.opts"]
47
+ t.spec_files = FileList['spec/*_spec.rb']
127
48
  end
128
- end
129
-
130
- desc "Run the specs under spec/models"
131
- Spec::Rake::SpecTask.new do |t|
132
- t.spec_opts = ['--options', "spec/spec.opts"]
133
- t.spec_files = FileList['spec/*_spec.rb']
49
+ rescue LoadError
50
+ puts "RSpec not available. Install it with: sudo gem install rspec"
134
51
  end
135
52
 
136
53
  desc "Run specs and tests by default"
data/TODO.taskpaper ADDED
@@ -0,0 +1,2 @@
1
+ Future Release X:
2
+ - deactivate layers before entering ContextR code and activate them on leave
data/VERSION.yml ADDED
@@ -0,0 +1,4 @@
1
+ ---
2
+ :major: 1
3
+ :minor: 0
4
+ :patch: 3
@@ -0,0 +1,3 @@
1
+ Autotest.add_discovery do
2
+ ["rspec", "test"]
3
+ end
@@ -0,0 +1,13 @@
1
+ require 'rubygems'
2
+ require 'autotest/rspec'
3
+
4
+ class Autotest
5
+ class RspecTest
6
+ def self.run
7
+ Thread.new do
8
+ Autotest::Rspec.run
9
+ end
10
+ Autotest.run
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,91 @@
1
+ require 'benchmark'
2
+ require File.dirname( __FILE__ ) + '/../../lib/contextr'
3
+
4
+ class Foo
5
+ def ordinary
6
+ true
7
+ end
8
+
9
+ def once
10
+ true
11
+ end
12
+
13
+ def twice
14
+ true
15
+ end
16
+
17
+ def wrapped
18
+ true
19
+ end
20
+
21
+ def full
22
+ true
23
+ end
24
+
25
+ def claimed
26
+ true
27
+ end
28
+
29
+ in_layer :once do
30
+ def once
31
+ true
32
+ end
33
+ def twice
34
+ true
35
+ end
36
+ end
37
+
38
+ in_layer :two do
39
+ def twice
40
+ true
41
+ end
42
+ end
43
+ end
44
+
45
+ f = Foo.new
46
+
47
+ n = 100_000
48
+ Benchmark.bmbm(20) do |x|
49
+ x.report("Ordinary:") {
50
+ n.times { f.ordinary }
51
+ }
52
+
53
+ x.report("Once (w/o):") {
54
+ n.times { f.once }
55
+ }
56
+
57
+ x.report("Once (ctx):") {
58
+ ContextR.with_layers :one do
59
+ n.times { f.once }
60
+ end
61
+ }
62
+
63
+ x.report("Twice (w/o):") {
64
+ n.times { f.twice }
65
+ }
66
+
67
+ x.report("Twice (ctx):") {
68
+ ContextR.with_layers :one, :two do
69
+ n.times { f.twice }
70
+ end
71
+ }
72
+ end
73
+
74
+ __END__
75
+ n = 100_000 (bmbm to warm up the jvm)
76
+
77
+ ruby 1.8.6
78
+ user system total real
79
+ Ordinary: 0.040000 0.000000 0.040000 ( 0.041294)
80
+ Once (w/o): 1.030000 0.010000 1.040000 ( 1.043971)
81
+ Once (ctx): 1.540000 0.000000 1.540000 ( 1.598743)
82
+ Twice (w/o): 1.030000 0.010000 1.040000 ( 1.055684)
83
+ Twice (ctx): 2.780000 0.010000 2.790000 ( 2.839568)
84
+
85
+ jruby -O -J-server 1.0.2
86
+ user system total real
87
+ Ordinary: 0.108000 0.000000 0.108000 ( 0.108000)
88
+ Once (w/o): 2.336000 0.000000 2.336000 ( 2.335000)
89
+ Once (ctx): 3.390000 0.000000 3.390000 ( 3.390000)
90
+ Twice (w/o): 2.439000 0.000000 2.439000 ( 2.439000)
91
+ Twice (ctx): 5.191000 0.000000 5.191000 ( 5.190000)
@@ -0,0 +1,31 @@
1
+ Hash - memory leak
2
+ Ordinary: 0.040000 0.000000 0.040000 ( 0.042914)
3
+ Once (w/o): 0.610000 0.000000 0.610000 ( 0.609222)
4
+ Once (ctx): 1.640000 0.000000 1.640000 ( 1.647269)
5
+ Twice (w/o): 0.610000 0.000000 0.610000 ( 0.605728)
6
+ Twice (ctx): 1.850000 0.000000 1.850000 ( 1.861542)
7
+ Wrapped (w/o): 0.600000 0.010000 0.610000 ( 0.604295)
8
+ Wrapped (ctx): 2.980000 0.000000 2.980000 ( 2.988616)
9
+ All wrappers (ctx): 3.890000 0.010000 3.900000 ( 3.915734)
10
+
11
+ Without cache
12
+ Ordinary: 0.040000 0.000000 0.040000 ( 0.040913)
13
+ Once (w/o): 1.410000 0.010000 1.420000 ( 1.426041)
14
+ Once (ctx): 2.530000 0.010000 2.540000 ( 2.534582)
15
+ Twice (w/o): 1.400000 0.000000 1.400000 ( 1.403935)
16
+ Twice (ctx): 2.730000 0.000000 2.730000 ( 2.749183)
17
+ Wrapped (w/o): 1.400000 0.000000 1.400000 ( 1.397227)
18
+ Wrapped (ctx): 4.000000 0.010000 4.010000 ( 4.019783)
19
+ All wrappers (ctx): 4.770000 0.010000 4.780000 ( 4.790803)
20
+
21
+ SimpleWeakHash
22
+ Ordinary: 0.040000 0.000000 0.040000 ( 0.040132)
23
+ Once (w/o): 0.940000 0.000000 0.940000 ( 0.947428)
24
+ Once (ctx): 2.010000 0.010000 2.020000 ( 2.021883)
25
+ Twice (w/o): 0.950000 0.000000 0.950000 ( 0.952142)
26
+ Twice (ctx): 2.220000 0.000000 2.220000 ( 2.231346)
27
+ Wrapped (w/o): 0.950000 0.000000 0.950000 ( 0.948439)
28
+ Wrapped (ctx): 3.380000 0.010000 3.390000 ( 3.400573)
29
+ All wrappers (ctx): 4.360000 0.010000 4.370000 ( 4.390844)
30
+
31
+ WeakHash is either to slow or produces an infinte loop
data/contextr.gemspec ADDED
@@ -0,0 +1,119 @@
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{contextr}
8
+ s.version = "1.0.3"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Gregor Schmidt"]
12
+ s.date = %q{2009-12-03}
13
+ s.description = %q{The goal is to equip Ruby with an API to allow context-oriented programming.}
14
+ s.email = %q{ruby@schmidtwisser.de}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".gitignore",
21
+ "GPL.txt",
22
+ "History.txt",
23
+ "LICENSE.txt",
24
+ "MIT.txt",
25
+ "README.rdoc",
26
+ "RUBY.txt",
27
+ "Rakefile",
28
+ "TODO.taskpaper",
29
+ "VERSION.yml",
30
+ "autotest/discover.rb",
31
+ "autotest/rspec_test.rb",
32
+ "benchmark/contextr/bench.rb",
33
+ "benchmark/contextr/results_for_different_hashes.txt",
34
+ "contextr.gemspec",
35
+ "examples/README",
36
+ "examples/employer.rb",
37
+ "examples/node.rb",
38
+ "lib/contextr.rb",
39
+ "lib/contextr/class_methods.rb",
40
+ "lib/contextr/core_ext.rb",
41
+ "lib/contextr/core_ext/module.rb",
42
+ "lib/contextr/core_ext/object.rb",
43
+ "lib/contextr/event_machine.rb",
44
+ "lib/contextr/inner_class.rb",
45
+ "lib/contextr/layer.rb",
46
+ "lib/contextr/modules/mutex_code.rb",
47
+ "lib/contextr/modules/unique_id.rb",
48
+ "lib/contextr/public_api.rb",
49
+ "lib/ext/active_support_subset.rb",
50
+ "lib/ext/dynamic.rb",
51
+ "setup.rb",
52
+ "spec/contextr_spec.rb",
53
+ "spec/spec.opts",
54
+ "spec/spec_helper.rb",
55
+ "test/class_side.mkd",
56
+ "test/dynamic_scope.mkd",
57
+ "test/dynamics.mkd",
58
+ "test/hello_world.mkd",
59
+ "test/introduction.mkd",
60
+ "test/layer_state.mkd",
61
+ "test/lib/example_test.rb",
62
+ "test/lib/literate_maruku_test.rb",
63
+ "test/meta_api.mkd",
64
+ "test/method_missing.mkd",
65
+ "test/ordering.mkd",
66
+ "test/restrictions.mkd",
67
+ "test/test_contextr.rb",
68
+ "test/test_helper.rb",
69
+ "test/test_plain.rb",
70
+ "website/ContextR_euruko_2008.pdf",
71
+ "website/index.html",
72
+ "website/index.txt",
73
+ "website/javascripts/rounded_corners_lite.inc.js",
74
+ "website/stylesheets/screen.css",
75
+ "website/template.rhtml"
76
+ ]
77
+ s.homepage = %q{http://github.com/schmidt/contextr}
78
+ s.rdoc_options = ["--charset=UTF-8"]
79
+ s.require_paths = ["lib"]
80
+ s.rubygems_version = %q{1.3.5}
81
+ s.summary = %q{Context-oriented programming API for Ruby}
82
+ s.test_files = [
83
+ "spec/contextr_spec.rb",
84
+ "spec/spec_helper.rb",
85
+ "test/lib/example_test.rb",
86
+ "test/lib/literate_maruku_test.rb",
87
+ "test/test_contextr.rb",
88
+ "test/test_helper.rb",
89
+ "test/test_plain.rb",
90
+ "examples/employer.rb",
91
+ "examples/node.rb"
92
+ ]
93
+
94
+ if s.respond_to? :specification_version then
95
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
96
+ s.specification_version = 3
97
+
98
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
99
+ s.add_development_dependency(%q<rake>, [">= 0"])
100
+ s.add_development_dependency(%q<markaby>, [">= 0"])
101
+ s.add_development_dependency(%q<literate_maruku>, [">= 0"])
102
+ s.add_development_dependency(%q<rspec>, [">= 0"])
103
+ s.add_development_dependency(%q<jeweler>, [">= 1.4.0"])
104
+ else
105
+ s.add_dependency(%q<rake>, [">= 0"])
106
+ s.add_dependency(%q<markaby>, [">= 0"])
107
+ s.add_dependency(%q<literate_maruku>, [">= 0"])
108
+ s.add_dependency(%q<rspec>, [">= 0"])
109
+ s.add_dependency(%q<jeweler>, [">= 1.4.0"])
110
+ end
111
+ else
112
+ s.add_dependency(%q<rake>, [">= 0"])
113
+ s.add_dependency(%q<markaby>, [">= 0"])
114
+ s.add_dependency(%q<literate_maruku>, [">= 0"])
115
+ s.add_dependency(%q<rspec>, [">= 0"])
116
+ s.add_dependency(%q<jeweler>, [">= 1.4.0"])
117
+ end
118
+ end
119
+