Capcode 0.8.6 → 0.8.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. data/README.rdoc +72 -1
  2. data/doc/rdoc/classes/Capcode.html +549 -444
  3. data/doc/rdoc/classes/Capcode/Helpers.html +293 -133
  4. data/doc/rdoc/classes/Capcode/Helpers/Authorization.html +60 -29
  5. data/doc/rdoc/created.rid +1 -1
  6. data/doc/rdoc/files/README_rdoc.html +94 -8
  7. data/doc/rdoc/files/lib/capcode/configuration_rb.html +101 -0
  8. data/doc/rdoc/files/lib/capcode/helpers/auth_rb.html +1 -32
  9. data/doc/rdoc/files/lib/capcode/render/erb_rb.html +1 -1
  10. data/doc/rdoc/files/lib/capcode/render/haml_rb.html +1 -1
  11. data/doc/rdoc/files/lib/capcode/render/markaby_rb.html +1 -1
  12. data/doc/rdoc/files/lib/capcode/render/sass_rb.html +1 -1
  13. data/doc/rdoc/files/lib/capcode/render/text_rb.html +1 -1
  14. data/doc/rdoc/files/lib/capcode_rb.html +8 -1
  15. data/doc/rdoc/fr_file_index.html +1 -0
  16. data/doc/rdoc/fr_method_index.html +19 -11
  17. data/examples/blog-couchdb.rb +4 -3
  18. data/examples/erb/cf.rhtml +1 -0
  19. data/examples/haml/cf.haml +4 -1
  20. data/examples/render-erb.rb +4 -1
  21. data/examples/render-haml_sass.rb +6 -2
  22. data/examples/render-image.rb +70 -0
  23. data/examples/render-static.rb +4 -1
  24. data/examples/render-static.ru +0 -2
  25. data/examples/render-use.rb +31 -0
  26. data/examples/static/coderay.css +131 -0
  27. data/examples/static/index.html +19 -0
  28. data/lib/capcode.rb +125 -76
  29. data/lib/capcode/configuration.rb +39 -0
  30. data/lib/capcode/helpers/auth.rb +22 -23
  31. data/lib/capcode/render/erb.rb +25 -18
  32. data/lib/capcode/render/haml.rb +28 -19
  33. data/lib/capcode/render/markaby.rb +2 -1
  34. data/lib/capcode/render/sass.rb +19 -13
  35. data/lib/capcode/render/text.rb +1 -1
  36. data/lib/capcode/version.rb +1 -1
  37. metadata +8 -2
@@ -2,15 +2,16 @@ require "haml"
2
2
 
3
3
  module Capcode
4
4
  module Helpers
5
- @@__HAML_PATH__ = nil
6
5
  # Set the path to Haml files. If this path is not set, Capcode will search in the static path.
7
- def self.haml_path=( p ) #:nodoc:
8
- @@__HAML_PATH__ = p
6
+ # This method is deprecated and will be removed in version 1.0
7
+ def self.haml_path=( p )
8
+ warn "Capcode::Helpers.haml_path is deprecated and will be removed in version 1.0, please use `set :haml'"
9
+ Capcode.set :haml, p
9
10
  end
10
11
 
11
12
  def render_haml( f, opts ) #:nodoc:
12
- if @@__HAML_PATH__.nil?
13
- @@__HAML_PATH__ = "." + (Capcode.static.nil? == false)?Capcode.static():''
13
+ if @haml_path.nil?
14
+ @haml_path = Capcode.get( :haml ) || Capcode.static()
14
15
  end
15
16
 
16
17
  f = f.to_s
@@ -19,28 +20,36 @@ module Capcode
19
20
  end
20
21
 
21
22
  if /Windows/.match( ENV['OS'] )
22
- unless( /.:\\/.match( @@__HAML_PATH__[0] ) )
23
- @@__HAML_PATH__ = File.expand_path( File.join(".", @@__HAML_PATH__) )
23
+ unless( /.:\\/.match( @haml_path[0] ) )
24
+ @haml_path = File.expand_path( File.join(".", @haml_path) )
24
25
  end
25
26
  else
26
- unless( @@__HAML_PATH__[0].chr == "/" )
27
- @@__HAML_PATH__ = File.expand_path( File.join(".", @@__HAML_PATH__) )
27
+ unless( @haml_path[0].chr == "/" )
28
+ @haml_path = File.expand_path( File.join(".", @haml_path) )
28
29
  end
29
30
  end
30
-
31
+
32
+ # Get Layout file
31
33
  layout = opts.delete(:layout)||:layout
32
- layout_file = File.join( @@__HAML_PATH__, layout.to_s+".haml" )
34
+ layout_file = File.join( @haml_path, layout.to_s+".haml" )
33
35
 
36
+ # Get HAML File
34
37
  f = f + ".haml" if File.extname( f ) != ".haml"
35
- file = File.join( @@__HAML_PATH__, f )
36
-
37
- if( File.exist?( layout_file ) )
38
- Haml::Engine.new( open( layout_file ).read ).to_html(self) { |*args|
39
- @@__ARGS__ = args
40
- Haml::Engine.new( open( file ).read ).render(self)
41
- }
38
+ file = File.join( @haml_path, f )
39
+
40
+ # Render
41
+ if( File.exist?( file ) )
42
+ if( File.exist?( layout_file ) )
43
+ Haml::Engine.new( open( layout_file ).read ).to_html(self) { |*args|
44
+ #@@__ARGS__ = args
45
+ Capcode::Helpers.args = args
46
+ Haml::Engine.new( open( file ).read ).render(self)
47
+ }
48
+ else
49
+ Haml::Engine.new( open( file ).read ).to_html( self )
50
+ end
42
51
  else
43
- Haml::Engine.new( open( file ).read ).to_html( self )
52
+ raise Capcode::RenderError, "Error rendering `haml', #{file} does not exist !"
44
53
  end
45
54
  end
46
55
  end
@@ -15,7 +15,8 @@ module Capcode
15
15
  __mab = Mab.new({}, self) {
16
16
  if self.respond_to?(layout)
17
17
  self.send(layout.to_s) { |*args|
18
- @@__ARGS__ = args
18
+ #@@__ARGS__ = args
19
+ Capcode::Helpers.args = args
19
20
  self.send(f)
20
21
  }
21
22
  else
@@ -2,16 +2,16 @@ require "sass"
2
2
 
3
3
  module Capcode
4
4
  module Helpers
5
- @@__SASS_PATH__ = "."
6
-
7
5
  # Set the path to Sass files. If this path is not set, Capcode will search in the static path.
8
- def self.sass_path=( p ) #:nodoc:
9
- @@__SASS_PATH__ = p
6
+ # This method is deprecated and will be removed in version 1.0
7
+ def self.sass_path=( p )
8
+ warn "Capcode::Helpers.sass_path is deprecated and will be removed in version 1.0, please use `set :sass'"
9
+ Capcode.set :sass, p
10
10
  end
11
11
 
12
12
  def render_sass( f, _ ) #:nodoc:
13
- if @@__SASS_PATH__.nil?
14
- @@__SASS_PATH__ = "." + (Capcode.static.nil? == false)?Capcode.static():''
13
+ if @sass_path.nil?
14
+ @sass_path = Capcode.get( :sass ) || Capcode.static()
15
15
  end
16
16
 
17
17
  f = f.to_s
@@ -20,19 +20,25 @@ module Capcode
20
20
  end
21
21
 
22
22
  if /Windows/.match( ENV['OS'] )
23
- unless( /.:\\/.match( @@__SASS_PATH__[0] ) )
24
- @@__SASS_PATH__ = File.expand_path( File.join(".", @@__SASS_PATH__) )
23
+ unless( /.:\\/.match( @sass_path[0] ) )
24
+ @sass_path = File.expand_path( File.join(".", @sass_path) )
25
25
  end
26
26
  else
27
- unless( @@__SASS_PATH__[0].chr == "/" )
28
- @@__SASS_PATH__ = File.expand_path( File.join(".", @@__SASS_PATH__) )
27
+ unless( @sass_path[0].chr == "/" )
28
+ @sass_path = File.expand_path( File.join(".", @sass_path) )
29
29
  end
30
30
  end
31
-
31
+
32
+ # Get File
32
33
  f = f + ".sass" if File.extname( f ) != ".sass"
33
- file = File.join( @@__SASS_PATH__, f )
34
+ file = File.join( @sass_path, f )
34
35
 
35
- Sass::Engine.new( open( file ).read ).to_css
36
+ # Render
37
+ if( File.exist?( file ) )
38
+ Sass::Engine.new( open( file ).read ).to_css
39
+ else
40
+ raise Capcode::RenderError, "Error rendering `sass', #{file} does not exist !"
41
+ end
36
42
  end
37
43
  end
38
44
  end
@@ -1,6 +1,6 @@
1
1
  module Capcode
2
2
  module Helpers
3
- def render_text( f, _ ) #:nodoc:
3
+ def render_text( f, opts ) #:nodoc:
4
4
  f
5
5
  end
6
6
  end
@@ -1,3 +1,3 @@
1
1
  module Capcode
2
- CAPCOD_VERION="0.8.6"
2
+ CAPCOD_VERION="0.8.7"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Capcode
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.6
4
+ version: 0.8.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Gr\xC3\xA9goire Lejeune"
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-09 00:00:00 +02:00
12
+ date: 2009-10-21 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -43,6 +43,7 @@ extra_rdoc_files:
43
43
  - AUTHORS
44
44
  - COPYING
45
45
  - lib/capcode.rb
46
+ - lib/capcode/configuration.rb
46
47
  - lib/capcode/base/db.rb
47
48
  - lib/capcode/render/erb.rb
48
49
  - lib/capcode/render/haml.rb
@@ -70,6 +71,7 @@ files:
70
71
  - doc/rdoc/files/AUTHORS.html
71
72
  - doc/rdoc/files/COPYING.html
72
73
  - doc/rdoc/files/lib/capcode/base/db_rb.html
74
+ - doc/rdoc/files/lib/capcode/configuration_rb.html
73
75
  - doc/rdoc/files/lib/capcode/helpers/auth_rb.html
74
76
  - doc/rdoc/files/lib/capcode/render/erb_rb.html
75
77
  - doc/rdoc/files/lib/capcode/render/haml_rb.html
@@ -90,6 +92,7 @@ files:
90
92
  - lib/capcode/base/couchdb.rb
91
93
  - lib/capcode/base/db.rb
92
94
  - lib/capcode/base/dm.rb
95
+ - lib/capcode/configuration.rb
93
96
  - lib/capcode/core_ext.rb
94
97
  - lib/capcode/helpers/auth.rb
95
98
  - lib/capcode/render/erb.rb
@@ -124,11 +127,13 @@ files:
124
127
  - examples/my_blog.db
125
128
  - examples/render-erb.rb
126
129
  - examples/render-haml_sass.rb
130
+ - examples/render-image.rb
127
131
  - examples/render-json.rb
128
132
  - examples/render-markaby.rb
129
133
  - examples/render-static.rb
130
134
  - examples/render-static.ru
131
135
  - examples/render-text.rb
136
+ - examples/render-use.rb
132
137
  - examples/render-webdav.rb
133
138
  - examples/render-xml.rb
134
139
  - examples/rest-run.rb
@@ -137,6 +142,7 @@ files:
137
142
  - examples/rss.rb
138
143
  - examples/sample.rb
139
144
  - examples/session.rb
145
+ - examples/static/coderay.css
140
146
  - examples/static/index.html
141
147
  - examples/test/index.html
142
148
  - examples/upload.rb