ruby-activeldap 0.8.3 → 0.8.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (177) hide show
  1. data/CHANGES +431 -0
  2. data/COPYING +340 -0
  3. data/LICENSE +58 -0
  4. data/README +104 -0
  5. data/Rakefile +165 -0
  6. data/TODO +22 -0
  7. data/benchmark/bench-al.rb +202 -0
  8. data/benchmark/config.yaml.sample +5 -0
  9. data/data/locale/en/LC_MESSAGES/active-ldap.mo +0 -0
  10. data/data/locale/ja/LC_MESSAGES/active-ldap.mo +0 -0
  11. data/examples/al-admin/README +182 -0
  12. data/examples/al-admin/Rakefile +10 -0
  13. data/examples/al-admin/app/controllers/account_controller.rb +50 -0
  14. data/examples/al-admin/app/controllers/application.rb +15 -0
  15. data/examples/al-admin/app/controllers/directory_controller.rb +22 -0
  16. data/examples/al-admin/app/controllers/users_controller.rb +38 -0
  17. data/examples/al-admin/app/controllers/welcome_controller.rb +4 -0
  18. data/examples/al-admin/app/helpers/account_helper.rb +2 -0
  19. data/examples/al-admin/app/helpers/application_helper.rb +6 -0
  20. data/examples/al-admin/app/helpers/directory_helper.rb +2 -0
  21. data/examples/al-admin/app/helpers/users_helper.rb +13 -0
  22. data/examples/al-admin/app/helpers/welcome_helper.rb +2 -0
  23. data/examples/al-admin/app/models/entry.rb +19 -0
  24. data/examples/al-admin/app/models/ldap_user.rb +49 -0
  25. data/examples/al-admin/app/models/user.rb +91 -0
  26. data/examples/al-admin/app/views/account/login.rhtml +12 -0
  27. data/examples/al-admin/app/views/account/sign_up.rhtml +22 -0
  28. data/examples/al-admin/app/views/directory/index.rhtml +5 -0
  29. data/examples/al-admin/app/views/directory/populate.rhtml +2 -0
  30. data/examples/al-admin/app/views/layouts/application.rhtml +41 -0
  31. data/examples/al-admin/app/views/users/_attribute_information.rhtml +22 -0
  32. data/examples/al-admin/app/views/users/_entry.rhtml +12 -0
  33. data/examples/al-admin/app/views/users/_form.rhtml +29 -0
  34. data/examples/al-admin/app/views/users/_object_class_information.rhtml +23 -0
  35. data/examples/al-admin/app/views/users/edit.rhtml +10 -0
  36. data/examples/al-admin/app/views/users/index.rhtml +9 -0
  37. data/examples/al-admin/app/views/users/show.rhtml +3 -0
  38. data/examples/al-admin/app/views/welcome/index.rhtml +16 -0
  39. data/examples/al-admin/config/boot.rb +45 -0
  40. data/examples/al-admin/config/database.yml.example +19 -0
  41. data/examples/al-admin/config/environment.rb +68 -0
  42. data/examples/al-admin/config/environments/development.rb +21 -0
  43. data/examples/al-admin/config/environments/production.rb +18 -0
  44. data/examples/al-admin/config/environments/test.rb +19 -0
  45. data/examples/al-admin/config/ldap.yml.example +21 -0
  46. data/examples/al-admin/config/routes.rb +26 -0
  47. data/examples/al-admin/db/migrate/001_create_users.rb +16 -0
  48. data/examples/al-admin/lib/accept_http_rails_relative_url_root.rb +9 -0
  49. data/examples/al-admin/lib/authenticated_system.rb +131 -0
  50. data/examples/al-admin/lib/authenticated_test_helper.rb +113 -0
  51. data/examples/al-admin/lib/tasks/gettext.rake +35 -0
  52. data/examples/al-admin/po/en/al-admin.po +190 -0
  53. data/examples/al-admin/po/ja/al-admin.po +190 -0
  54. data/examples/al-admin/po/nl/al-admin.po +202 -0
  55. data/examples/al-admin/public/.htaccess +40 -0
  56. data/examples/al-admin/public/404.html +30 -0
  57. data/examples/al-admin/public/500.html +30 -0
  58. data/examples/al-admin/public/dispatch.cgi +10 -0
  59. data/examples/al-admin/public/dispatch.fcgi +24 -0
  60. data/examples/al-admin/public/dispatch.rb +10 -0
  61. data/examples/al-admin/public/favicon.ico +0 -0
  62. data/examples/al-admin/public/images/rails.png +0 -0
  63. data/examples/al-admin/public/javascripts/application.js +2 -0
  64. data/examples/al-admin/public/javascripts/controls.js +833 -0
  65. data/examples/al-admin/public/javascripts/dragdrop.js +942 -0
  66. data/examples/al-admin/public/javascripts/effects.js +1088 -0
  67. data/examples/al-admin/public/javascripts/prototype.js +2515 -0
  68. data/examples/al-admin/public/robots.txt +1 -0
  69. data/examples/al-admin/public/stylesheets/rails.css +35 -0
  70. data/examples/al-admin/public/stylesheets/screen.css +52 -0
  71. data/examples/al-admin/script/about +3 -0
  72. data/examples/al-admin/script/breakpointer +3 -0
  73. data/examples/al-admin/script/console +3 -0
  74. data/examples/al-admin/script/destroy +3 -0
  75. data/examples/al-admin/script/generate +3 -0
  76. data/examples/al-admin/script/performance/benchmarker +3 -0
  77. data/examples/al-admin/script/performance/profiler +3 -0
  78. data/examples/al-admin/script/plugin +3 -0
  79. data/examples/al-admin/script/process/inspector +3 -0
  80. data/examples/al-admin/script/process/reaper +3 -0
  81. data/examples/al-admin/script/process/spawner +3 -0
  82. data/examples/al-admin/script/runner +3 -0
  83. data/examples/al-admin/script/server +3 -0
  84. data/examples/al-admin/test/fixtures/users.yml +9 -0
  85. data/examples/al-admin/test/functional/account_controller_test.rb +24 -0
  86. data/examples/al-admin/test/functional/directory_controller_test.rb +18 -0
  87. data/examples/al-admin/test/functional/users_controller_test.rb +18 -0
  88. data/examples/al-admin/test/functional/welcome_controller_test.rb +18 -0
  89. data/examples/al-admin/test/run-test.sh +3 -0
  90. data/examples/al-admin/test/test_helper.rb +28 -0
  91. data/examples/al-admin/test/unit/user_test.rb +13 -0
  92. data/examples/al-admin/vendor/plugins/exception_notification/README +111 -0
  93. data/examples/al-admin/vendor/plugins/exception_notification/init.rb +1 -0
  94. data/examples/al-admin/vendor/plugins/exception_notification/lib/exception_notifiable.rb +99 -0
  95. data/examples/al-admin/vendor/plugins/exception_notification/lib/exception_notifier.rb +67 -0
  96. data/examples/al-admin/vendor/plugins/exception_notification/lib/exception_notifier_helper.rb +77 -0
  97. data/examples/al-admin/vendor/plugins/exception_notification/test/exception_notifier_helper_test.rb +61 -0
  98. data/examples/al-admin/vendor/plugins/exception_notification/test/test_helper.rb +7 -0
  99. data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/_backtrace.rhtml +1 -0
  100. data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/_environment.rhtml +7 -0
  101. data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/_inspect_model.rhtml +16 -0
  102. data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/_request.rhtml +3 -0
  103. data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/_session.rhtml +2 -0
  104. data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/_title.rhtml +3 -0
  105. data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/exception_notification.rhtml +6 -0
  106. data/examples/config.yaml.example +5 -0
  107. data/examples/example.der +0 -0
  108. data/examples/example.jpg +0 -0
  109. data/examples/groupadd +41 -0
  110. data/examples/groupdel +35 -0
  111. data/examples/groupls +49 -0
  112. data/examples/groupmod +42 -0
  113. data/examples/lpasswd +55 -0
  114. data/examples/objects/group.rb +13 -0
  115. data/examples/objects/ou.rb +4 -0
  116. data/examples/objects/user.rb +20 -0
  117. data/examples/ouadd +38 -0
  118. data/examples/useradd +45 -0
  119. data/examples/useradd-binary +50 -0
  120. data/examples/userdel +34 -0
  121. data/examples/userls +50 -0
  122. data/examples/usermod +42 -0
  123. data/examples/usermod-binary-add +47 -0
  124. data/examples/usermod-binary-add-time +51 -0
  125. data/examples/usermod-binary-del +48 -0
  126. data/examples/usermod-lang-add +43 -0
  127. data/lib/active_ldap.rb +978 -0
  128. data/lib/active_ldap/adapter/base.rb +512 -0
  129. data/lib/active_ldap/adapter/ldap.rb +233 -0
  130. data/lib/active_ldap/adapter/ldap_ext.rb +69 -0
  131. data/lib/active_ldap/adapter/net_ldap.rb +290 -0
  132. data/lib/active_ldap/adapter/net_ldap_ext.rb +29 -0
  133. data/lib/active_ldap/association/belongs_to.rb +47 -0
  134. data/lib/active_ldap/association/belongs_to_many.rb +42 -0
  135. data/lib/active_ldap/association/collection.rb +83 -0
  136. data/lib/active_ldap/association/has_many.rb +31 -0
  137. data/lib/active_ldap/association/has_many_utils.rb +35 -0
  138. data/lib/active_ldap/association/has_many_wrap.rb +46 -0
  139. data/lib/active_ldap/association/proxy.rb +102 -0
  140. data/lib/active_ldap/associations.rb +172 -0
  141. data/lib/active_ldap/attributes.rb +211 -0
  142. data/lib/active_ldap/base.rb +1256 -0
  143. data/lib/active_ldap/callbacks.rb +19 -0
  144. data/lib/active_ldap/command.rb +48 -0
  145. data/lib/active_ldap/configuration.rb +114 -0
  146. data/lib/active_ldap/connection.rb +234 -0
  147. data/lib/active_ldap/distinguished_name.rb +250 -0
  148. data/lib/active_ldap/escape.rb +12 -0
  149. data/lib/active_ldap/get_text/parser.rb +142 -0
  150. data/lib/active_ldap/get_text_fallback.rb +53 -0
  151. data/lib/active_ldap/get_text_support.rb +12 -0
  152. data/lib/active_ldap/helper.rb +23 -0
  153. data/lib/active_ldap/ldap_error.rb +74 -0
  154. data/lib/active_ldap/object_class.rb +93 -0
  155. data/lib/active_ldap/operations.rb +419 -0
  156. data/lib/active_ldap/populate.rb +44 -0
  157. data/lib/active_ldap/schema.rb +427 -0
  158. data/lib/active_ldap/timeout.rb +75 -0
  159. data/lib/active_ldap/timeout_stub.rb +17 -0
  160. data/lib/active_ldap/user_password.rb +93 -0
  161. data/lib/active_ldap/validations.rb +112 -0
  162. data/po/en/active-ldap.po +3011 -0
  163. data/po/ja/active-ldap.po +3044 -0
  164. data/rails/plugin/active_ldap/README +54 -0
  165. data/rails/plugin/active_ldap/generators/scaffold_al/scaffold_al_generator.rb +7 -0
  166. data/rails/plugin/active_ldap/generators/scaffold_al/templates/ldap.yml +21 -0
  167. data/rails/plugin/active_ldap/init.rb +19 -0
  168. data/test/al-test-utils.rb +362 -0
  169. data/test/command.rb +62 -0
  170. data/test/config.yaml.sample +6 -0
  171. data/test/run-test.rb +31 -0
  172. data/test/test-unit-ext.rb +4 -0
  173. data/test/test-unit-ext/always-show-result.rb +28 -0
  174. data/test/test-unit-ext/backtrace-filter.rb +17 -0
  175. data/test/test-unit-ext/long-display-for-emacs.rb +25 -0
  176. data/test/test-unit-ext/priority.rb +163 -0
  177. metadata +211 -4
@@ -0,0 +1,91 @@
1
+ require 'digest/sha1'
2
+
3
+ class User < ActiveRecord::Base
4
+ validates_presence_of :login
5
+ validates_presence_of :dn
6
+ validates_uniqueness_of :login, :dn, :case_sensitive => false
7
+ before_validation :generate_salt, :find_dn
8
+
9
+ class << self
10
+ def authenticate(login, password)
11
+ u = find_by_login(login) # need to get the salt
12
+ if u.nil?
13
+ u = new
14
+ u.login = login
15
+ u = nil unless u.save
16
+ end
17
+ u && u.authenticated?(password) ? u : nil
18
+ end
19
+
20
+ def encrypt(password, salt)
21
+ Digest::SHA1.hexdigest("--#{salt}--#{password}--")
22
+ end
23
+ end
24
+
25
+ def encrypt(password)
26
+ self.class.encrypt(password, salt)
27
+ end
28
+
29
+ def authenticated?(password)
30
+ return false if ldap_user.nil? or ldap_user.new_entry?
31
+ ldap_user.authenticated?(password)
32
+ end
33
+
34
+ def ldap_user
35
+ @ldap_user ||= LdapUser.find(dn)
36
+ rescue ActiveLdap::EntryNotFound
37
+ if dn
38
+ LdapUser.new(dn)
39
+ else
40
+ nil
41
+ end
42
+ end
43
+
44
+ def connected?
45
+ ldap_user.connected?
46
+ end
47
+
48
+ def remember_token?
49
+ begin
50
+ remember_token_expires_at and
51
+ Time.now.utc < remember_token_expires_at and
52
+ connected?
53
+ rescue ActiveLdap::EntryNotFound
54
+ false
55
+ end
56
+ end
57
+
58
+ # These create and unset the fields required for remembering users between browser closes
59
+ def remember_me
60
+ self.remember_token_expires_at = 2.weeks.from_now.utc
61
+ self.remember_token = encrypt("#{dn}--#{remember_token_expires_at}")
62
+ save(false)
63
+ end
64
+
65
+ def forget_me
66
+ self.remember_token_expires_at = nil
67
+ self.remember_token = nil
68
+ save(false)
69
+ LdapUser.remove_connection(dn) if dn
70
+ @ldap_user = nil
71
+ end
72
+
73
+ private
74
+ def generate_salt
75
+ return unless new_record?
76
+ self.salt = Digest::SHA1.hexdigest("--#{Time.now.to_s}--#{login}--")
77
+ end
78
+
79
+ def find_dn
80
+ if login.blank?
81
+ self.dn = nil
82
+ else
83
+ begin
84
+ ldap_user = LdapUser.find(login)
85
+ self.dn = ldap_user.dn
86
+ rescue ActiveLdap::EntryNotFound
87
+ self.dn = nil
88
+ end
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,12 @@
1
+ <% form_tag do -%>
2
+ <p><label for="login"><%= _("Login") %></label><br/>
3
+ <%= text_field_tag 'login' %></p>
4
+
5
+ <p><label for="password"><%= _("Password") %></label><br/>
6
+ <%= password_field_tag 'password' %></p>
7
+
8
+ <p><label for="remember_me"><%= _("Remember me:") %></label>
9
+ <%= check_box_tag 'remember_me' %></p>
10
+
11
+ <p><%= submit_tag(_('Log in')) %></p>
12
+ <% end -%>
@@ -0,0 +1,22 @@
1
+ <%= error_messages_for(:user) %>
2
+ <%= error_messages_for(:system_user) %>
3
+ <% form_for(:user) do |f| -%>
4
+ <p><label for="<%= @user.dn_attribute %>"><%= _("Login") %></label><br/>
5
+ <%= f.text_field(@user.dn_attribute) %></p>
6
+
7
+ <p><label for="password"><%= _("Password") %></label><br/>
8
+ <%= f.password_field(:password) %></p>
9
+
10
+ <p><label for="password_confirmation"><%= _("Confirm Password") %></label><br/>
11
+ <%= f.password_field(:password_confirmation) %></p>
12
+
13
+ <p><%= submit_tag(_('Sign up')) %></p>
14
+
15
+ <% names = @user.attribute_names(true) - ["objectClass", "userPassword"] -%>
16
+ <% names.sort.each do |name| -%>
17
+ <p><label for="<%= h name %>"><%=h la_(name) %><br />
18
+ <%= f.text_field(name) %></p>
19
+ <% end -%>
20
+
21
+ <p><%= submit_tag(_('Sign up')) %></p>
22
+ <% end -%>
@@ -0,0 +1,5 @@
1
+ <ul>
2
+ <% @entries.each do |dn, attributes| -%>
3
+ <li><%= h dn %></li>
4
+ <% end -%>
5
+ </ul>
@@ -0,0 +1,2 @@
1
+ <p><%= _("Done.") %></p>
2
+ <p><%= link_to(s_("Menu|Index"), :action => "index") %></p>
@@ -0,0 +1,41 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml">
4
+ <head>
5
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
6
+ <meta name="robots" content="all" />
7
+ <meta http-equiv="imagetoolbar" content="false" />
8
+ <meta name="MSSmartTagsPreventParsing" content="true" />
9
+ <title>
10
+ <%=h "#{controller.controller_name}: #{controller.action_name}" %>
11
+ </title>
12
+
13
+ <%= stylesheet_link_tag 'rails' %>
14
+ <%= stylesheet_link_tag 'screen' %>
15
+ <%= javascript_include_tag :defaults %>
16
+ </head>
17
+ <body>
18
+ <h1><%=h "#{controller.controller_name}: #{controller.action_name}" %></h1>
19
+ <% if flash[:notice] -%>
20
+ <p class="notice"><%=h flash[:notice] %></p>
21
+ <% end -%>
22
+ <div class="content">
23
+ <%= yield %>
24
+ </div>
25
+
26
+ <div class="footer">
27
+ <div class="links">
28
+ <p><%= link_to(_("Top"), top_path) %></p>
29
+ </div>
30
+
31
+ <div class="system-info">
32
+ <p>
33
+ al-admin: Powered by
34
+ <%= link_to("Ruby/ActiveLdap",
35
+ "http://rubyforge.org/projects/ruby-activeldap") %>
36
+ <%= ActiveLdap::VERSION %>
37
+ </p>
38
+ </div>
39
+ </div>
40
+ </body>
41
+ </html>
@@ -0,0 +1,22 @@
1
+
2
+ <div class="attribute-information">
3
+ <table>
4
+ <thead>
5
+ <tr>
6
+ <th><%= _("attribute name") %></th>
7
+ <th><%= _("value") %></th>
8
+ <th><%= _("description") %></th>
9
+ </tr>
10
+ </thead>
11
+
12
+ <tbody>
13
+ <% (entry.attribute_names(true) - ["objectClass"]).sort.each do |name| -%>
14
+ <tr>
15
+ <th><%= h la_(name) %></th>
16
+ <td><%= h entry[name, true].join(", ") %></td>
17
+ <td><%= h lad_(name) %></td>
18
+ </tr>
19
+ <% end -%>
20
+ </tbody>
21
+ </table>
22
+ </div>
@@ -0,0 +1,12 @@
1
+
2
+ <div class="entry">
3
+ <h2>
4
+ <%= user_link_if(defined?(link_to_entry) && link_to_entry, entry, true) %>
5
+ </h2>
6
+
7
+ <%= render(:partial => "object_class_information",
8
+ :locals => {:entry => entry}) %>
9
+
10
+ <%= render(:partial => "attribute_information",
11
+ :locals => {:entry => entry}) %>
12
+ </div>
@@ -0,0 +1,29 @@
1
+
2
+ <%= error_messages_for "user" %>
3
+
4
+ <table>
5
+ <tr>
6
+ <th><label for="user_password"><%= _("Password") %></label></th>
7
+ <td><%= password_field("user", "password") %></td>
8
+ </tr>
9
+
10
+ <tr>
11
+ <th>
12
+ <label for="user_password_confirmation">
13
+ <%= _("Confirm Password") %>
14
+ </label>
15
+ </th>
16
+ <td><%= password_field("user", "password_confirmation") %></td>
17
+ </tr>
18
+ </table>
19
+
20
+ <table>
21
+ <% names = @user.attribute_names(true) - ["objectClass", "userPassword"] -%>
22
+ <% names.sort.each do |name| -%>
23
+ <tr>
24
+ <th><label for="user_<%=h name %>"><%= h la_(name) %></label></th>
25
+ <td><%= text_field("user", name) %></td>
26
+ <td><%= h lad_(name) %></td>
27
+ </tr>
28
+ <% end -%>
29
+ </table>
@@ -0,0 +1,23 @@
1
+
2
+ <div class="object-class-information">
3
+ <h3><%=h la_("objectClass") %></h3>
4
+ <p><%=h lad_("objectClass") %></p>
5
+
6
+ <table>
7
+ <thead>
8
+ <tr>
9
+ <th><%= _("objectClass name") %></th>
10
+ <th><%= _("description") %></th>
11
+ </tr>
12
+ </thead>
13
+
14
+ <tbody>
15
+ <% entry.classes.sort.each do |object_class| -%>
16
+ <tr>
17
+ <td><%=h loc_(object_class) %></td>
18
+ <td><%=h locd_(object_class) %></td>
19
+ </tr>
20
+ <% end -%>
21
+ </tbody>
22
+ </table>
23
+ </div>
@@ -0,0 +1,10 @@
1
+ <div class="entry">
2
+ <h2><%= user_link(@user) %></h2>
3
+ <% form_tag :action => 'update', :id => @user do %>
4
+ <%= render :partial => 'form' %>
5
+ <%= submit_tag(s_('Command|Update')) %>
6
+ <% end %>
7
+ </div>
8
+
9
+ <%= link_to(s_('Menu|Show'), :action => 'show', :id => @user) %> |
10
+ <%= link_to(s_('Menu|Back'), :action => 'index') %>
@@ -0,0 +1,9 @@
1
+ <% if @users.empty? -%>
2
+ <p><%= _("No user.") %></p>
3
+ <% else -%>
4
+ <ul>
5
+ <% @users.each do |user| -%>
6
+ <li><%= user_link(user, true) %></li>
7
+ <% end -%>
8
+ </ul>
9
+ <% end -%>
@@ -0,0 +1,3 @@
1
+ <%= render(:partial => "entry", :locals => {:entry => @user}) %>
2
+
3
+ <%= link_to s_('Menu|Back'), :action => 'index' %>
@@ -0,0 +1,16 @@
1
+ <ul>
2
+ <% if logged_in? -%>
3
+ <li><%= link_to(s_("Menu|Users list"), :controller => "users") %></li>
4
+ <li><%= link_to(s_("Menu|Logout"), logout_path) %></li>
5
+ <li><%= link_to(s_("Menu|Directory"), :controller => "directory") %></li>
6
+ <% else -%>
7
+ <li><%= link_to(s_("Menu|Login"), login_path) %></li>
8
+ <li><%= link_to(s_("Menu|Sign up"), sign_up_path) %></li>
9
+ <% end -%>
10
+
11
+ <% if Entry.empty? -%>
12
+ <li><%= link_to(s_("Menu|Populate"),
13
+ {:controller => "directory", :action => "populate"},
14
+ :confirm => _("OK?")) %></li>
15
+ <% end -%>
16
+ </ul>
@@ -0,0 +1,45 @@
1
+ # Don't change this file. Configuration is done in config/environment.rb and config/environments/*.rb
2
+
3
+ unless defined?(RAILS_ROOT)
4
+ root_path = File.join(File.dirname(__FILE__), '..')
5
+
6
+ unless RUBY_PLATFORM =~ /(:?mswin|mingw)/
7
+ require 'pathname'
8
+ root_path = Pathname.new(root_path).cleanpath(true).to_s
9
+ end
10
+
11
+ RAILS_ROOT = root_path
12
+ end
13
+
14
+ unless defined?(Rails::Initializer)
15
+ if File.directory?("#{RAILS_ROOT}/vendor/rails")
16
+ require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
17
+ else
18
+ require 'rubygems'
19
+
20
+ environment_without_comments = IO.readlines(File.dirname(__FILE__) + '/environment.rb').reject { |l| l =~ /^#/ }.join
21
+ environment_without_comments =~ /[^#]RAILS_GEM_VERSION = '([\d.]+)'/
22
+ rails_gem_version = $1
23
+
24
+ if version = defined?(RAILS_GEM_VERSION) ? RAILS_GEM_VERSION : rails_gem_version
25
+ # Asking for 1.1.6 will give you 1.1.6.5206, if available -- makes it easier to use beta gems
26
+ rails_gem = Gem.cache.search('rails', "~>#{version}.0").sort_by { |g| g.version.version }.last
27
+
28
+ if rails_gem
29
+ gem "rails", "=#{rails_gem.version.version}"
30
+ require rails_gem.full_gem_path + '/lib/initializer'
31
+ else
32
+ STDERR.puts %(Cannot find gem for Rails ~>#{version}.0:
33
+ Install the missing gem with 'gem install -v=#{version} rails', or
34
+ change environment.rb to define RAILS_GEM_VERSION with your desired version.
35
+ )
36
+ exit 1
37
+ end
38
+ else
39
+ gem "rails"
40
+ require 'initializer'
41
+ end
42
+ end
43
+
44
+ Rails::Initializer.run(:set_load_path)
45
+ end
@@ -0,0 +1,19 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3-ruby
3
+ development:
4
+ adapter: sqlite3
5
+ database: db/development.sqlite3
6
+ timeout: 5000
7
+
8
+ # Warning: The database defined as 'test' will be erased and
9
+ # re-generated from your development database when you run 'rake'.
10
+ # Do not set this db to the same as development or production.
11
+ test:
12
+ adapter: sqlite3
13
+ database: db/test.sqlite3
14
+ timeout: 5000
15
+
16
+ production:
17
+ adapter: sqlite3
18
+ database: db/production.sqlite3
19
+ timeout: 5000
@@ -0,0 +1,68 @@
1
+ # Be sure to restart your web server when you modify this file.
2
+
3
+ # Uncomment below to force Rails into production mode when
4
+ # you don't control web/app server and can't set it the proper way
5
+ # ENV['RAILS_ENV'] ||= 'production'
6
+
7
+ # Specifies gem version of Rails to use when vendor/rails is not present
8
+ RAILS_GEM_VERSION = '1.2.3' unless defined? RAILS_GEM_VERSION
9
+
10
+ # Bootstrap the Rails environment, frameworks, and default configuration
11
+ require File.join(File.dirname(__FILE__), 'boot')
12
+
13
+ Rails::Initializer.run do |config|
14
+ # Settings in config/environments/* take precedence over those specified here
15
+
16
+ # Skip frameworks you're not going to use (only works if using vendor/rails)
17
+ # config.frameworks -= [ :action_web_service, :action_mailer ]
18
+
19
+ # Only load the plugins named here, by default all plugins in vendor/plugins are loaded
20
+ # config.plugins = %W( exception_notification ssl_requirement )
21
+
22
+ # Add additional load paths for your own custom dirs
23
+ config.load_paths += %W(#{RAILS_ROOT}/../../lib)
24
+
25
+ config.plugin_paths += %W(#{RAILS_ROOT}/../../rails/plugin)
26
+
27
+ # Force all environments to use the same logger level
28
+ # (by default production uses :info, the others :debug)
29
+ # config.log_level = :debug
30
+
31
+ # Use the database for sessions instead of the file system
32
+ # (create the session table with 'rake db:sessions:create')
33
+ # config.action_controller.session_store = :active_record_store
34
+
35
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
36
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
37
+ # like if you have constraints or database-specific column types
38
+ # config.active_record.schema_format = :sql
39
+
40
+ # Activate observers that should always be running
41
+ # config.active_record.observers = :cacher, :garbage_collector
42
+
43
+ # Make Active Record use UTC-base instead of local time
44
+ # config.active_record.default_timezone = :utc
45
+
46
+ # See Rails::Configuration for more options
47
+ end
48
+
49
+ # Add new inflection rules using the following format
50
+ # (all these examples are active by default):
51
+ # Inflector.inflections do |inflect|
52
+ # inflect.plural /^(ox)$/i, '\1en'
53
+ # inflect.singular /^(ox)en/i, '\1'
54
+ # inflect.irregular 'person', 'people'
55
+ # inflect.uncountable %w( fish sheep )
56
+ # end
57
+
58
+ # Add new mime types for use in respond_to blocks:
59
+ # Mime::Type.register "text/richtext", :rtf
60
+ # Mime::Type.register "application/x-mobile", :mobile
61
+
62
+ # Include your application configuration below
63
+
64
+ require 'gettext/rails'
65
+ require 'accept_http_rails_relative_url_root'
66
+
67
+ # ExceptionNotifier.sender_address = "null@cozmixng.org"
68
+ # ExceptionNotifier.exception_recipients = %w(kou@cozmixng.org)