manveru-ramaze 2009.04 → 2009.04.01
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +0 -405
- data/MANIFEST +16 -16
- data/Rakefile +4 -24
- data/bin/ramaze +52 -275
- data/doc/tutorial/todolist.html +5 -83
- data/doc/tutorial/todolist.txt +33 -85
- data/examples/app/auth/layout/{auth.xhtml → auth.nag} +0 -0
- data/examples/app/auth/view/{index.xhtml → index.nag} +0 -0
- data/examples/app/auth/view/{login.xhtml → login.nag} +0 -0
- data/examples/app/auth/view/{secret.xhtml → secret.nag} +0 -0
- data/examples/app/blog/app.rb +1 -1
- data/examples/app/blog/controller/comment.rb +1 -1
- data/examples/app/blog/controller/entry.rb +3 -12
- data/examples/app/blog/model/init.rb +0 -5
- data/examples/app/blog/model/tag.rb +2 -2
- data/examples/app/blog/start.rb +1 -1
- data/examples/app/blog/view/entry/index.nag +3 -3
- data/examples/app/blog/view/feed.atom.nag +1 -1
- data/examples/app/blog/view/feed.rss.nag +1 -1
- data/examples/app/blog/view/index.nag +1 -1
- data/examples/app/blog/view/tag/index.nag +1 -1
- data/examples/app/todolist/model/init.rb +0 -3
- data/examples/app/wikore/spec/wikore.rb +6 -4
- data/examples/app/wikore/src/controller.rb +11 -9
- data/examples/app/wikore/src/model.rb +10 -7
- data/examples/app/wikore/start.rb +1 -1
- data/examples/app/wikore/{view → template}/index.xhtml +0 -0
- data/examples/helpers/provide.rb +23 -0
- data/examples/misc/rapp.rb +17 -28
- data/examples/templates/template_redcloth.rb +2 -2
- data/examples/templates/template_xslt.rb +48 -0
- data/examples/templates/view/external.xsl +57 -0
- data/lib/proto/config.ru +5 -4
- data/lib/proto/controller/init.rb +2 -2
- data/lib/proto/layout/{default.xhtml → default.nag} +0 -0
- data/lib/proto/spec/main.rb +8 -7
- data/lib/proto/start.rb +10 -6
- data/lib/proto/view/{index.xhtml → index.nag} +0 -0
- data/lib/proto/view/page.nag +27 -0
- data/lib/ramaze/app.rb +5 -5
- data/lib/ramaze/cache.rb +2 -3
- data/lib/ramaze/contrib/email.rb +0 -2
- data/lib/ramaze/contrib/sequel/create_join.rb +0 -1
- data/lib/ramaze/contrib/sequel/fill.rb +12 -0
- data/lib/ramaze/contrib/sequel/form_field.rb +4 -4
- data/lib/ramaze/contrib/sequel/image.rb +11 -9
- data/lib/ramaze/contrib/sequel/relation.rb +3 -17
- data/lib/ramaze/controller/default.rb +0 -5
- data/lib/ramaze/helper/cache.rb +8 -22
- data/lib/ramaze/helper/formatting.rb +0 -2
- data/lib/ramaze/helper/httpdigest.rb +1 -1
- data/lib/ramaze/helper/link.rb +5 -2
- data/lib/ramaze/helper/localize.rb +3 -13
- data/lib/ramaze/helper/paginate.rb +0 -1
- data/lib/ramaze/helper/partial.rb +10 -85
- data/lib/ramaze/helper.rb +16 -6
- data/lib/ramaze/request.rb +1 -22
- data/lib/ramaze/snippets/ramaze/deprecated.rb +1 -0
- data/lib/ramaze/snippets/string/each.rb +19 -0
- data/lib/ramaze/spec.rb +2 -9
- data/lib/ramaze/version.rb +1 -1
- data/lib/ramaze/view/haml.rb +0 -1
- data/lib/ramaze/view/liquid.rb +11 -45
- data/lib/ramaze/view/nagoro/render_partial.rb +9 -9
- data/lib/ramaze/view.rb +0 -4
- data/lib/ramaze.rb +0 -2
- data/ramaze.gemspec +12 -12
- data/spec/contrib/sequel/fill.rb +47 -0
- data/spec/examples/helpers/httpdigest.rb +67 -42
- data/spec/examples/templates/template_markaby.rb +1 -1
- data/spec/examples/templates/template_xslt.rb +10 -0
- data/spec/ramaze/dispatcher/file.rb +20 -22
- data/spec/ramaze/error.rb +1 -1
- data/spec/ramaze/helper/auth.rb +40 -29
- data/spec/ramaze/helper/cache.rb +3 -43
- data/spec/ramaze/helper/flash.rb +14 -10
- data/spec/ramaze/helper/httpdigest.rb +65 -47
- data/spec/ramaze/helper/localize.rb +9 -9
- data/spec/ramaze/helper/partial.rb +40 -0
- data/spec/ramaze/helper/sequel_form.rb +1 -1
- data/spec/ramaze/helper/simple_captcha.rb +13 -9
- data/spec/ramaze/helper/stack.rb +39 -31
- data/spec/ramaze/helper/user.rb +13 -15
- data/spec/ramaze/request.rb +0 -12
- data/tasks/bacon.rake +21 -38
- data/tasks/release.rake +22 -4
- metadata +24 -22
- data/lib/proto/app.rb +0 -15
- data/lib/ramaze/cache/localmemcache.rb +0 -56
- data/lib/ramaze/contrib/app_graph.rb +0 -64
- data/lib/ramaze/tool/create.rb +0 -48
- data/lib/ramaze/tool/project_creator.rb +0 -111
- data/spec/ramaze/cache/localmemcache.rb +0 -49
- data/tasks/setup.rake +0 -24
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: manveru-ramaze
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2009.04.01
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael 'manveru' Fellinger
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-04-
|
12
|
+
date: 2009-04-01 00:00:00 -07:00
|
13
13
|
default_executable: ramaze
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -18,17 +18,17 @@ dependencies:
|
|
18
18
|
version_requirement:
|
19
19
|
version_requirements: !ruby/object:Gem::Requirement
|
20
20
|
requirements:
|
21
|
-
- - "
|
21
|
+
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version:
|
23
|
+
version: 0.9.9
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
|
-
name: innate
|
26
|
+
name: manveru-innate
|
27
27
|
type: :runtime
|
28
28
|
version_requirement:
|
29
29
|
version_requirements: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: "2009.04"
|
34
34
|
version:
|
@@ -79,11 +79,11 @@ files:
|
|
79
79
|
- doc/tutorial/todolist.html
|
80
80
|
- doc/tutorial/todolist.mkd
|
81
81
|
- doc/tutorial/todolist.txt
|
82
|
-
- examples/app/auth/layout/auth.
|
82
|
+
- examples/app/auth/layout/auth.nag
|
83
83
|
- examples/app/auth/start.rb
|
84
|
-
- examples/app/auth/view/index.
|
85
|
-
- examples/app/auth/view/login.
|
86
|
-
- examples/app/auth/view/secret.
|
84
|
+
- examples/app/auth/view/index.nag
|
85
|
+
- examples/app/auth/view/login.nag
|
86
|
+
- examples/app/auth/view/secret.nag
|
87
87
|
- examples/app/blog/README
|
88
88
|
- examples/app/blog/app.rb
|
89
89
|
- examples/app/blog/config.ru
|
@@ -156,7 +156,7 @@ files:
|
|
156
156
|
- examples/app/wikore/src/controller.rb
|
157
157
|
- examples/app/wikore/src/model.rb
|
158
158
|
- examples/app/wikore/start.rb
|
159
|
-
- examples/app/wikore/
|
159
|
+
- examples/app/wikore/template/index.xhtml
|
160
160
|
- examples/app/wiktacular/README
|
161
161
|
- examples/app/wiktacular/mkd/link/2007-07-20_19-45-51.mkd
|
162
162
|
- examples/app/wiktacular/mkd/link/current.mkd
|
@@ -196,6 +196,7 @@ files:
|
|
196
196
|
- examples/helpers/identity.rb
|
197
197
|
- examples/helpers/nitro_form.rb
|
198
198
|
- examples/helpers/paginate.rb
|
199
|
+
- examples/helpers/provide.rb
|
199
200
|
- examples/helpers/rest.rb
|
200
201
|
- examples/helpers/simple_captcha.rb
|
201
202
|
- examples/misc/css.rb
|
@@ -215,6 +216,7 @@ files:
|
|
215
216
|
- examples/templates/template_redcloth.rb
|
216
217
|
- examples/templates/template_remarkably.rb
|
217
218
|
- examples/templates/template_tenjin.rb
|
219
|
+
- examples/templates/template_xslt.rb
|
218
220
|
- examples/templates/view/external.haml
|
219
221
|
- examples/templates/view/external.liquid
|
220
222
|
- examples/templates/view/external.mab
|
@@ -223,12 +225,12 @@ files:
|
|
223
225
|
- examples/templates/view/external.rem
|
224
226
|
- examples/templates/view/external.rhtml
|
225
227
|
- examples/templates/view/external.tenjin
|
228
|
+
- examples/templates/view/external.xsl
|
226
229
|
- examples/templates/view/external.zmr
|
227
|
-
- lib/proto/app.rb
|
228
230
|
- lib/proto/config.ru
|
229
231
|
- lib/proto/controller/init.rb
|
230
232
|
- lib/proto/controller/main.rb
|
231
|
-
- lib/proto/layout/default.
|
233
|
+
- lib/proto/layout/default.nag
|
232
234
|
- lib/proto/model/init.rb
|
233
235
|
- lib/proto/public/.htaccess
|
234
236
|
- lib/proto/public/css/screen.css
|
@@ -238,14 +240,13 @@ files:
|
|
238
240
|
- lib/proto/public/ramaze.png
|
239
241
|
- lib/proto/spec/main.rb
|
240
242
|
- lib/proto/start.rb
|
241
|
-
- lib/proto/view/index.
|
243
|
+
- lib/proto/view/index.nag
|
244
|
+
- lib/proto/view/page.nag
|
242
245
|
- lib/ramaze.rb
|
243
246
|
- lib/ramaze/app.rb
|
244
247
|
- lib/ramaze/cache.rb
|
245
|
-
- lib/ramaze/cache/localmemcache.rb
|
246
248
|
- lib/ramaze/cache/memcache.rb
|
247
249
|
- lib/ramaze/cache/sequel.rb
|
248
|
-
- lib/ramaze/contrib/app_graph.rb
|
249
250
|
- lib/ramaze/contrib/email.rb
|
250
251
|
- lib/ramaze/contrib/facebook.rb
|
251
252
|
- lib/ramaze/contrib/facebook/facebook.rb
|
@@ -258,6 +259,7 @@ files:
|
|
258
259
|
- lib/ramaze/contrib/profiling.rb
|
259
260
|
- lib/ramaze/contrib/rest.rb
|
260
261
|
- lib/ramaze/contrib/sequel/create_join.rb
|
262
|
+
- lib/ramaze/contrib/sequel/fill.rb
|
261
263
|
- lib/ramaze/contrib/sequel/form_field.rb
|
262
264
|
- lib/ramaze/contrib/sequel/image.rb
|
263
265
|
- lib/ramaze/contrib/sequel/relation.rb
|
@@ -341,6 +343,7 @@ files:
|
|
341
343
|
- lib/ramaze/snippets/ramaze/struct.rb
|
342
344
|
- lib/ramaze/snippets/string/camel_case.rb
|
343
345
|
- lib/ramaze/snippets/string/color.rb
|
346
|
+
- lib/ramaze/snippets/string/each.rb
|
344
347
|
- lib/ramaze/snippets/string/end_with.rb
|
345
348
|
- lib/ramaze/snippets/string/esc.rb
|
346
349
|
- lib/ramaze/snippets/string/ord.rb
|
@@ -353,8 +356,6 @@ files:
|
|
353
356
|
- lib/ramaze/spec/helper/pretty_output.rb
|
354
357
|
- lib/ramaze/spec/helper/snippets.rb
|
355
358
|
- lib/ramaze/spec/helper/template_examples.rb
|
356
|
-
- lib/ramaze/tool/create.rb
|
357
|
-
- lib/ramaze/tool/project_creator.rb
|
358
359
|
- lib/ramaze/version.rb
|
359
360
|
- lib/ramaze/view.rb
|
360
361
|
- lib/ramaze/view/erubis.rb
|
@@ -373,6 +374,7 @@ files:
|
|
373
374
|
- lib/vendor/route_exceptions.rb
|
374
375
|
- ramaze.gemspec
|
375
376
|
- spec/contrib/rest.rb
|
377
|
+
- spec/contrib/sequel/fill.rb
|
376
378
|
- spec/examples/caching.rb
|
377
379
|
- spec/examples/css.rb
|
378
380
|
- spec/examples/element.rb
|
@@ -389,6 +391,7 @@ files:
|
|
389
391
|
- spec/examples/templates/template_redcloth.rb
|
390
392
|
- spec/examples/templates/template_remarkably.rb
|
391
393
|
- spec/examples/templates/template_tenjin.rb
|
394
|
+
- spec/examples/templates/template_xslt.rb
|
392
395
|
- spec/helper.rb
|
393
396
|
- spec/ramaze/action/render.rb
|
394
397
|
- spec/ramaze/action/view/bar.xhtml
|
@@ -399,7 +402,6 @@ files:
|
|
399
402
|
- spec/ramaze/action/view/sub/sub_wrapper.erb
|
400
403
|
- spec/ramaze/action/view/sub/sub_wrapper.xhtml
|
401
404
|
- spec/ramaze/app.rb
|
402
|
-
- spec/ramaze/cache/localmemcache.rb
|
403
405
|
- spec/ramaze/cache/memcache.rb
|
404
406
|
- spec/ramaze/cache/sequel.rb
|
405
407
|
- spec/ramaze/controller/actionless_templates.rb
|
@@ -438,6 +440,7 @@ files:
|
|
438
440
|
- spec/ramaze/helper/maruku.rb
|
439
441
|
- spec/ramaze/helper/pager.rb
|
440
442
|
- spec/ramaze/helper/paginate.rb
|
443
|
+
- spec/ramaze/helper/partial.rb
|
441
444
|
- spec/ramaze/helper/request_accessor.rb
|
442
445
|
- spec/ramaze/helper/sequel_form.rb
|
443
446
|
- spec/ramaze/helper/simple_captcha.rb
|
@@ -522,7 +525,6 @@ files:
|
|
522
525
|
- tasks/rcov.rake
|
523
526
|
- tasks/release.rake
|
524
527
|
- tasks/reversion.rake
|
525
|
-
- tasks/setup.rake
|
526
528
|
- tasks/todo.rake
|
527
529
|
- tasks/traits.rake
|
528
530
|
- tasks/yard.rake
|
@@ -533,7 +535,7 @@ post_install_message: |-
|
|
533
535
|
|
534
536
|
Thank you for installing Ramaze!
|
535
537
|
You can now do create a new project:
|
536
|
-
# ramaze create yourproject
|
538
|
+
# ramaze --create yourproject
|
537
539
|
|
538
540
|
============================================================
|
539
541
|
rdoc_options: []
|
@@ -557,7 +559,7 @@ requirements: []
|
|
557
559
|
rubyforge_project: ramaze
|
558
560
|
rubygems_version: 1.2.0
|
559
561
|
signing_key:
|
560
|
-
specification_version:
|
562
|
+
specification_version: 2
|
561
563
|
summary: Ramaze is a simple and modular web framework
|
562
564
|
test_files: []
|
563
565
|
|
data/lib/proto/app.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
# This file contains your application, it requires dependencies and necessary
|
2
|
-
# parts of the application.
|
3
|
-
#
|
4
|
-
# It will be required from either `config.ru` or `start.rb`
|
5
|
-
|
6
|
-
require 'rubygems'
|
7
|
-
require 'ramaze'
|
8
|
-
|
9
|
-
# Add the directory this file resides in to the load path, so you can run the
|
10
|
-
# app from any other working directory
|
11
|
-
$LOAD_PATH.unshift(__DIR__)
|
12
|
-
|
13
|
-
# Initialize controllers and models
|
14
|
-
require 'model/init'
|
15
|
-
require 'controller/init'
|
@@ -1,56 +0,0 @@
|
|
1
|
-
# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
|
2
|
-
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
-
|
4
|
-
require 'localmemcache'
|
5
|
-
|
6
|
-
module Ramaze
|
7
|
-
class Cache
|
8
|
-
|
9
|
-
# Cache based on the localmemcache library which utilizes mmap to share
|
10
|
-
# strings in memory between ruby instances.
|
11
|
-
class LocalMemCache
|
12
|
-
include Cache::API
|
13
|
-
|
14
|
-
OPTIONS = {
|
15
|
-
:size_mb => 1024,
|
16
|
-
:serialize => true,
|
17
|
-
:serializer => ::Marshal, # something that responds to ::load and ::dump
|
18
|
-
}
|
19
|
-
|
20
|
-
# Connect to localmemcache
|
21
|
-
def cache_setup(host, user, app, name)
|
22
|
-
@namespace = [host, user, app, name].compact.join('-')
|
23
|
-
|
24
|
-
options = {:namespace => @namespace}.merge(OPTIONS)
|
25
|
-
|
26
|
-
@serialize = options.delete(:serialize)
|
27
|
-
@serializer = options.delete(:serializer)
|
28
|
-
|
29
|
-
@store = ::LocalMemCache.new(options)
|
30
|
-
end
|
31
|
-
|
32
|
-
# Wipe out _all_ data in localmemcached, use with care.
|
33
|
-
def cache_clear
|
34
|
-
::LocalMemCache.clear_namespace(@namespace)
|
35
|
-
end
|
36
|
-
|
37
|
-
def cache_delete(*args)
|
38
|
-
super{|key| @store.delete(key.to_s) }
|
39
|
-
end
|
40
|
-
|
41
|
-
# NOTE:
|
42
|
-
# * We have no way of knowing whether the value really is nil, we
|
43
|
-
# assume you wouldn't cache nil and return the default instead.
|
44
|
-
def cache_fetch(*args)
|
45
|
-
super{|key|
|
46
|
-
value = @store[key.to_s]
|
47
|
-
@serializer.load(value) if value
|
48
|
-
}
|
49
|
-
end
|
50
|
-
|
51
|
-
def cache_store(*args)
|
52
|
-
super{|key, value| @store[key.to_s] = @serializer.dump(value) }
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
@@ -1,64 +0,0 @@
|
|
1
|
-
require 'set'
|
2
|
-
|
3
|
-
# require 'ramaze/contrib/app_graph'
|
4
|
-
#
|
5
|
-
# graph = AppGraph.new
|
6
|
-
# graph.generate
|
7
|
-
# graph.show
|
8
|
-
|
9
|
-
class AppGraph
|
10
|
-
def initialize
|
11
|
-
@out = Set.new
|
12
|
-
end
|
13
|
-
|
14
|
-
def generate
|
15
|
-
Ramaze::AppMap.to_hash.each do |location, app|
|
16
|
-
connect(location => app.name)
|
17
|
-
|
18
|
-
app.url_map.to_hash.each do |c_location, c_node|
|
19
|
-
connect(app.name => c_node)
|
20
|
-
connect(c_node.mapping => c_node)
|
21
|
-
|
22
|
-
c_node.update_template_mappings
|
23
|
-
c_node.view_templates.each do |wish, mapping|
|
24
|
-
mapping.each do |action_name, template|
|
25
|
-
action_path = File.join(c_node.mapping, action_name)
|
26
|
-
connect(c_node => action_path, action_path => template)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
c_node.update_method_arities
|
31
|
-
c_node.method_arities.each do |method, arity|
|
32
|
-
action_path = File.join(c_node.mapping, method.to_s)
|
33
|
-
connect(action_path => "#{c_node}##{method}[#{arity}]", c_node => action_path)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def connect(hash)
|
40
|
-
hash.each do |from, to|
|
41
|
-
@out << (" %p -> %p;" % [from.to_s, to.to_s])
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def write_dot
|
46
|
-
File.open('graph.dot', 'w+') do |dot|
|
47
|
-
dot.puts 'digraph appmap {'
|
48
|
-
dot.puts(*@out)
|
49
|
-
dot.puts '}'
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def show
|
54
|
-
write_dot
|
55
|
-
options = {
|
56
|
-
'rankdir' => 'LR',
|
57
|
-
'splines' => 'true',
|
58
|
-
'overlap' => 'false',
|
59
|
-
}
|
60
|
-
args = options.map{|k,v| "-G#{k}=#{v}" }
|
61
|
-
system("dot -O -Tpng #{args.join(' ')} graph.dot")
|
62
|
-
system('feh graph.dot.png')
|
63
|
-
end
|
64
|
-
end
|
data/lib/ramaze/tool/create.rb
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
# Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
|
2
|
-
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
-
|
4
|
-
require 'ramaze/tool/project_creator'
|
5
|
-
|
6
|
-
module Ramaze
|
7
|
-
module Tool
|
8
|
-
|
9
|
-
# Create is a simple class used to create new projects based on the proto
|
10
|
-
# directory.
|
11
|
-
#
|
12
|
-
# It is primarly used for this command:
|
13
|
-
#
|
14
|
-
# ramaze --create project
|
15
|
-
#
|
16
|
-
# where project is the directory you want the content put into.
|
17
|
-
|
18
|
-
class Create
|
19
|
-
|
20
|
-
# Default options passed to Create::create
|
21
|
-
# :proto is the directory to duplicate
|
22
|
-
# :amend no files may be overwritten but missing files will be added
|
23
|
-
# :force will overwrite existing files
|
24
|
-
# :layout copy one subdirectory in +proto+
|
25
|
-
|
26
|
-
DEFAULT = {
|
27
|
-
:proto => File.join(ROOT, 'proto'),
|
28
|
-
:amend => false,
|
29
|
-
:force => false,
|
30
|
-
:layout => '/',
|
31
|
-
}
|
32
|
-
|
33
|
-
# Using ProjectCreator to copy all files and directories from lib/proto
|
34
|
-
# to another location.
|
35
|
-
# +options+ are described in the DEFAULT constant and should be:
|
36
|
-
# :force => (true|false|nil)
|
37
|
-
# :amend => (true|false|nil)
|
38
|
-
# :layout => (String|nil)
|
39
|
-
# :proto => String
|
40
|
-
|
41
|
-
def self.create(project, options = {})
|
42
|
-
options = DEFAULT.merge(options)
|
43
|
-
creator = ProjectCreator.new(project, options)
|
44
|
-
creator.create
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
@@ -1,111 +0,0 @@
|
|
1
|
-
# Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
|
2
|
-
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
-
|
4
|
-
require 'fileutils'
|
5
|
-
require 'find'
|
6
|
-
|
7
|
-
class ProjectCreator
|
8
|
-
PROTO = []
|
9
|
-
PROTO << '~/.proto/' if ENV["HOME"] # Guard against Windows
|
10
|
-
attr_accessor :name, :options
|
11
|
-
|
12
|
-
def initialize(name, options = {})
|
13
|
-
@name, @options = name, options
|
14
|
-
end
|
15
|
-
|
16
|
-
def target
|
17
|
-
File.expand_path(name)
|
18
|
-
end
|
19
|
-
|
20
|
-
def proto
|
21
|
-
PROTO.map!{|pr| File.expand_path(pr) }
|
22
|
-
proto = options[:proto] ||= PROTO.find{|f| File.directory?(f) }
|
23
|
-
layout = options[:layout] ||= '/'
|
24
|
-
File.expand_path(File.join(proto, layout))
|
25
|
-
end
|
26
|
-
|
27
|
-
def create_root?
|
28
|
-
return true unless File.directory?(target)
|
29
|
-
return true if amend? or force?
|
30
|
-
fatal "%p is a directory, choose different project name or use --amend/--force" % target
|
31
|
-
end
|
32
|
-
|
33
|
-
def got_proto?
|
34
|
-
return true if File.directory?(proto)
|
35
|
-
fatal "Cannot create, %p doesn't exist, use --proto or create the proto directory" % proto
|
36
|
-
end
|
37
|
-
|
38
|
-
def create
|
39
|
-
got_proto?
|
40
|
-
|
41
|
-
puts "Found proto at: %p, proceeding...\n\n" % proto
|
42
|
-
mkdir(relate('/')) if create_root?
|
43
|
-
proceed
|
44
|
-
end
|
45
|
-
|
46
|
-
def proceed
|
47
|
-
files, directories = partition{|path| File.file?(path) }
|
48
|
-
proceed_directories(directories)
|
49
|
-
proceed_files(files)
|
50
|
-
end
|
51
|
-
|
52
|
-
def proceed_files(files)
|
53
|
-
files.each{|file| copy(file, relate(file)) }
|
54
|
-
end
|
55
|
-
|
56
|
-
def proceed_directories(dirs)
|
57
|
-
dirs.each{|dir| mkdir(relate(dir)) }
|
58
|
-
end
|
59
|
-
|
60
|
-
def mkdir(dir)
|
61
|
-
exists = File.directory?(dir)
|
62
|
-
return if exists and amend?
|
63
|
-
return if exists and not force?
|
64
|
-
puts "mkdir(%p)" % dir
|
65
|
-
FileUtils.mkdir_p(dir)
|
66
|
-
end
|
67
|
-
|
68
|
-
def copy(from, to)
|
69
|
-
return unless copy_check(to)
|
70
|
-
puts "copy(%p, %p)" % [from, to]
|
71
|
-
FileUtils.cp(from, to)
|
72
|
-
post_process(to)
|
73
|
-
end
|
74
|
-
|
75
|
-
def copy_check(to)
|
76
|
-
exists = File.file?(to)
|
77
|
-
return if exists and amend?
|
78
|
-
return if exists and not force?
|
79
|
-
return true
|
80
|
-
end
|
81
|
-
|
82
|
-
# Think about a useful way to process the generated files it should be
|
83
|
-
# possible to substitute some things like the project name in the
|
84
|
-
# configuration
|
85
|
-
|
86
|
-
def post_process(file)
|
87
|
-
return
|
88
|
-
source = File.read(file)
|
89
|
-
File.open(file, 'w+') do |io|
|
90
|
-
io.write(source.gsub('$project', "'#@name'"))
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
def relate(path)
|
95
|
-
File.join(target, path.to_s.sub(proto, ''))
|
96
|
-
end
|
97
|
-
|
98
|
-
def amend?; options[:amend] end
|
99
|
-
def force?; options[:force] end
|
100
|
-
|
101
|
-
def fatal(message)
|
102
|
-
warn message
|
103
|
-
exit 1
|
104
|
-
end
|
105
|
-
|
106
|
-
def each
|
107
|
-
Dir["#{proto}/**/*"].each{|path| yield(path) }
|
108
|
-
end
|
109
|
-
|
110
|
-
include Enumerable
|
111
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
|
2
|
-
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
-
|
4
|
-
require 'spec/helper'
|
5
|
-
spec_require 'localmemcache'
|
6
|
-
|
7
|
-
describe Ramaze::Cache::LocalMemCache do
|
8
|
-
Ramaze.options.cache.names = [:one, :two]
|
9
|
-
Ramaze.options.cache.default = Ramaze::Cache::LocalMemCache
|
10
|
-
Ramaze.setup_dependencies
|
11
|
-
|
12
|
-
cache = Ramaze::Cache.one
|
13
|
-
hello = 'Hello, World!'
|
14
|
-
|
15
|
-
should 'store without ttl' do
|
16
|
-
cache.store(:hello, hello).should == hello
|
17
|
-
end
|
18
|
-
|
19
|
-
should 'fetch' do
|
20
|
-
cache.fetch(:hello).should == hello
|
21
|
-
end
|
22
|
-
|
23
|
-
should 'delete' do
|
24
|
-
cache.delete(:hello)
|
25
|
-
cache.fetch(:hello).should == nil
|
26
|
-
end
|
27
|
-
|
28
|
-
should 'delete two key/value pairs at once' do
|
29
|
-
cache.store(:hello, hello).should == hello
|
30
|
-
cache.store(:ramaze, 'ramaze').should == 'ramaze'
|
31
|
-
cache.delete(:hello, :ramaze)
|
32
|
-
cache.fetch(:hello).should == nil
|
33
|
-
cache.fetch(:innate).should == nil
|
34
|
-
end
|
35
|
-
|
36
|
-
should 'store with ttl' do
|
37
|
-
cache.store(:hello, @hello, :ttl => 0.2)
|
38
|
-
cache.fetch(:hello).should == @hello
|
39
|
-
sleep 0.3
|
40
|
-
cache.fetch(:hello).should == nil
|
41
|
-
end
|
42
|
-
|
43
|
-
should 'clear' do
|
44
|
-
cache.store(:hello, @hello)
|
45
|
-
cache.fetch(:hello).should == @hello
|
46
|
-
cache.clear
|
47
|
-
cache.fetch(:hello).should == nil
|
48
|
-
end
|
49
|
-
end
|
data/tasks/setup.rake
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
desc 'install all possible dependencies'
|
2
|
-
task :setup do
|
3
|
-
GemInstaller.new do
|
4
|
-
# core
|
5
|
-
gem 'innate', '= 2009.04'
|
6
|
-
|
7
|
-
# misc
|
8
|
-
gem 'bacon', '>= 1.0'
|
9
|
-
gem 'json', '>= 1.1.3'
|
10
|
-
gem 'memcache', '~> 1.7.0'
|
11
|
-
|
12
|
-
# templating engines
|
13
|
-
gem 'Remarkably', '~> 0.5.2'
|
14
|
-
gem 'erubis', '>= 2.6.4'
|
15
|
-
gem 'haml', '~> 2.0.9'
|
16
|
-
gem 'hpricot', '>= 0.7'
|
17
|
-
gem 'liquid', '~> 2.0.0'
|
18
|
-
gem 'sequel', '>= 2.11.0'
|
19
|
-
gem 'tagz', '>= 5.0.1'
|
20
|
-
gem 'tenjin', '~> 0.6.1'
|
21
|
-
|
22
|
-
setup
|
23
|
-
end
|
24
|
-
end
|