amrita2 2.0.1 → 2.0.2

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.
Files changed (162) hide show
  1. data/README +5 -5
  2. data/Rakefile +85 -0
  3. data/lib/amrita2/gettext.rb +9 -4
  4. data/lib/amrita2/template.rb +20 -9
  5. data/lib/amrita2/testsupport.rb +25 -0
  6. data/lib/amrita2/version.rb +1 -1
  7. data/sample/depot/README +160 -0
  8. data/sample/depot/Rakefile +10 -0
  9. data/sample/depot/app/views/admin/_form.html.a2 +23 -0
  10. data/sample/depot/app/views/admin/_form.html.erb +14 -0
  11. data/sample/depot/app/views/admin/edit.html.a2 +22 -0
  12. data/sample/depot/app/views/admin/edit.html.erb +10 -0
  13. data/sample/depot/app/views/admin/list.html.a2 +34 -0
  14. data/sample/depot/app/views/admin/list.html.erb +37 -0
  15. data/sample/depot/app/views/admin/new.html.a2 +21 -0
  16. data/sample/depot/app/views/admin/new.html.erb +9 -0
  17. data/sample/depot/app/views/admin/show.html.a2 +12 -0
  18. data/sample/depot/app/views/admin/show.html.erb +13 -0
  19. data/sample/depot/app/views/info/who_bought.rhtml +14 -0
  20. data/sample/depot/app/views/info/who_bought.rxml +8 -0
  21. data/sample/depot/app/views/layouts/admin.a2html +32 -0
  22. data/sample/depot/app/views/layouts/admin.rhtml +40 -0
  23. data/sample/depot/app/views/layouts/store.a2html +37 -0
  24. data/sample/depot/app/views/layouts/store.rhtml +43 -0
  25. data/sample/depot/app/views/login/add_user.rhtml +33 -0
  26. data/sample/depot/app/views/login/index.rhtml +9 -0
  27. data/sample/depot/app/views/login/list_users.rhtml +20 -0
  28. data/sample/depot/app/views/login/login.rhtml +26 -0
  29. data/sample/depot/app/views/store/_cart.html.a2 +18 -0
  30. data/sample/depot/app/views/store/_cart.html.erb +17 -0
  31. data/sample/depot/app/views/store/_cart_item.html.a2 +16 -0
  32. data/sample/depot/app/views/store/_cart_item.html.erb +14 -0
  33. data/sample/depot/app/views/store/add_to_cart.rjs +11 -0
  34. data/sample/depot/app/views/store/checkout.html.a2 +45 -0
  35. data/sample/depot/app/views/store/checkout.html.a2.using_macro +32 -0
  36. data/sample/depot/app/views/store/checkout.html.a2.without_label +37 -0
  37. data/sample/depot/app/views/store/checkout.html.erb +41 -0
  38. data/sample/depot/app/views/store/index.html.a2 +19 -0
  39. data/sample/depot/app/views/store/index.html.erb +22 -0
  40. data/sample/depot/config/database.yml +24 -0
  41. data/sample/depot/db/create_database.sql +14 -0
  42. data/sample/depot/doc/README_FOR_APP +35 -0
  43. data/sample/depot/lib/tasks/db_schema_version.rake +6 -0
  44. data/sample/depot/log/development.log +116 -0
  45. data/sample/depot/log/test.log +347 -0
  46. data/sample/depot/public/404.html +13 -0
  47. data/sample/depot/public/500.html +13 -0
  48. data/sample/depot/public/dispatch.cgi +10 -0
  49. data/sample/depot/public/dispatch.fcgi +24 -0
  50. data/sample/depot/public/favicon.ico +0 -0
  51. data/sample/depot/public/images/auto.jpg +0 -0
  52. data/sample/depot/public/images/logo.png +0 -0
  53. data/sample/depot/public/images/rails.png +0 -0
  54. data/sample/depot/public/images/svn.jpg +0 -0
  55. data/sample/depot/public/images/utc.jpg +0 -0
  56. data/sample/depot/public/index.html +282 -0
  57. data/sample/depot/public/javascripts/application.js +2 -0
  58. data/sample/depot/public/javascripts/controls.js +832 -0
  59. data/sample/depot/public/javascripts/dragdrop.js +942 -0
  60. data/sample/depot/public/javascripts/effects.js +954 -0
  61. data/sample/depot/public/javascripts/prototype.js +2347 -0
  62. data/sample/depot/public/robots.txt +1 -0
  63. data/sample/depot/public/stylesheets/depot.css +227 -0
  64. data/sample/depot/public/stylesheets/scaffold.css +74 -0
  65. data/sample/depot/script/about +3 -0
  66. data/sample/depot/script/breakpointer +3 -0
  67. data/sample/depot/script/console +3 -0
  68. data/sample/depot/script/destroy +3 -0
  69. data/sample/depot/script/generate +3 -0
  70. data/sample/depot/script/performance/benchmarker +3 -0
  71. data/sample/depot/script/performance/profiler +3 -0
  72. data/sample/depot/script/plugin +3 -0
  73. data/sample/depot/script/process/inspector +3 -0
  74. data/sample/depot/script/process/reaper +3 -0
  75. data/sample/depot/script/process/spawner +3 -0
  76. data/sample/depot/script/runner +3 -0
  77. data/sample/depot/script/server +3 -0
  78. data/sample/depot/test/fixtures/line_items.yml +16 -0
  79. data/sample/depot/test/fixtures/orders.yml +4 -0
  80. data/sample/depot/test/fixtures/performance/products.yml +8 -0
  81. data/sample/depot/test/fixtures/products.yml +16 -0
  82. data/sample/depot/test/fixtures/users.yml +7 -0
  83. data/sample/depot/vendor/plugins/will_paginate/LICENSE +18 -0
  84. data/sample/depot/vendor/plugins/will_paginate/README +171 -0
  85. data/sample/depot/vendor/plugins/will_paginate/Rakefile +27 -0
  86. data/sample/depot/vendor/plugins/will_paginate/test/console +9 -0
  87. data/sample/depot/vendor/plugins/will_paginate/test/fixtures/companies.yml +24 -0
  88. data/sample/depot/vendor/plugins/will_paginate/test/fixtures/developers_projects.yml +13 -0
  89. data/sample/depot/vendor/plugins/will_paginate/test/fixtures/projects.yml +7 -0
  90. data/sample/depot/vendor/plugins/will_paginate/test/fixtures/replies.yml +34 -0
  91. data/sample/depot/vendor/plugins/will_paginate/test/fixtures/schema.sql +44 -0
  92. data/sample/depot/vendor/plugins/will_paginate/test/fixtures/topics.yml +30 -0
  93. data/sample/depot/vendor/plugins/will_paginate/test/fixtures/users.yml +35 -0
  94. data/sample/login_engine/README +182 -0
  95. data/sample/login_engine/Rakefile +27 -0
  96. data/sample/login_engine/app/views/layouts/user.a2html +20 -0
  97. data/sample/login_engine/app/views/layouts/user.rhtml +16 -0
  98. data/sample/login_engine/app/views/user/_edit.a2html +16 -0
  99. data/sample/login_engine/app/views/user/_edit.rhtml +11 -0
  100. data/sample/login_engine/app/views/user/_password.a2html +18 -0
  101. data/sample/login_engine/app/views/user/_password.rhtml +9 -0
  102. data/sample/login_engine/app/views/user/change_password.a2html +17 -0
  103. data/sample/login_engine/app/views/user/change_password.rhtml +17 -0
  104. data/sample/login_engine/app/views/user/edit.a2html +22 -0
  105. data/sample/login_engine/app/views/user/edit.rhtml +23 -0
  106. data/sample/login_engine/app/views/user/forgot_password.rhtml +18 -0
  107. data/sample/login_engine/app/views/user/home.a2html +12 -0
  108. data/sample/login_engine/app/views/user/home.rhtml +7 -0
  109. data/sample/login_engine/app/views/user/login.a2html +16 -0
  110. data/sample/login_engine/app/views/user/login.rhtml +17 -0
  111. data/sample/login_engine/app/views/user/logout.rhtml +8 -0
  112. data/sample/login_engine/app/views/user/signup.a2html +14 -0
  113. data/sample/login_engine/app/views/user/signup.rhtml +17 -0
  114. data/sample/login_engine/app/views/user_notify/change_password.rhtml +10 -0
  115. data/sample/login_engine/app/views/user_notify/delete.rhtml +5 -0
  116. data/sample/login_engine/app/views/user_notify/forgot_password.rhtml +11 -0
  117. data/sample/login_engine/app/views/user_notify/pending_delete.rhtml +9 -0
  118. data/sample/login_engine/app/views/user_notify/signup.rhtml +12 -0
  119. data/sample/login_engine/config/database.yml +18 -0
  120. data/sample/login_engine/db/create_database.sql +14 -0
  121. data/sample/login_engine/db/dev.sqlite3 +0 -0
  122. data/sample/login_engine/db/test.sqlite3 +0 -0
  123. data/sample/login_engine/doc/README_FOR_APP +2 -0
  124. data/sample/login_engine/locale/ja/LC_MESSAGES/login_engine.mo +0 -0
  125. data/sample/login_engine/log/development.log +330 -0
  126. data/sample/login_engine/log/test.log +19026 -0
  127. data/sample/login_engine/po/ja/login_engine.po +248 -0
  128. data/sample/login_engine/po/login_engine.pot +245 -0
  129. data/sample/login_engine/public/404.html +30 -0
  130. data/sample/login_engine/public/500.html +30 -0
  131. data/sample/login_engine/public/dispatch.cgi +10 -0
  132. data/sample/login_engine/public/dispatch.fcgi +24 -0
  133. data/sample/login_engine/public/favicon.ico +0 -0
  134. data/sample/login_engine/public/images/rails.png +0 -0
  135. data/sample/login_engine/public/index.html +277 -0
  136. data/sample/login_engine/public/javascripts/application.js +2 -0
  137. data/sample/login_engine/public/javascripts/controls.js +833 -0
  138. data/sample/login_engine/public/javascripts/dragdrop.js +942 -0
  139. data/sample/login_engine/public/javascripts/effects.js +1088 -0
  140. data/sample/login_engine/public/javascripts/prototype.js +2385 -0
  141. data/sample/login_engine/public/robots.txt +1 -0
  142. data/sample/login_engine/public/stylesheets/login_engine.css +81 -0
  143. data/sample/login_engine/script/about +3 -0
  144. data/sample/login_engine/script/breakpointer +3 -0
  145. data/sample/login_engine/script/console +3 -0
  146. data/sample/login_engine/script/destroy +3 -0
  147. data/sample/login_engine/script/generate +3 -0
  148. data/sample/login_engine/script/performance/benchmarker +3 -0
  149. data/sample/login_engine/script/performance/profiler +3 -0
  150. data/sample/login_engine/script/plugin +3 -0
  151. data/sample/login_engine/script/process/inspector +3 -0
  152. data/sample/login_engine/script/process/reaper +3 -0
  153. data/sample/login_engine/script/process/spawner +3 -0
  154. data/sample/login_engine/script/runner +3 -0
  155. data/sample/login_engine/script/server +3 -0
  156. data/sample/login_engine/test/fixtures/users.yml +41 -0
  157. data/specs/erb_cdata.rb +11 -0
  158. data/specs/filters.rb +5 -4
  159. data/specs/gettext/static_text.rb +30 -13
  160. data/specs/impl/preprocess.rb +58 -54
  161. metadata +375 -120
  162. data/sample/hello/test1.rb +0 -23
data/README CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  == Summary
4
4
 
5
- Amrita2 is a a xml/xhtml template library for Ruby.
5
+ Amrita2 is a a xml/xhtml template library for Ruby.
6
6
  It makes html documents from a template and a model data.
7
7
 
8
8
  === Key feature
@@ -22,7 +22,7 @@ It makes html documents from a template and a model data.
22
22
  </html>
23
23
  END
24
24
 
25
- data = {
25
+ data = {
26
26
  :page_title=>'Amrita2',
27
27
  :header_title=>'Hello, Amrita2',
28
28
  :text=>{
@@ -37,7 +37,7 @@ It makes html documents from a template and a model data.
37
37
  </head>
38
38
  <body>
39
39
  <h1>Hello, Amrita2</h1>
40
- <p class="text">Amrita2 is a html template library for Ruby</p>
40
+ <p class="text">Amrita2 is a html template library for Ruby</p>
41
41
  </body>
42
42
  </html>
43
43
  END
@@ -77,7 +77,7 @@ matching the +id+ attribute of XML element to model data.
77
77
 
78
78
  === Current version and roadmap
79
79
 
80
- Current version is 2.0.1 .
80
+ Current version is 2.0.2 .
81
81
 
82
82
  === Setup
83
83
 
@@ -102,7 +102,7 @@ Amrita2 is Copyright (c) 2008 Taku Nakajima
102
102
  redistributed under the terms specified in the README file of the Ruby
103
103
  distribution.
104
104
 
105
- Sample source code under sample/depot is Amrita2 version of
105
+ Sample source code under sample/depot is Amrita2 version of
106
106
  Depot Application of "Agile Web Development with Rails".
107
107
 
108
108
  http://www.pragprog.com/titles/rails2/source_code
@@ -0,0 +1,85 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'rake/testtask'
4
+ require 'rake/rdoctask'
5
+ require 'spec/rake/spectask'
6
+ require 'lib/amrita2/version'
7
+
8
+ Gem.manage_gems
9
+
10
+ TMP='/tmp'
11
+ PACKAGE_NAME = "amrita2"
12
+ PACKAGE_VERSION = Amrita2::Version::STRING
13
+ package_name = "#{PACKAGE_NAME}-#{PACKAGE_VERSION}"
14
+ package_dir = "pkg"
15
+ package_dir_path = "#{package_dir}/#{package_name}"
16
+
17
+ tar_file = "#{package_name}.tar.gz"
18
+ gem_file = "#{package_name}.gem"
19
+
20
+ ENV['RUBYLIB'] = "lib"
21
+
22
+ task :default => [ :specs, :test_login_engine, :spec1 ]
23
+ task :test => [ :specs ]
24
+
25
+ desc "Run all specs"
26
+ Spec::Rake::SpecTask.new('specs') do |t|
27
+ t.spec_files = FileList['specs/**/*.rb']
28
+ t.spec_opts = %w(-Du)
29
+ end
30
+
31
+ desc "Run all specs one by one"
32
+ task :spec1 do
33
+ tmp = "/tmp/amrita_spec.out"
34
+ Dir['specs/**/*.rb'].each do |f|
35
+ begin
36
+ sh %{spec #{f} > #{tmp} }
37
+ sh %{spec -r amrita2/gettext #{f} > #{tmp} }
38
+ rescue
39
+ puts File::open(tmp).read
40
+ raise
41
+ end
42
+ end
43
+ end
44
+
45
+ task :clean do
46
+ Dir['**/*~'].each do |f|
47
+ puts f
48
+ FileUtils::rm_f f
49
+ end
50
+
51
+ Dir['docs'].each do |f|
52
+ puts f
53
+ FileUtils::rm_rf f
54
+ end
55
+ end
56
+
57
+ task :test_login_engine do
58
+ Dir::chdir("sample/login_engine") do
59
+ Dir::mkdir "log" unless FileTest::directory?("log")
60
+ sh %{rake test}
61
+ end
62
+ end
63
+
64
+ desc "Generate documentation for the application"
65
+ Rake::RDocTask.new("appdoc") { |rdoc|
66
+ rdoc.rdoc_dir = 'docs/app'
67
+ rdoc.title = "Amrita2 Documentation"
68
+ rdoc.rdoc_files = Dir['lib/amrita2/*.rb']
69
+ rdoc.rdoc_files << 'README'
70
+ }
71
+
72
+ task :tar do
73
+ Dir::chdir(TMP) do
74
+ system 'rm -rf amrita2'
75
+ system "svn export http://svn.brain-tokyo.net/amrita2/trunk/amrita2 #{package_name}"
76
+ system "tar zcvf #{tar_file} #{package_name}"
77
+ end
78
+ end
79
+
80
+ task :gem => :clean do
81
+ spec = eval(File.read("amrita2.gemspec"))
82
+ Gem::Builder.new(spec).build
83
+ mv gem_file, "#{TMP}/#{gem_file}"
84
+ end
85
+
@@ -1,7 +1,7 @@
1
1
  require 'amrita2/template'
2
2
  require 'gettext/rgettext'
3
3
 
4
- module Amrita2
4
+ module Amrita2
5
5
  module Core
6
6
  class CompoundElement # :nodoc: all
7
7
  def get_erb_source
@@ -25,6 +25,11 @@ module Amrita2
25
25
  end
26
26
  end
27
27
 
28
+ class CommentNode # :nodoc: all
29
+ def get_erb_source
30
+ ""
31
+ end
32
+ end
28
33
 
29
34
  class RootElement < DynamicElement # :nodoc: all
30
35
  attr_accessor :text_domain
@@ -55,10 +60,10 @@ module Amrita2
55
60
  def dynamic?
56
61
  true
57
62
  end
58
-
63
+
59
64
  def render_me(cg)
60
65
  #text = @node.to_s.strip
61
-
66
+
62
67
  # to keep &nbsp;
63
68
  text = ""
64
69
  @node.output(text, :preserve=>true)
@@ -92,7 +97,7 @@ module Amrita2
92
97
 
93
98
  module_function
94
99
  def target?(file)
95
- File.extname(file) == '.a2html'
100
+ File.extname(file) == '.a2html' || File.extname(file) == '.a2'
96
101
  end
97
102
 
98
103
  def parse(file, ary)
@@ -2,7 +2,7 @@ require 'hpricot'
2
2
  require 'erb'
3
3
  require 'enumerator'
4
4
 
5
- module Amrita2
5
+ module Amrita2
6
6
  module ScalarData
7
7
  def amrita_value
8
8
  Amrita2::Util::sanitize_text(to_s)
@@ -394,7 +394,7 @@ module Amrita2
394
394
  end
395
395
  end
396
396
 
397
- module Core
397
+ module Core
398
398
  class CodeGenerator # :nodoc: all
399
399
  def initialize
400
400
  @iehack = true
@@ -1165,8 +1165,8 @@ module Amrita2
1165
1165
  #
1166
1166
  # tmpl = Template.new "...."
1167
1167
  # tmpl.set_trace(STDOUT)
1168
- # puts tmpl.render_with(...)
1169
-
1168
+ # puts tmpl.render_with(...)
1169
+
1170
1170
  def set_trace(io_or_type, &block)
1171
1171
  @tracer = Tracer.new(io_or_type, &block)
1172
1172
  end
@@ -1554,7 +1554,8 @@ module Amrita2
1554
1554
  S_COND = %q[\\?(\\!)?\\[(.+)\\]]
1555
1555
  S_VALUE = %q[\\{(.+)\\}]
1556
1556
  S_TRAILER = %q[((?: |\\-)*)]
1557
- S_AMVARS = %[(#{S_FOR}|#{S_COND}|#{S_VALUE})?]
1557
+ S_ERB_IN_AMXML = %q[%=(.*)]
1558
+ S_AMVARS = %[(#{S_FOR}|#{S_COND}|#{S_VALUE}|#{S_ERB_IN_AMXML})?]
1558
1559
  R_AMXML_WITHOUT_TAG = %r[\A\s*(?:\/)?\s*(?:#{S_NO_SRC}|#{S_SRC_AND_FILTERS})*\s*#{S_AMVARS}\s*\Z]um
1559
1560
  R_AMXML = %r[\A#{R_TAG_ATTR}\s*(?:\/)?\s*(?:#{S_NO_SRC}|#{S_SRC_AND_FILTERS})*\s*#{S_AMVARS}\s*\Z]um
1560
1561
  R_AMXML_BLOCK_LINE = %r[^\s*<<\s*?(.*)\s*?<#{S_TRAILER}$]
@@ -1648,6 +1649,8 @@ module Amrita2
1648
1649
  end
1649
1650
  when %r[#{S_VALUE}]m
1650
1651
  @value = $1.strip
1652
+ when %r[#{S_ERB_IN_AMXML}]m
1653
+ @erb = $1.strip
1651
1654
  else
1652
1655
  raise "can't happen #{s}"
1653
1656
  end
@@ -1702,7 +1705,7 @@ module Amrita2
1702
1705
  ret << make_attr(am_skipif, @skipif)
1703
1706
  end
1704
1707
  if @skipunless
1705
- am_skipif = @opt[:am_skipif] || "am:skipif"
1708
+ am_skipif = @opt[:am_skipunless] || "am:skipif"
1706
1709
  ret << make_attr(am_skipif, "not(#@skipunless)")
1707
1710
  end
1708
1711
  if @value
@@ -1710,10 +1713,18 @@ module Amrita2
1710
1713
  ret << make_attr(am_v, "HashDelegator.new($_) { {#@value} }")
1711
1714
  end
1712
1715
  ret << @attr.to_s
1713
- if single_tag
1714
- ret << " />"
1716
+ if @erb
1717
+ if single_tag
1718
+ ret << "><![CDATA[<%= #{@erb} %>]]></#@tag>"
1719
+ else
1720
+ raise "not implemented"
1721
+ end
1715
1722
  else
1716
- ret << " >"
1723
+ if single_tag
1724
+ ret << " />"
1725
+ else
1726
+ ret << " >"
1727
+ end
1717
1728
  end
1718
1729
  ret
1719
1730
  end
@@ -144,3 +144,28 @@ end
144
144
  class Object
145
145
  include Amrita2::TestSupport
146
146
  end
147
+
148
+ if Object::const_defined?(:ActionView)
149
+
150
+ class ActionView::Base # :nodoc: all
151
+ def self.unregister_template_handler(extension)
152
+ self.cache_template_extensions = false
153
+ @@template_handlers.delete(extension)
154
+ end
155
+ end
156
+
157
+ module Amrita2
158
+ module RailsTestHelper # :nodoc: all
159
+ def compare_result
160
+ ActionView::Base.register_template_handler "a2html", Amrita2View::Base
161
+ amrita2_result = yield
162
+ ActionView::Base.unregister_template_handler "a2html"
163
+ erb_result = yield
164
+ assert_equal_as_xml(erb_result, amrita2_result)
165
+ #assert_dom_equal(amrita2_result, erb_result)
166
+ end
167
+ end
168
+ end
169
+
170
+ end
171
+
@@ -2,7 +2,7 @@ module Amrita2
2
2
  module Version
3
3
  MAJOR=2
4
4
  MINOR=0
5
- TINY=1
5
+ TINY=2
6
6
 
7
7
  STRING=[MAJOR,MINOR,TINY].join('.')
8
8
  end
@@ -0,0 +1,160 @@
1
+ == Welcome to Rails
2
+
3
+ Rails is a web-application and persistence framework that includes everything
4
+ needed to create database-backed web-applications according to the
5
+ Model-View-Control pattern of separation. This pattern splits the view (also
6
+ called the presentation) into "dumb" templates that are primarily responsible
7
+ for inserting pre-built data in between HTML tags. The model contains the
8
+ "smart" domain objects (such as Account, Product, Person, Post) that holds all
9
+ the business logic and knows how to persist themselves to a database. The
10
+ controller handles the incoming requests (such as Save New Account, Update
11
+ Product, Show Post) by manipulating the model and directing data to the view.
12
+
13
+ In Rails, the model is handled by what's called an object-relational mapping
14
+ layer entitled Active Record. This layer allows you to present the data from
15
+ database rows as objects and embellish these data objects with business logic
16
+ methods. You can read more about Active Record in
17
+ link:files/vendor/rails/activerecord/README.html.
18
+
19
+ The controller and view are handled by the Action Pack, which handles both
20
+ layers by its two parts: Action View and Action Controller. These two layers
21
+ are bundled in a single package due to their heavy interdependence. This is
22
+ unlike the relationship between the Active Record and Action Pack that is much
23
+ more separate. Each of these packages can be used independently outside of
24
+ Rails. You can read more about Action Pack in
25
+ link:files/vendor/rails/actionpack/README.html.
26
+
27
+
28
+ == Getting started
29
+
30
+ 1. Run the WEBrick servlet: <tt>ruby script/server</tt> (run with --help for options)
31
+ ...or if you have lighttpd installed: <tt>ruby script/lighttpd</tt> (it's faster)
32
+ 2. Go to http://localhost:3000/ and get "Congratulations, you've put Ruby on Rails!"
33
+ 3. Follow the guidelines on the "Congratulations, you've put Ruby on Rails!" screen
34
+
35
+
36
+ == Example for Apache conf
37
+
38
+ <VirtualHost *:80>
39
+ ServerName rails
40
+ DocumentRoot /path/application/public/
41
+ ErrorLog /path/application/log/server.log
42
+
43
+ <Directory /path/application/public/>
44
+ Options ExecCGI FollowSymLinks
45
+ AllowOverride all
46
+ Allow from all
47
+ Order allow,deny
48
+ </Directory>
49
+ </VirtualHost>
50
+
51
+ NOTE: Be sure that CGIs can be executed in that directory as well. So ExecCGI
52
+ should be on and ".cgi" should respond. All requests from 127.0.0.1 go
53
+ through CGI, so no Apache restart is necessary for changes. All other requests
54
+ go through FCGI (or mod_ruby), which requires a restart to show changes.
55
+
56
+
57
+ == Debugging Rails
58
+
59
+ Have "tail -f" commands running on both the server.log, production.log, and
60
+ test.log files. Rails will automatically display debugging and runtime
61
+ information to these files. Debugging info will also be shown in the browser
62
+ on requests from 127.0.0.1.
63
+
64
+
65
+ == Breakpoints
66
+
67
+ Breakpoint support is available through the script/breakpointer client. This
68
+ means that you can break out of execution at any point in the code, investigate
69
+ and change the model, AND then resume execution! Example:
70
+
71
+ class WeblogController < ActionController::Base
72
+ def index
73
+ @posts = Post.find_all
74
+ breakpoint "Breaking out from the list"
75
+ end
76
+ end
77
+
78
+ So the controller will accept the action, run the first line, then present you
79
+ with a IRB prompt in the breakpointer window. Here you can do things like:
80
+
81
+ Executing breakpoint "Breaking out from the list" at .../webrick_server.rb:16 in 'breakpoint'
82
+
83
+ >> @posts.inspect
84
+ => "[#<Post:0x14a6be8 @attributes={\"title\"=>nil, \"body\"=>nil, \"id\"=>\"1\"}>,
85
+ #<Post:0x14a6620 @attributes={\"title\"=>\"Rails you know!\", \"body\"=>\"Only ten..\", \"id\"=>\"2\"}>]"
86
+ >> @posts.first.title = "hello from a breakpoint"
87
+ => "hello from a breakpoint"
88
+
89
+ ...and even better is that you can examine how your runtime objects actually work:
90
+
91
+ >> f = @posts.first
92
+ => #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
93
+ >> f.
94
+ Display all 152 possibilities? (y or n)
95
+
96
+ Finally, when you're ready to resume execution, you press CTRL-D
97
+
98
+
99
+ == Console
100
+
101
+ You can interact with the domain model by starting the console through script/console.
102
+ Here you'll have all parts of the application configured, just like it is when the
103
+ application is running. You can inspect domain models, change values, and save to the
104
+ database. Starting the script without arguments will launch it in the development environment.
105
+ Passing an argument will specify a different environment, like <tt>console production</tt>.
106
+
107
+
108
+ == Description of contents
109
+
110
+ app
111
+ Holds all the code that's specific to this particular application.
112
+
113
+ app/controllers
114
+ Holds controllers that should be named like weblog_controller.rb for
115
+ automated URL mapping. All controllers should descend from
116
+ ActionController::Base.
117
+
118
+ app/models
119
+ Holds models that should be named like post.rb.
120
+ Most models will descend from ActiveRecord::Base.
121
+
122
+ app/views
123
+ Holds the template files for the view that should be named like
124
+ weblog/index.rhtml for the WeblogController#index action. All views use eRuby
125
+ syntax. This directory can also be used to keep stylesheets, images, and so on
126
+ that can be symlinked to public.
127
+
128
+ app/helpers
129
+ Holds view helpers that should be named like weblog_helper.rb.
130
+
131
+ app/apis
132
+ Holds API classes for web services.
133
+
134
+ config
135
+ Configuration files for the Rails environment, the routing map, the database, and other dependencies.
136
+
137
+ components
138
+ Self-contained mini-applications that can bundle together controllers, models, and views.
139
+
140
+ db
141
+ Contains the SQL dump of your development database. db/migrate contains all
142
+ the sequence of Migrations for your schema.
143
+
144
+ lib
145
+ Application specific libraries. Basically, any kind of custom code that doesn't
146
+ belong under controllers, models, or helpers. This directory is in the load path.
147
+
148
+ public
149
+ The directory available for the web server. Contains subdirectories for images, stylesheets,
150
+ and javascripts. Also contains the dispatchers and the default HTML files.
151
+
152
+ script
153
+ Helper scripts for automation and generation.
154
+
155
+ test
156
+ Unit and functional tests along with fixtures.
157
+
158
+ vendor
159
+ External libraries that the application depends on. Also includes the plugins subdirectory.
160
+ This directory is in the load path.
@@ -0,0 +1,10 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/switchtower.rake, and they will automatically be available to Rake.
3
+
4
+ require(File.join(File.dirname(__FILE__), 'config', 'boot'))
5
+
6
+ require 'rake'
7
+ require 'rake/testtask'
8
+ require 'rake/rdoctask'
9
+
10
+ require 'tasks/rails'