innate 2009.04.12 → 2009.05
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +10 -0
- data/CHANGELOG +360 -0
- data/MANIFEST +8 -8
- data/README.md +1 -9
- data/Rakefile +7 -5
- data/example/app/whywiki_erb/start.rb +1 -1
- data/innate.gemspec +9 -5
- data/lib/innate.rb +6 -13
- data/lib/innate/action.rb +29 -33
- data/lib/innate/cache.rb +1 -1
- data/lib/innate/cache/drb.rb +5 -5
- data/lib/innate/cache/file_based.rb +3 -0
- data/lib/innate/cache/marshal.rb +4 -1
- data/lib/innate/cache/memory.rb +1 -2
- data/lib/innate/cache/yaml.rb +4 -1
- data/lib/innate/current.rb +11 -13
- data/lib/innate/dynamap.rb +5 -0
- data/lib/innate/helper.rb +11 -9
- data/lib/innate/helper/aspect.rb +9 -9
- data/lib/innate/helper/cgi.rb +3 -0
- data/lib/innate/helper/link.rb +2 -2
- data/lib/innate/helper/redirect.rb +1 -1
- data/lib/innate/helper/render.rb +70 -7
- data/lib/innate/helper/send_file.rb +9 -1
- data/lib/innate/log/color_formatter.rb +19 -13
- data/lib/innate/node.rb +38 -35
- data/lib/innate/options/dsl.rb +5 -2
- data/lib/innate/request.rb +1 -1
- data/lib/innate/response.rb +1 -7
- data/lib/innate/route.rb +4 -0
- data/lib/innate/session.rb +16 -14
- data/lib/innate/state.rb +10 -11
- data/lib/innate/state/accessor.rb +8 -8
- data/lib/innate/traited.rb +15 -10
- data/lib/innate/version.rb +1 -1
- data/lib/innate/view.rb +41 -4
- data/lib/innate/view/erb.rb +1 -2
- data/lib/innate/view/etanni.rb +9 -12
- data/spec/innate/action/layout.rb +0 -3
- data/spec/innate/helper/flash.rb +0 -3
- data/spec/innate/helper/link.rb +8 -0
- data/spec/innate/helper/redirect.rb +11 -0
- data/spec/innate/helper/render.rb +32 -0
- data/spec/innate/node/node.rb +1 -0
- data/spec/innate/options.rb +5 -1
- data/tasks/authors.rake +30 -0
- data/tasks/release.rake +48 -9
- data/tasks/ycov.rake +84 -0
- metadata +21 -13
- data/lib/innate/core_compatibility/basic_object.rb +0 -10
- data/lib/innate/core_compatibility/string.rb +0 -3
- data/lib/innate/state/fiber.rb +0 -74
- data/lib/innate/state/thread.rb +0 -47
- data/spec/innate/state/fiber.rb +0 -58
- data/spec/innate/state/thread.rb +0 -40
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: innate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2009.
|
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-
|
12
|
+
date: 2009-05-07 00:00:00 +09: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: []
|
@@ -22,6 +31,7 @@ extensions: []
|
|
22
31
|
extra_rdoc_files: []
|
23
32
|
|
24
33
|
files:
|
34
|
+
- AUTHORS
|
25
35
|
- CHANGELOG
|
26
36
|
- COPYING
|
27
37
|
- MANIFEST
|
@@ -54,8 +64,6 @@ files:
|
|
54
64
|
- lib/innate/cache/marshal.rb
|
55
65
|
- lib/innate/cache/memory.rb
|
56
66
|
- lib/innate/cache/yaml.rb
|
57
|
-
- lib/innate/core_compatibility/basic_object.rb
|
58
|
-
- lib/innate/core_compatibility/string.rb
|
59
67
|
- lib/innate/current.rb
|
60
68
|
- lib/innate/dynamap.rb
|
61
69
|
- lib/innate/helper.rb
|
@@ -83,8 +91,6 @@ files:
|
|
83
91
|
- lib/innate/spec.rb
|
84
92
|
- lib/innate/state.rb
|
85
93
|
- lib/innate/state/accessor.rb
|
86
|
-
- lib/innate/state/fiber.rb
|
87
|
-
- lib/innate/state/thread.rb
|
88
94
|
- lib/innate/traited.rb
|
89
95
|
- lib/innate/trinity.rb
|
90
96
|
- lib/innate/version.rb
|
@@ -137,9 +143,8 @@ files:
|
|
137
143
|
- spec/innate/request.rb
|
138
144
|
- spec/innate/route.rb
|
139
145
|
- spec/innate/session.rb
|
140
|
-
- spec/innate/state/fiber.rb
|
141
|
-
- spec/innate/state/thread.rb
|
142
146
|
- spec/innate/traited.rb
|
147
|
+
- tasks/authors.rake
|
143
148
|
- tasks/bacon.rake
|
144
149
|
- tasks/changelog.rake
|
145
150
|
- tasks/gem.rake
|
@@ -151,8 +156,11 @@ files:
|
|
151
156
|
- tasks/release.rake
|
152
157
|
- tasks/reversion.rake
|
153
158
|
- tasks/setup.rake
|
159
|
+
- tasks/ycov.rake
|
154
160
|
has_rdoc: true
|
155
161
|
homepage: http://github.com/manveru/innate
|
162
|
+
licenses: []
|
163
|
+
|
156
164
|
post_install_message:
|
157
165
|
rdoc_options: []
|
158
166
|
|
@@ -172,10 +180,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
172
180
|
version:
|
173
181
|
requirements: []
|
174
182
|
|
175
|
-
rubyforge_project:
|
176
|
-
rubygems_version: 1.3.
|
183
|
+
rubyforge_project: innate
|
184
|
+
rubygems_version: 1.3.2
|
177
185
|
signing_key:
|
178
|
-
specification_version:
|
186
|
+
specification_version: 3
|
179
187
|
summary: Powerful web-framework wrapper for Rack.
|
180
188
|
test_files: []
|
181
189
|
|
@@ -1,10 +0,0 @@
|
|
1
|
-
# We define BasicObject for compatibility with 1.9 if it isn't there yet.
|
2
|
-
class BasicObject
|
3
|
-
# Remove all but these methods
|
4
|
-
# NOTE: __id__ is not there in 1.9, but would give a warning in 1.8
|
5
|
-
KEEP = %w[== equal? ! != instance_eval instance_exec __send__ __id__]
|
6
|
-
|
7
|
-
(instance_methods - KEEP).each do |im|
|
8
|
-
undef_method(im)
|
9
|
-
end
|
10
|
-
end unless defined?(BasicObject)
|
data/lib/innate/state/fiber.rb
DELETED
@@ -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
|
data/lib/innate/state/thread.rb
DELETED
@@ -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
|
data/spec/innate/state/fiber.rb
DELETED
@@ -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
|
data/spec/innate/state/thread.rb
DELETED
@@ -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
|