hashbrowns 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. data/.document +5 -0
  2. data/.rvmrc +1 -0
  3. data/Gemfile +17 -0
  4. data/Gemfile.lock +79 -0
  5. data/LICENSE.txt +20 -0
  6. data/README.md +9 -0
  7. data/Rakefile +53 -0
  8. data/TODO +17 -0
  9. data/VERSION +1 -0
  10. data/example/.gitignore +15 -0
  11. data/example/.rvmrc +1 -0
  12. data/example/Gemfile +45 -0
  13. data/example/Gemfile.lock +143 -0
  14. data/example/README.rdoc +261 -0
  15. data/example/Rakefile +7 -0
  16. data/example/app/assets/images/rails.png +0 -0
  17. data/example/app/assets/javascripts/application.js +16 -0
  18. data/example/app/assets/javascripts/customers.js.coffee +3 -0
  19. data/example/app/assets/javascripts/destinations.js.coffee +3 -0
  20. data/example/app/assets/javascripts/orders.js.coffee +3 -0
  21. data/example/app/assets/stylesheets/application.css.scss +25 -0
  22. data/example/app/assets/stylesheets/bootstrap_and_overrides.css.scss +3 -0
  23. data/example/app/assets/stylesheets/customers.css.scss +3 -0
  24. data/example/app/assets/stylesheets/destinations.css.scss +3 -0
  25. data/example/app/assets/stylesheets/orders.css.scss +3 -0
  26. data/example/app/assets/stylesheets/scaffolds.css.scss +69 -0
  27. data/example/app/controllers/application_controller.rb +3 -0
  28. data/example/app/controllers/customers_controller.rb +90 -0
  29. data/example/app/controllers/destinations_controller.rb +89 -0
  30. data/example/app/controllers/orders_controller.rb +88 -0
  31. data/example/app/helpers/application_helper.rb +2 -0
  32. data/example/app/helpers/customers_helper.rb +2 -0
  33. data/example/app/helpers/destinations_helper.rb +2 -0
  34. data/example/app/helpers/orders_helper.rb +2 -0
  35. data/example/app/mailers/.gitkeep +0 -0
  36. data/example/app/models/.gitkeep +0 -0
  37. data/example/app/models/customer.rb +5 -0
  38. data/example/app/models/destination.rb +4 -0
  39. data/example/app/models/order.rb +5 -0
  40. data/example/app/views/customers/_form.html.erb +33 -0
  41. data/example/app/views/customers/edit.html.erb +6 -0
  42. data/example/app/views/customers/full.rabl +2 -0
  43. data/example/app/views/customers/index.html.erb +10 -0
  44. data/example/app/views/customers/index.rabl +5 -0
  45. data/example/app/views/customers/new.html.erb +5 -0
  46. data/example/app/views/customers/show.html.erb +25 -0
  47. data/example/app/views/customers/show.rabl +5 -0
  48. data/example/app/views/destinations/_form.html.erb +41 -0
  49. data/example/app/views/destinations/edit.html.erb +6 -0
  50. data/example/app/views/destinations/full.rabl +2 -0
  51. data/example/app/views/destinations/index.html.erb +10 -0
  52. data/example/app/views/destinations/index.rabl +5 -0
  53. data/example/app/views/destinations/new.html.erb +5 -0
  54. data/example/app/views/destinations/show.html.erb +35 -0
  55. data/example/app/views/destinations/show.rabl +5 -0
  56. data/example/app/views/layouts/application.html.erb +14 -0
  57. data/example/app/views/orders/_form.html.erb +29 -0
  58. data/example/app/views/orders/edit.html.erb +6 -0
  59. data/example/app/views/orders/full.rabl +2 -0
  60. data/example/app/views/orders/index.html.erb +10 -0
  61. data/example/app/views/orders/index.rabl +5 -0
  62. data/example/app/views/orders/new.html.erb +5 -0
  63. data/example/app/views/orders/show.html.erb +20 -0
  64. data/example/app/views/orders/show.rabl +8 -0
  65. data/example/config/application.rb +62 -0
  66. data/example/config/boot.rb +6 -0
  67. data/example/config/database.yml +20 -0
  68. data/example/config/environment.rb +5 -0
  69. data/example/config/environments/development.rb +37 -0
  70. data/example/config/environments/production.rb +67 -0
  71. data/example/config/environments/test.rb +37 -0
  72. data/example/config/initializers/backtrace_silencers.rb +7 -0
  73. data/example/config/initializers/hashbrowns.rb +34 -0
  74. data/example/config/initializers/inflections.rb +15 -0
  75. data/example/config/initializers/mime_types.rb +5 -0
  76. data/example/config/initializers/secret_token.rb +7 -0
  77. data/example/config/initializers/session_store.rb +8 -0
  78. data/example/config/initializers/wrap_parameters.rb +14 -0
  79. data/example/config/locales/en.yml +5 -0
  80. data/example/config/routes.rb +64 -0
  81. data/example/config.ru +4 -0
  82. data/example/db/migrate/20121102164922_create_customers.rb +12 -0
  83. data/example/db/migrate/20121102165116_create_orders.rb +12 -0
  84. data/example/db/migrate/20121102165208_create_destinations.rb +15 -0
  85. data/example/db/schema.rb +45 -0
  86. data/example/db/seeds.rb +51 -0
  87. data/example/lib/assets/.gitkeep +0 -0
  88. data/example/lib/tasks/.gitkeep +0 -0
  89. data/example/log/.gitkeep +0 -0
  90. data/example/public/404.html +26 -0
  91. data/example/public/422.html +26 -0
  92. data/example/public/500.html +25 -0
  93. data/example/public/favicon.ico +0 -0
  94. data/example/public/index.html +241 -0
  95. data/example/public/robots.txt +5 -0
  96. data/example/script/rails +6 -0
  97. data/example/test/fixtures/.gitkeep +0 -0
  98. data/example/test/fixtures/customers.yml +13 -0
  99. data/example/test/fixtures/destinations.yml +17 -0
  100. data/example/test/fixtures/orders.yml +11 -0
  101. data/example/test/functional/.gitkeep +0 -0
  102. data/example/test/functional/customers_controller_test.rb +49 -0
  103. data/example/test/functional/destinations_controller_test.rb +49 -0
  104. data/example/test/functional/orders_controller_test.rb +49 -0
  105. data/example/test/integration/.gitkeep +0 -0
  106. data/example/test/performance/browsing_test.rb +12 -0
  107. data/example/test/test_helper.rb +13 -0
  108. data/example/test/unit/.gitkeep +0 -0
  109. data/example/test/unit/customer_test.rb +7 -0
  110. data/example/test/unit/destination_test.rb +7 -0
  111. data/example/test/unit/helpers/customers_helper_test.rb +4 -0
  112. data/example/test/unit/helpers/destinations_helper_test.rb +4 -0
  113. data/example/test/unit/helpers/orders_helper_test.rb +4 -0
  114. data/example/test/unit/order_test.rb +7 -0
  115. data/example/vendor/assets/javascripts/.gitkeep +0 -0
  116. data/example/vendor/assets/stylesheets/.gitkeep +0 -0
  117. data/example/vendor/plugins/.gitkeep +0 -0
  118. data/hashbrowns.gemspec +185 -0
  119. data/lib/hashbrowns/configuration.rb +129 -0
  120. data/lib/hashbrowns/helpers/display_helpers.rb +27 -0
  121. data/lib/hashbrowns/helpers/links_helpers.rb +24 -0
  122. data/lib/hashbrowns/helpers/overview_helpers.rb +20 -0
  123. data/lib/hashbrowns/helpers/relations_helpers.rb +9 -0
  124. data/lib/hashbrowns/helpers/renderer_helpers.rb +12 -0
  125. data/lib/hashbrowns/railtie.rb +17 -0
  126. data/lib/hashbrowns/views/hashbrowns/_overview.html.haml +20 -0
  127. data/lib/hashbrowns/views/hashbrowns/_recursive_hash_tabler.html.haml +27 -0
  128. data/lib/hashbrowns.rb +16 -0
  129. data/test/helper.rb +18 -0
  130. data/test/test_hash_tabler.rb +7 -0
  131. metadata +249 -0
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm --create use jruby-1.6.5@hashbrowns
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "shoulda"
10
+ gem "rdoc"
11
+ gem "bundler"
12
+ gem "jeweler"
13
+ #gem "rcov"
14
+ end
15
+
16
+ gem "haml-rails"
17
+ gem 'rake', '0.8.7'
data/Gemfile.lock ADDED
@@ -0,0 +1,79 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ actionpack (3.2.9)
5
+ activemodel (= 3.2.9)
6
+ activesupport (= 3.2.9)
7
+ builder (~> 3.0.0)
8
+ erubis (~> 2.7.0)
9
+ journey (~> 1.0.4)
10
+ rack (~> 1.4.0)
11
+ rack-cache (~> 1.2)
12
+ rack-test (~> 0.6.1)
13
+ sprockets (~> 2.2.1)
14
+ activemodel (3.2.9)
15
+ activesupport (= 3.2.9)
16
+ builder (~> 3.0.0)
17
+ activesupport (3.2.9)
18
+ i18n (~> 0.6)
19
+ multi_json (~> 1.0)
20
+ builder (3.0.4)
21
+ erubis (2.7.0)
22
+ git (1.2.5)
23
+ haml (3.1.7)
24
+ haml-rails (0.3.5)
25
+ actionpack (>= 3.1, < 4.1)
26
+ activesupport (>= 3.1, < 4.1)
27
+ haml (~> 3.1)
28
+ railties (>= 3.1, < 4.1)
29
+ hike (1.2.1)
30
+ i18n (0.6.1)
31
+ jeweler (1.8.4)
32
+ bundler (~> 1.0)
33
+ git (>= 1.2.5)
34
+ rake
35
+ rdoc
36
+ journey (1.0.4)
37
+ json (1.7.5)
38
+ multi_json (1.3.7)
39
+ rack (1.4.1)
40
+ rack-cache (1.2)
41
+ rack (>= 0.4)
42
+ rack-ssl (1.3.2)
43
+ rack
44
+ rack-test (0.6.2)
45
+ rack (>= 1.0)
46
+ railties (3.2.9)
47
+ actionpack (= 3.2.9)
48
+ activesupport (= 3.2.9)
49
+ rack-ssl (~> 1.3.2)
50
+ rake (>= 0.8.7)
51
+ rdoc (~> 3.4)
52
+ thor (>= 0.14.6, < 2.0)
53
+ rake (0.8.7)
54
+ rdoc (3.12)
55
+ json (~> 1.4)
56
+ shoulda (3.3.2)
57
+ shoulda-context (~> 1.0.1)
58
+ shoulda-matchers (~> 1.4.1)
59
+ shoulda-context (1.0.1)
60
+ shoulda-matchers (1.4.1)
61
+ activesupport (>= 3.0.0)
62
+ sprockets (2.2.1)
63
+ hike (~> 1.2)
64
+ multi_json (~> 1.0)
65
+ rack (~> 1.0)
66
+ tilt (~> 1.1, != 1.3.0)
67
+ thor (0.16.0)
68
+ tilt (1.3.3)
69
+
70
+ PLATFORMS
71
+ ruby
72
+
73
+ DEPENDENCIES
74
+ bundler
75
+ haml-rails
76
+ jeweler
77
+ rake (= 0.8.7)
78
+ rdoc
79
+ shoulda
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 crimsonknave
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,9 @@
1
+ Hashbrowns
2
+ ===========
3
+
4
+ Cooks your hashes into html!
5
+
6
+ Provides tools for simply converting hashes into html that is easy to read.
7
+
8
+
9
+ This is a work in progress, it may work and may be radically redesigned under you should you use it.
data/Rakefile ADDED
@@ -0,0 +1,53 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "hashbrowns"
18
+ gem.homepage = "http://github.com/crimsonknave/hashbrowns"
19
+ gem.license = "MIT"
20
+ gem.summary = "Cooks your hashes into html"
21
+ gem.description = "Provides a DSL and helpers to convert hashes into html tables. Allows you to create overviews with selected fields, define keys whose values link to a url and so on."
22
+ gem.email = "crimsonknave@gmail.com"
23
+ gem.authors = ["crimsonknave"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rake/testtask'
29
+ Rake::TestTask.new(:test) do |test|
30
+ test.libs << 'lib' << 'test'
31
+ test.pattern = 'test/**/test_*.rb'
32
+ test.verbose = true
33
+ end
34
+
35
+ #require 'rcov/rcovtask'
36
+ #Rcov::RcovTask.new do |test|
37
+ #test.libs << 'test'
38
+ #test.pattern = 'test/**/test_*.rb'
39
+ #test.verbose = true
40
+ #test.rcov_opts << '--exclude "gems/*"'
41
+ #end
42
+
43
+ task :default => :test
44
+
45
+ require 'rdoc/task'
46
+ Rake::RDocTask.new do |rdoc|
47
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
48
+
49
+ rdoc.rdoc_dir = 'rdoc'
50
+ rdoc.title = "hashbrowns #{version}"
51
+ rdoc.rdoc_files.include('README*')
52
+ rdoc.rdoc_files.include('lib/**/*.rb')
53
+ end
data/TODO ADDED
@@ -0,0 +1,17 @@
1
+ TESTS!
2
+
3
+ Determine string/symbol stragegy
4
+
5
+ Fix initialization so that it isn't on app startup.
6
+ Ideally this would not require a restart for new settings.
7
+ Determine best place to call add_foo functions.
8
+
9
+ Engine isn't a railtie anymore, rename it
10
+
11
+ Finish example code
12
+ views
13
+ controllers
14
+ tests?
15
+ two or three more tables
16
+ more fields to tables
17
+ more records in db
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.3
@@ -0,0 +1,15 @@
1
+ # See http://help.github.com/ignore-files/ for more about ignoring files.
2
+ #
3
+ # If you find yourself ignoring temporary files generated by your text editor
4
+ # or operating system, you probably want to add a global ignore instead:
5
+ # git config --global core.excludesfile ~/.gitignore_global
6
+
7
+ # Ignore bundler config
8
+ /.bundle
9
+
10
+ # Ignore the default SQLite database.
11
+ /db/*.sqlite3
12
+
13
+ # Ignore all logfiles and tempfiles.
14
+ /log/*.log
15
+ /tmp
data/example/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm --create use jruby-1.6.5@hashbrowns_example
data/example/Gemfile ADDED
@@ -0,0 +1,45 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rails', '3.2.8'
4
+
5
+ # Bundle edge Rails instead:
6
+ # gem 'rails', :git => 'git://github.com/rails/rails.git'
7
+
8
+ gem 'activerecord-jdbcsqlite3-adapter'
9
+
10
+ gem 'jruby-openssl'
11
+ gem 'json'
12
+
13
+ gem 'rabl'
14
+
15
+ gem 'hashbrowns', :path => '../'
16
+ gem 'bootstrap-sass'
17
+
18
+ # Gems used only for assets and not required
19
+ # in production environments by default.
20
+ group :assets do
21
+ gem 'sass-rails', '~> 3.2.3'
22
+ gem 'coffee-rails', '~> 3.2.1'
23
+
24
+ # See https://github.com/sstephenson/execjs#readme for more supported runtimes
25
+ gem 'therubyrhino'
26
+
27
+ gem 'uglifier', '>= 1.0.3'
28
+ end
29
+
30
+ gem 'jquery-rails'
31
+
32
+ # To use ActiveModel has_secure_password
33
+ # gem 'bcrypt-ruby', '~> 3.0.0'
34
+
35
+ # To use Jbuilder templates for JSON
36
+ # gem 'jbuilder'
37
+
38
+ # Use unicorn as the app server
39
+ # gem 'unicorn'
40
+
41
+ # Deploy with Capistrano
42
+ # gem 'capistrano'
43
+
44
+ # To use debugger
45
+ # gem 'ruby-debug'
@@ -0,0 +1,143 @@
1
+ PATH
2
+ remote: ../
3
+ specs:
4
+ hashbrowns (0.1.0)
5
+ haml-rails
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actionmailer (3.2.8)
11
+ actionpack (= 3.2.8)
12
+ mail (~> 2.4.4)
13
+ actionpack (3.2.8)
14
+ activemodel (= 3.2.8)
15
+ activesupport (= 3.2.8)
16
+ builder (~> 3.0.0)
17
+ erubis (~> 2.7.0)
18
+ journey (~> 1.0.4)
19
+ rack (~> 1.4.0)
20
+ rack-cache (~> 1.2)
21
+ rack-test (~> 0.6.1)
22
+ sprockets (~> 2.1.3)
23
+ activemodel (3.2.8)
24
+ activesupport (= 3.2.8)
25
+ builder (~> 3.0.0)
26
+ activerecord (3.2.8)
27
+ activemodel (= 3.2.8)
28
+ activesupport (= 3.2.8)
29
+ arel (~> 3.0.2)
30
+ tzinfo (~> 0.3.29)
31
+ activerecord-jdbc-adapter (1.2.2.1)
32
+ activerecord-jdbcsqlite3-adapter (1.2.2.1)
33
+ activerecord-jdbc-adapter (~> 1.2.2.1)
34
+ jdbc-sqlite3 (~> 3.7.2)
35
+ activeresource (3.2.8)
36
+ activemodel (= 3.2.8)
37
+ activesupport (= 3.2.8)
38
+ activesupport (3.2.8)
39
+ i18n (~> 0.6)
40
+ multi_json (~> 1.0)
41
+ arel (3.0.2)
42
+ bootstrap-sass (2.1.1.0)
43
+ bouncy-castle-java (1.5.0146.1)
44
+ builder (3.0.4)
45
+ coffee-rails (3.2.2)
46
+ coffee-script (>= 2.2.0)
47
+ railties (~> 3.2.0)
48
+ coffee-script (2.2.0)
49
+ coffee-script-source
50
+ execjs
51
+ coffee-script-source (1.4.0)
52
+ erubis (2.7.0)
53
+ execjs (1.4.0)
54
+ multi_json (~> 1.0)
55
+ haml (3.1.7)
56
+ haml-rails (0.3.5)
57
+ actionpack (>= 3.1, < 4.1)
58
+ activesupport (>= 3.1, < 4.1)
59
+ haml (~> 3.1)
60
+ railties (>= 3.1, < 4.1)
61
+ hike (1.2.1)
62
+ i18n (0.6.1)
63
+ jdbc-sqlite3 (3.7.2)
64
+ journey (1.0.4)
65
+ jquery-rails (2.1.3)
66
+ railties (>= 3.1.0, < 5.0)
67
+ thor (~> 0.14)
68
+ jruby-openssl (0.7.7)
69
+ bouncy-castle-java (>= 1.5.0146.1)
70
+ json (1.7.5-java)
71
+ mail (2.4.4)
72
+ i18n (>= 0.4.0)
73
+ mime-types (~> 1.16)
74
+ treetop (~> 1.4.8)
75
+ mime-types (1.19)
76
+ multi_json (1.3.6)
77
+ polyglot (0.3.3)
78
+ rabl (0.7.6)
79
+ activesupport (>= 2.3.14)
80
+ multi_json (~> 1.0)
81
+ rack (1.4.1)
82
+ rack-cache (1.2)
83
+ rack (>= 0.4)
84
+ rack-ssl (1.3.2)
85
+ rack
86
+ rack-test (0.6.2)
87
+ rack (>= 1.0)
88
+ rails (3.2.8)
89
+ actionmailer (= 3.2.8)
90
+ actionpack (= 3.2.8)
91
+ activerecord (= 3.2.8)
92
+ activeresource (= 3.2.8)
93
+ activesupport (= 3.2.8)
94
+ bundler (~> 1.0)
95
+ railties (= 3.2.8)
96
+ railties (3.2.8)
97
+ actionpack (= 3.2.8)
98
+ activesupport (= 3.2.8)
99
+ rack-ssl (~> 1.3.2)
100
+ rake (>= 0.8.7)
101
+ rdoc (~> 3.4)
102
+ thor (>= 0.14.6, < 2.0)
103
+ rake (0.9.2.2)
104
+ rdoc (3.12)
105
+ json (~> 1.4)
106
+ sass (3.2.1)
107
+ sass-rails (3.2.5)
108
+ railties (~> 3.2.0)
109
+ sass (>= 3.1.10)
110
+ tilt (~> 1.3)
111
+ sprockets (2.1.3)
112
+ hike (~> 1.2)
113
+ rack (~> 1.0)
114
+ tilt (~> 1.1, != 1.3.0)
115
+ therubyrhino (2.0.1)
116
+ therubyrhino_jar (>= 1.7.3)
117
+ therubyrhino_jar (1.7.4)
118
+ thor (0.16.0)
119
+ tilt (1.3.3)
120
+ treetop (1.4.12)
121
+ polyglot
122
+ polyglot (>= 0.3.1)
123
+ tzinfo (0.3.34)
124
+ uglifier (1.3.0)
125
+ execjs (>= 0.3.0)
126
+ multi_json (~> 1.0, >= 1.0.2)
127
+
128
+ PLATFORMS
129
+ java
130
+
131
+ DEPENDENCIES
132
+ activerecord-jdbcsqlite3-adapter
133
+ bootstrap-sass
134
+ coffee-rails (~> 3.2.1)
135
+ hashbrowns!
136
+ jquery-rails
137
+ jruby-openssl
138
+ json
139
+ rabl
140
+ rails (= 3.2.8)
141
+ sass-rails (~> 3.2.3)
142
+ therubyrhino
143
+ uglifier (>= 1.0.3)
@@ -0,0 +1,261 @@
1
+ == Welcome to Rails
2
+
3
+ Rails is a web-application framework that includes everything needed to create
4
+ database-backed web applications according to the Model-View-Control pattern.
5
+
6
+ This pattern splits the view (also called the presentation) into "dumb"
7
+ templates that are primarily responsible for inserting pre-built data in between
8
+ HTML tags. The model contains the "smart" domain objects (such as Account,
9
+ Product, Person, Post) that holds all the business logic and knows how to
10
+ persist themselves to a database. The controller handles the incoming requests
11
+ (such as Save New Account, Update Product, Show Post) by manipulating the model
12
+ and directing data to the view.
13
+
14
+ In Rails, the model is handled by what's called an object-relational mapping
15
+ layer entitled Active Record. This layer allows you to present the data from
16
+ database rows as objects and embellish these data objects with business logic
17
+ methods. You can read more about Active Record in
18
+ link:files/vendor/rails/activerecord/README.html.
19
+
20
+ The controller and view are handled by the Action Pack, which handles both
21
+ layers by its two parts: Action View and Action Controller. These two layers
22
+ are bundled in a single package due to their heavy interdependence. This is
23
+ unlike the relationship between the Active Record and Action Pack that is much
24
+ more separate. Each of these packages can be used independently outside of
25
+ Rails. You can read more about Action Pack in
26
+ link:files/vendor/rails/actionpack/README.html.
27
+
28
+
29
+ == Getting Started
30
+
31
+ 1. At the command prompt, create a new Rails application:
32
+ <tt>rails new myapp</tt> (where <tt>myapp</tt> is the application name)
33
+
34
+ 2. Change directory to <tt>myapp</tt> and start the web server:
35
+ <tt>cd myapp; rails server</tt> (run with --help for options)
36
+
37
+ 3. Go to http://localhost:3000/ and you'll see:
38
+ "Welcome aboard: You're riding Ruby on Rails!"
39
+
40
+ 4. Follow the guidelines to start developing your application. You can find
41
+ the following resources handy:
42
+
43
+ * The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html
44
+ * Ruby on Rails Tutorial Book: http://www.railstutorial.org/
45
+
46
+
47
+ == Debugging Rails
48
+
49
+ Sometimes your application goes wrong. Fortunately there are a lot of tools that
50
+ will help you debug it and get it back on the rails.
51
+
52
+ First area to check is the application log files. Have "tail -f" commands
53
+ running on the server.log and development.log. Rails will automatically display
54
+ debugging and runtime information to these files. Debugging info will also be
55
+ shown in the browser on requests from 127.0.0.1.
56
+
57
+ You can also log your own messages directly into the log file from your code
58
+ using the Ruby logger class from inside your controllers. Example:
59
+
60
+ class WeblogController < ActionController::Base
61
+ def destroy
62
+ @weblog = Weblog.find(params[:id])
63
+ @weblog.destroy
64
+ logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
65
+ end
66
+ end
67
+
68
+ The result will be a message in your log file along the lines of:
69
+
70
+ Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1!
71
+
72
+ More information on how to use the logger is at http://www.ruby-doc.org/core/
73
+
74
+ Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are
75
+ several books available online as well:
76
+
77
+ * Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe)
78
+ * Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
79
+
80
+ These two books will bring you up to speed on the Ruby language and also on
81
+ programming in general.
82
+
83
+
84
+ == Debugger
85
+
86
+ Debugger support is available through the debugger command when you start your
87
+ Mongrel or WEBrick server with --debugger. This means that you can break out of
88
+ execution at any point in the code, investigate and change the model, and then,
89
+ resume execution! You need to install ruby-debug to run the server in debugging
90
+ mode. With gems, use <tt>sudo gem install ruby-debug</tt>. Example:
91
+
92
+ class WeblogController < ActionController::Base
93
+ def index
94
+ @posts = Post.all
95
+ debugger
96
+ end
97
+ end
98
+
99
+ So the controller will accept the action, run the first line, then present you
100
+ with a IRB prompt in the server window. Here you can do things like:
101
+
102
+ >> @posts.inspect
103
+ => "[#<Post:0x14a6be8
104
+ @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>,
105
+ #<Post:0x14a6620
106
+ @attributes={"title"=>"Rails", "body"=>"Only ten..", "id"=>"2"}>]"
107
+ >> @posts.first.title = "hello from a debugger"
108
+ => "hello from a debugger"
109
+
110
+ ...and even better, you can examine how your runtime objects actually work:
111
+
112
+ >> f = @posts.first
113
+ => #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
114
+ >> f.
115
+ Display all 152 possibilities? (y or n)
116
+
117
+ Finally, when you're ready to resume execution, you can enter "cont".
118
+
119
+
120
+ == Console
121
+
122
+ The console is a Ruby shell, which allows you to interact with your
123
+ application's domain model. Here you'll have all parts of the application
124
+ configured, just like it is when the application is running. You can inspect
125
+ domain models, change values, and save to the database. Starting the script
126
+ without arguments will launch it in the development environment.
127
+
128
+ To start the console, run <tt>rails console</tt> from the application
129
+ directory.
130
+
131
+ Options:
132
+
133
+ * Passing the <tt>-s, --sandbox</tt> argument will rollback any modifications
134
+ made to the database.
135
+ * Passing an environment name as an argument will load the corresponding
136
+ environment. Example: <tt>rails console production</tt>.
137
+
138
+ To reload your controllers and models after launching the console run
139
+ <tt>reload!</tt>
140
+
141
+ More information about irb can be found at:
142
+ link:http://www.rubycentral.org/pickaxe/irb.html
143
+
144
+
145
+ == dbconsole
146
+
147
+ You can go to the command line of your database directly through <tt>rails
148
+ dbconsole</tt>. You would be connected to the database with the credentials
149
+ defined in database.yml. Starting the script without arguments will connect you
150
+ to the development database. Passing an argument will connect you to a different
151
+ database, like <tt>rails dbconsole production</tt>. Currently works for MySQL,
152
+ PostgreSQL and SQLite 3.
153
+
154
+ == Description of Contents
155
+
156
+ The default directory structure of a generated Ruby on Rails application:
157
+
158
+ |-- app
159
+ | |-- assets
160
+ | |-- images
161
+ | |-- javascripts
162
+ | `-- stylesheets
163
+ | |-- controllers
164
+ | |-- helpers
165
+ | |-- mailers
166
+ | |-- models
167
+ | `-- views
168
+ | `-- layouts
169
+ |-- config
170
+ | |-- environments
171
+ | |-- initializers
172
+ | `-- locales
173
+ |-- db
174
+ |-- doc
175
+ |-- lib
176
+ | `-- tasks
177
+ |-- log
178
+ |-- public
179
+ |-- script
180
+ |-- test
181
+ | |-- fixtures
182
+ | |-- functional
183
+ | |-- integration
184
+ | |-- performance
185
+ | `-- unit
186
+ |-- tmp
187
+ | |-- cache
188
+ | |-- pids
189
+ | |-- sessions
190
+ | `-- sockets
191
+ `-- vendor
192
+ |-- assets
193
+ `-- stylesheets
194
+ `-- plugins
195
+
196
+ app
197
+ Holds all the code that's specific to this particular application.
198
+
199
+ app/assets
200
+ Contains subdirectories for images, stylesheets, and JavaScript files.
201
+
202
+ app/controllers
203
+ Holds controllers that should be named like weblogs_controller.rb for
204
+ automated URL mapping. All controllers should descend from
205
+ ApplicationController which itself descends from ActionController::Base.
206
+
207
+ app/models
208
+ Holds models that should be named like post.rb. Models descend from
209
+ ActiveRecord::Base by default.
210
+
211
+ app/views
212
+ Holds the template files for the view that should be named like
213
+ weblogs/index.html.erb for the WeblogsController#index action. All views use
214
+ eRuby syntax by default.
215
+
216
+ app/views/layouts
217
+ Holds the template files for layouts to be used with views. This models the
218
+ common header/footer method of wrapping views. In your views, define a layout
219
+ using the <tt>layout :default</tt> and create a file named default.html.erb.
220
+ Inside default.html.erb, call <% yield %> to render the view using this
221
+ layout.
222
+
223
+ app/helpers
224
+ Holds view helpers that should be named like weblogs_helper.rb. These are
225
+ generated for you automatically when using generators for controllers.
226
+ Helpers can be used to wrap functionality for your views into methods.
227
+
228
+ config
229
+ Configuration files for the Rails environment, the routing map, the database,
230
+ and other dependencies.
231
+
232
+ db
233
+ Contains the database schema in schema.rb. db/migrate contains all the
234
+ sequence of Migrations for your schema.
235
+
236
+ doc
237
+ This directory is where your application documentation will be stored when
238
+ generated using <tt>rake doc:app</tt>
239
+
240
+ lib
241
+ Application specific libraries. Basically, any kind of custom code that
242
+ doesn't belong under controllers, models, or helpers. This directory is in
243
+ the load path.
244
+
245
+ public
246
+ The directory available for the web server. Also contains the dispatchers and the
247
+ default HTML files. This should be set as the DOCUMENT_ROOT of your web
248
+ server.
249
+
250
+ script
251
+ Helper scripts for automation and generation.
252
+
253
+ test
254
+ Unit and functional tests along with fixtures. When using the rails generate
255
+ command, template test files will be generated for you and placed in this
256
+ directory.
257
+
258
+ vendor
259
+ External libraries that the application depends on. Also includes the plugins
260
+ subdirectory. If the app has frozen rails, those gems also go here, under
261
+ vendor/rails/. This directory is in the load path.
data/example/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env rake
2
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
3
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
4
+
5
+ require File.expand_path('../config/application', __FILE__)
6
+
7
+ Example::Application.load_tasks
Binary file