manveru-innate 2009.04.18 → 2009.05

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. data/CHANGELOG +230 -0
  2. data/MANIFEST +2 -4
  3. data/Rakefile +6 -2
  4. data/example/app/whywiki_erb/start.rb +1 -1
  5. data/innate.gemspec +7 -3
  6. data/lib/innate.rb +5 -4
  7. data/lib/innate/action.rb +17 -25
  8. data/lib/innate/cache.rb +1 -1
  9. data/lib/innate/cache/drb.rb +5 -5
  10. data/lib/innate/cache/file_based.rb +3 -0
  11. data/lib/innate/cache/marshal.rb +4 -1
  12. data/lib/innate/cache/memory.rb +1 -2
  13. data/lib/innate/cache/yaml.rb +4 -1
  14. data/lib/innate/current.rb +11 -13
  15. data/lib/innate/dynamap.rb +5 -0
  16. data/lib/innate/helper.rb +9 -7
  17. data/lib/innate/helper/aspect.rb +9 -9
  18. data/lib/innate/helper/cgi.rb +3 -0
  19. data/lib/innate/helper/redirect.rb +1 -1
  20. data/lib/innate/helper/render.rb +68 -7
  21. data/lib/innate/log/color_formatter.rb +19 -13
  22. data/lib/innate/node.rb +38 -35
  23. data/lib/innate/options/dsl.rb +5 -2
  24. data/lib/innate/request.rb +1 -1
  25. data/lib/innate/response.rb +1 -0
  26. data/lib/innate/route.rb +4 -0
  27. data/lib/innate/session.rb +16 -14
  28. data/lib/innate/state.rb +10 -11
  29. data/lib/innate/state/accessor.rb +8 -8
  30. data/lib/innate/traited.rb +15 -10
  31. data/lib/innate/version.rb +1 -1
  32. data/lib/innate/view.rb +41 -4
  33. data/lib/innate/view/erb.rb +1 -2
  34. data/lib/innate/view/etanni.rb +9 -12
  35. data/spec/innate/action/layout.rb +0 -3
  36. data/spec/innate/helper/flash.rb +0 -3
  37. data/spec/innate/helper/redirect.rb +11 -0
  38. data/spec/innate/helper/render.rb +32 -0
  39. data/spec/innate/node/node.rb +1 -0
  40. data/spec/innate/options.rb +5 -1
  41. data/tasks/authors.rake +30 -0
  42. data/tasks/release.rake +3 -3
  43. data/tasks/ycov.rake +84 -0
  44. metadata +16 -9
  45. data/lib/innate/state/fiber.rb +0 -74
  46. data/lib/innate/state/thread.rb +0 -47
  47. data/spec/innate/state/fiber.rb +0 -58
  48. data/spec/innate/state/thread.rb +0 -40
@@ -49,6 +49,7 @@ class SpecNodeWithLayoutView < SpecNodeProvide
49
49
  layout 'another_layout'
50
50
 
51
51
  map_views 'node/another_layout'
52
+ map_layouts 'another_layout'
52
53
  end
53
54
 
54
55
  class SpecNodeWithLayoutMethod < SpecNodeProvide
@@ -46,7 +46,7 @@ describe Options do
46
46
 
47
47
  should 'get sub-sub option' do
48
48
  @options.get(:deep, :down, :me).
49
- should == {:value => :too, :doc => 'deep down', :trigger=> nil}
49
+ should == {:value => :too, :doc => 'deep down'}
50
50
  end
51
51
 
52
52
  should 'respond with nil on getting missing option' do
@@ -98,6 +98,10 @@ describe Options do
98
98
  lambda{ @options[:foo] = :bar }.should.raise(ArgumentError)
99
99
  end
100
100
 
101
+ should "raise when trying to assign to an option that doesn't exist" do
102
+ lambda{ @options.merge!(:foo => :bar) }.should.raise(IndexError)
103
+ end
104
+
101
105
  should 'pretty_print' do
102
106
  require 'pp'
103
107
  p = PP.new
@@ -0,0 +1,30 @@
1
+ # Once git has a fix for the glibc in handling .mailmap and another fix for
2
+ # allowing empty mail address to be mapped in .mailmap we won't have to handle
3
+ # them manually.
4
+
5
+ desc 'Update AUTHORS'
6
+ task :authors do
7
+ authors = Hash.new(0)
8
+
9
+ `git shortlog -nse`.scan(/(\d+)\s(.+)\s<(.*)>$/) do |count, name, email|
10
+ case name
11
+ when "ahoward"
12
+ name, email = "Ara T. Howard", "ara.t.howard@gmail.com"
13
+ when "Martin Hilbig blueonyx@dev-area.net"
14
+ name, email = "Martin Hilbig", "blueonyx@dev-area.net"
15
+ when "Michael Fellinger m.fellinger@gmail.com"
16
+ name, email = "Michael Fellinger", "m.fellinger@gmail.com"
17
+ end
18
+
19
+ authors[[name, email]] += count.to_i
20
+ end
21
+
22
+ File.open('AUTHORS', 'w+') do |io|
23
+ io.puts "Following persons have contributed to #{GEMSPEC.name}."
24
+ io.puts '(Sorted by number of submitted patches, then alphabetically)'
25
+ io.puts ''
26
+ authors.sort_by{|(n,e),c| [-c, n.downcase] }.each do |(name, email), count|
27
+ io.puts("%6d %s <%s>" % [count, name, email])
28
+ end
29
+ end
30
+ end
data/tasks/release.rake CHANGED
@@ -2,13 +2,13 @@ namespace :release do
2
2
  task :all => [:release_github, :release_rubyforge]
3
3
 
4
4
  desc 'Display instructions to release on github'
5
- task :github => [:reversion, :gemspec] do
5
+ task :github => [:reversion, :authors, :gemspec] do
6
6
  name, version = GEMSPEC.name, GEMSPEC.version
7
7
 
8
8
  puts <<INSTRUCTIONS
9
9
  First add the relevant files:
10
10
 
11
- git add MANIFEST CHANGELOG #{name}.gemspec lib/#{name}/version.rb
11
+ git add AUTHORS MANIFEST CHANGELOG #{name}.gemspec lib/#{name}/version.rb
12
12
 
13
13
  Then commit them, tag the commit, and push:
14
14
 
@@ -22,7 +22,7 @@ INSTRUCTIONS
22
22
 
23
23
  # TODO: Not tested
24
24
  desc 'Display instructions to release on rubyforge'
25
- task :rubyforge => [:reversion, :gemspec, :package] do
25
+ task :rubyforge => [:reversion, :authors, :gemspec, :package] do
26
26
  name, version = GEMSPEC.name, GEMSPEC.version
27
27
 
28
28
  puts <<INSTRUCTIONS
data/tasks/ycov.rake ADDED
@@ -0,0 +1,84 @@
1
+ begin
2
+ require 'yard'
3
+
4
+ task 'Show Documentation coverage'
5
+ task :ycov => ['.yardoc'] do
6
+ YARD::Registry.load_yardoc
7
+ code_objects = YARD::Registry.paths.map{|path| YARD::Registry.at(path) }
8
+ code_objects.delete_if{|obj| obj.type == :root }
9
+ without_doc, with_doc = code_objects.partition{|obj| obj.docstring.empty? }
10
+
11
+ documented = with_doc.size
12
+ undocumented = without_doc.size
13
+ total = documented + undocumented
14
+ percentage = (documented / 0.01) / total
15
+
16
+ puts "Documentation coverage is %d/%d (%3.1f%%)" % [documented, total, percentage]
17
+ end
18
+
19
+ task 'ycov-full' => ['.yardoc'] do
20
+ require 'builder'
21
+
22
+ YARD::Registry.load_yardoc
23
+ code_objects = YARD::Registry.paths.map{|path| YARD::Registry.at(path) }
24
+ code_objects.delete_if{|obj| obj.type == :root }
25
+ without_doc, with_doc = code_objects.partition{|obj| obj.docstring.empty? }
26
+
27
+ list_objects = lambda{|body, list|
28
+ body.table(:width => '100%') do |table|
29
+ list.group_by{|obj| obj.type }.
30
+ sort_by{|k,v| k.to_s }.each do |type, objects|
31
+
32
+ table.tr do |tr|
33
+ tr.th(type.to_s, :colspan => 2)
34
+ end
35
+
36
+ objects.sort_by{|obj| obj.path }.each do |obj|
37
+ table.tr do |tr|
38
+ tr.td obj.path
39
+ tr.td "#{obj.file} +#{obj.line}"
40
+ end
41
+ end
42
+ end
43
+ end
44
+ }
45
+
46
+ File.open('ycov.html', 'w+') do |ycov|
47
+ builder = Builder::XmlMarkup.new(:target => ycov, :indent=>2)
48
+ builder.html do |html|
49
+ html.head do |head|
50
+ head.title 'YARD Coverage report'
51
+ end
52
+
53
+ html.body do |body|
54
+ body.h1 'YARD Coverage report'
55
+
56
+ body.h2 "#{without_doc.size} Undocumented objects"
57
+ list_objects[body, without_doc]
58
+
59
+ body.h2 "#{with_doc.size} Documented objects"
60
+ list_objects[body, with_doc]
61
+ end
62
+ end
63
+ end
64
+ end
65
+
66
+ file '.yardoc' => FileList['lib/**/*.rb'] do
67
+ files = ['lib/**/*.rb']
68
+ options = ['--no-output', '--private']
69
+ YARD::CLI::Yardoc.run(*(options + files))
70
+ end
71
+
72
+ desc 'Generate YARD documentation'
73
+ task :yardoc => ['.yardoc'] do
74
+ files = ['lib/**/*.rb']
75
+ options = [
76
+ '--output-dir', 'ydoc',
77
+ '--readme', PROJECT_README,
78
+ '--db', '.yardoc',
79
+ '--private']
80
+ YARD::CLI::Yardoc.run(*(options + files))
81
+ end
82
+ rescue LoadError
83
+ # you'll survive
84
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: manveru-innate
3
3
  version: !ruby/object:Gem::Version
4
- version: 2009.04.18
4
+ version: "2009.05"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael 'manveru' Fellinger
@@ -9,10 +9,19 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-18 00:00:00 -07:00
12
+ date: 2009-05-07 00:00:00 -07:00
13
13
  default_executable:
14
- dependencies: []
15
-
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rack
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: 1.0.0
24
+ version:
16
25
  description: Simple, straight-forward base for web-frameworks.
17
26
  email: m.fellinger@gmail.com
18
27
  executables: []
@@ -81,8 +90,6 @@ files:
81
90
  - lib/innate/spec.rb
82
91
  - lib/innate/state.rb
83
92
  - lib/innate/state/accessor.rb
84
- - lib/innate/state/fiber.rb
85
- - lib/innate/state/thread.rb
86
93
  - lib/innate/traited.rb
87
94
  - lib/innate/trinity.rb
88
95
  - lib/innate/version.rb
@@ -135,9 +142,8 @@ files:
135
142
  - spec/innate/request.rb
136
143
  - spec/innate/route.rb
137
144
  - spec/innate/session.rb
138
- - spec/innate/state/fiber.rb
139
- - spec/innate/state/thread.rb
140
145
  - spec/innate/traited.rb
146
+ - tasks/authors.rake
141
147
  - tasks/bacon.rake
142
148
  - tasks/changelog.rake
143
149
  - tasks/gem.rake
@@ -149,6 +155,7 @@ files:
149
155
  - tasks/release.rake
150
156
  - tasks/reversion.rake
151
157
  - tasks/setup.rake
158
+ - tasks/ycov.rake
152
159
  has_rdoc: true
153
160
  homepage: http://github.com/manveru/innate
154
161
  post_install_message:
@@ -170,7 +177,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
170
177
  version:
171
178
  requirements: []
172
179
 
173
- rubyforge_project:
180
+ rubyforge_project: innate
174
181
  rubygems_version: 1.2.0
175
182
  signing_key:
176
183
  specification_version: 3
@@ -1,74 +0,0 @@
1
- require 'fiber'
2
-
3
- module Innate
4
- # Innate subclasses Fiber to enable lightweight request/respose-cycle local
5
- # variables.
6
- #
7
- # We do that by adding a state Hash to the Fiber instance on initalization
8
- # which can be accessed by #[], #[]= and #key?. Other Hash methods are not
9
- # necessary right now but may be added.
10
- #
11
- # We subclass to keep your Ruby clean and polished.
12
- class Fiber < ::Fiber
13
- attr_accessor :state
14
-
15
- def initialize(*args)
16
- super
17
- @state = {}
18
- end
19
-
20
- def [](key)
21
- state[key]
22
- end
23
-
24
- def []=(key, value)
25
- state[key] = value
26
- end
27
-
28
- def key?(key)
29
- state.key?(key)
30
- end
31
-
32
- def keys
33
- state.keys
34
- end
35
- end
36
-
37
- module State
38
- # Our accessor to the currently active Fiber, an instance of
39
- # Innate::State::Fiber will be assigned to Innate::STATE if fibers are
40
- # available.
41
- class Fiber
42
- def [](key)
43
- ::Fiber.current[key]
44
- end
45
-
46
- def []=(key, value)
47
- ::Fiber.current[key] = value
48
- end
49
-
50
- # We don't use Fiber in a concurrent manner and they don't run
51
- # concurrently by themselves, so we directly #resume the Fiber to get the
52
- # return value of +block+.
53
-
54
- def wrap(&block)
55
- Innate::Fiber.new(&block).resume
56
- end
57
-
58
- # In an environment where only Fiber is used there is no concurrency, so
59
- # we don't have to lock with a Mutex.
60
-
61
- def sync
62
- yield
63
- end
64
-
65
- def defer
66
- a = Innate::Fiber.current
67
- ::Thread.new do
68
- b = Innate::Fiber.new{ a.keys.each{|k| b[k] = a[k] }; yield }
69
- b.resume
70
- end
71
- end
72
- end
73
- end
74
- end
@@ -1,47 +0,0 @@
1
- require 'thread'
2
-
3
- module Innate
4
- module State
5
- # In case fibers are not available we fall back to this wrapper.
6
- #
7
- # It will raise errors happening inside the wrapping Thread even if
8
- # Thread::abort_on_exception is false.
9
- #
10
- # For things that require a mutex in a threaded environment, use
11
- # STATE#sync, if Fiber is available no mutex will be used.
12
-
13
- class Thread
14
- SEMAPHORE = Mutex.new
15
-
16
- def [](key)
17
- ::Thread.current[key]
18
- end
19
-
20
- def []=(key, value)
21
- ::Thread.current[key] = value
22
- end
23
-
24
- # Execute given block in a new Thread and rescue any exceptions before
25
- # they reach Thread::new, so in case Thread::raise_on_exception is false
26
- # we can still reraise the error outside of the Thread.
27
- #
28
- # This is not meant to be concurrent, we only use Thread as a wrapping
29
- # context so we can store objects in Thread::current and access them from
30
- # anywhere within this thread.
31
- def wrap
32
- value = ::Thread.new{ begin; yield; rescue Exception => ex; ex; end }.value
33
- raise(value) if Exception === value
34
- return value
35
- end
36
-
37
- def sync(&block)
38
- SEMAPHORE.synchronize(&block)
39
- end
40
-
41
- def defer
42
- a = ::Thread.current
43
- ::Thread.new{ b = ::Thread.current; a.keys.each{|k| b[k] = a[k] }; yield }
44
- end
45
- end
46
- end
47
- end
@@ -1,58 +0,0 @@
1
- require 'spec/helper'
2
-
3
- describe 'Innate::State::Fiber' do
4
- begin
5
- require 'fiber'
6
- rescue LoadError
7
- it('needs fiber'){ should.flunk('needed fiber') }
8
- exit
9
- end
10
-
11
- F = Innate::State::Fiber
12
-
13
- it 'sets value in current thread with #[]=' do
14
- Innate::Fiber.new{
15
- t = F.new
16
- t[:a] = :b
17
- Fiber.current[:a].should == :b
18
- }.resume
19
- end
20
-
21
- it 'gets value in current thread with #[]' do
22
- Innate::Fiber.new{
23
- t = F.new
24
- Fiber.current[:b] = :c
25
- t[:b].should == :c
26
- }.resume
27
- end
28
-
29
- it 'executes block in #wrap' do
30
- Innate::Fiber.new{
31
- t = F.new
32
- t.wrap{ :foo }.should == :foo
33
- }.resume
34
- end
35
-
36
- it 'reraises exceptions occured in #wrap thread' do
37
- Innate::Fiber.new{
38
- t = F.new
39
- Thread.abort_on_exception = false
40
- lambda{ t.wrap{ raise 'foo' } }.should.raise
41
- }.resume
42
- end
43
-
44
- it 'defers execution of passed block in #defer' do
45
- Innate::Fiber.new{
46
- t = F.new
47
- t.defer{ :foo }.value.should == :foo
48
- }.resume
49
- end
50
-
51
- it 'copies thread variables to thread spawned in #defer' do
52
- Innate::Fiber.new{
53
- t = F.new
54
- t[:a] = :b
55
- t.defer{ Fiber.current[:a] }.value.should == :b
56
- }.resume
57
- end
58
- end
@@ -1,40 +0,0 @@
1
- require 'spec/helper'
2
- require 'innate/state/thread'
3
-
4
- describe Innate::State::Thread do
5
- T = Innate::State::Thread
6
-
7
- it 'sets value in current thread with #[]=' do
8
- t = T.new
9
- t[:a] = :b
10
- Thread.current[:a].should == :b
11
- end
12
-
13
- it 'gets value in current thread with #[]' do
14
- t = T.new
15
- Thread.current[:b] = :c
16
- t[:b].should == :c
17
- end
18
-
19
- it 'executes block in #wrap' do
20
- t = T.new
21
- t.wrap{ :foo }.should == :foo
22
- end
23
-
24
- it 'reraises exceptions occured in #wrap thread' do
25
- t = T.new
26
- Thread.abort_on_exception = false
27
- lambda{ t.wrap{ raise 'foo' } }.should.raise
28
- end
29
-
30
- it 'defers execution of passed block in #defer' do
31
- t = T.new
32
- t.defer{ :foo }.value.should == :foo
33
- end
34
-
35
- it 'copies thread variables to thread spawned in #defer' do
36
- t = T.new
37
- t[:a] = :b
38
- t.defer{ Thread.current[:a] }.value.should == :b
39
- end
40
- end