rich_support 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. data/.gitignore +9 -0
  2. data/.suit +4 -0
  3. data/CHANGELOG.rdoc +5 -0
  4. data/Gemfile +3 -0
  5. data/MIT-LICENSE +20 -0
  6. data/README.textile +141 -0
  7. data/Rakefile +29 -0
  8. data/VERSION +1 -0
  9. data/lib/rich/support/actionpack/action_controller/test_case.rb +28 -0
  10. data/lib/rich/support/actionpack.rb +3 -0
  11. data/lib/rich/support/activesupport/active_support/dependencies.rb +12 -0
  12. data/lib/rich/support/activesupport.rb +3 -0
  13. data/lib/rich/support/core/string/colorize.rb +41 -0
  14. data/lib/rich/support/core/string/html_safe.rb +17 -0
  15. data/lib/rich/support/core/string/inflections.rb +39 -0
  16. data/lib/rich/support/core/string.rb +7 -0
  17. data/lib/rich/support/core.rb +2 -0
  18. data/lib/rich/support/rails/engine.rb +4 -0
  19. data/lib/rich/support/rails.rb +3 -0
  20. data/lib/rich/support/test/unit/test_case.rb +92 -0
  21. data/lib/rich/support/test.rb +3 -0
  22. data/lib/rich/support/version.rb +11 -0
  23. data/lib/rich/support.rb +51 -0
  24. data/lib/rich_support.rb +7 -0
  25. data/rich_support.gemspec +21 -0
  26. data/suit/rails-2/dummy/Gemfile +14 -0
  27. data/suit/rails-2/dummy/README +243 -0
  28. data/suit/rails-2/dummy/Rakefile +10 -0
  29. data/suit/rails-2/dummy/app/controllers/application_controller.rb +10 -0
  30. data/suit/rails-2/dummy/app/helpers/application_helper.rb +3 -0
  31. data/suit/rails-2/dummy/config/boot.rb +128 -0
  32. data/suit/rails-2/dummy/config/database.yml +22 -0
  33. data/suit/rails-2/dummy/config/environment.rb +41 -0
  34. data/suit/rails-2/dummy/config/environments/development.rb +17 -0
  35. data/suit/rails-2/dummy/config/environments/production.rb +28 -0
  36. data/suit/rails-2/dummy/config/environments/test.rb +28 -0
  37. data/suit/rails-2/dummy/config/initializers/backtrace_silencers.rb +7 -0
  38. data/suit/rails-2/dummy/config/initializers/cookie_verification_secret.rb +7 -0
  39. data/suit/rails-2/dummy/config/initializers/inflections.rb +10 -0
  40. data/suit/rails-2/dummy/config/initializers/mime_types.rb +5 -0
  41. data/suit/rails-2/dummy/config/initializers/new_rails_defaults.rb +21 -0
  42. data/suit/rails-2/dummy/config/initializers/session_store.rb +15 -0
  43. data/suit/rails-2/dummy/config/locales/en.yml +5 -0
  44. data/suit/rails-2/dummy/config/preinitializer.rb +20 -0
  45. data/suit/rails-2/dummy/config/routes.rb +43 -0
  46. data/suit/rails-2/dummy/db/schema.rb +2 -0
  47. data/suit/rails-2/dummy/db/seeds.rb +7 -0
  48. data/suit/rails-2/dummy/doc/README_FOR_APP +2 -0
  49. data/suit/rails-2/dummy/script/about +4 -0
  50. data/suit/rails-2/dummy/script/console +3 -0
  51. data/suit/rails-2/dummy/script/dbconsole +3 -0
  52. data/suit/rails-2/dummy/script/destroy +3 -0
  53. data/suit/rails-2/dummy/script/generate +3 -0
  54. data/suit/rails-2/dummy/script/performance/benchmarker +3 -0
  55. data/suit/rails-2/dummy/script/performance/profiler +3 -0
  56. data/suit/rails-2/dummy/script/plugin +3 -0
  57. data/suit/rails-2/dummy/script/runner +3 -0
  58. data/suit/rails-2/dummy/script/server +3 -0
  59. data/suit/rails-3/dummy/.gitignore +4 -0
  60. data/suit/rails-3/dummy/Gemfile +14 -0
  61. data/suit/rails-3/dummy/README +256 -0
  62. data/suit/rails-3/dummy/Rakefile +7 -0
  63. data/suit/rails-3/dummy/app/controllers/application_controller.rb +3 -0
  64. data/suit/rails-3/dummy/app/helpers/application_helper.rb +2 -0
  65. data/suit/rails-3/dummy/config/application.rb +42 -0
  66. data/suit/rails-3/dummy/config/boot.rb +6 -0
  67. data/suit/rails-3/dummy/config/database.yml +22 -0
  68. data/suit/rails-3/dummy/config/environment.rb +5 -0
  69. data/suit/rails-3/dummy/config/environments/development.rb +26 -0
  70. data/suit/rails-3/dummy/config/environments/production.rb +49 -0
  71. data/suit/rails-3/dummy/config/environments/test.rb +35 -0
  72. data/suit/rails-3/dummy/config/initializers/backtrace_silencers.rb +7 -0
  73. data/suit/rails-3/dummy/config/initializers/inflections.rb +10 -0
  74. data/suit/rails-3/dummy/config/initializers/mime_types.rb +5 -0
  75. data/suit/rails-3/dummy/config/initializers/secret_token.rb +7 -0
  76. data/suit/rails-3/dummy/config/initializers/session_store.rb +8 -0
  77. data/suit/rails-3/dummy/config/locales/en.yml +5 -0
  78. data/suit/rails-3/dummy/config/routes.rb +58 -0
  79. data/suit/rails-3/dummy/config.ru +4 -0
  80. data/suit/rails-3/dummy/db/schema.rb +2 -0
  81. data/suit/rails-3/dummy/db/seeds.rb +7 -0
  82. data/suit/rails-3/dummy/doc/README_FOR_APP +2 -0
  83. data/suit/rails-3/dummy/lib/tasks/.gitkeep +0 -0
  84. data/suit/rails-3/dummy/script/rails +6 -0
  85. data/suit/rails-3/dummy/vendor/plugins/.gitkeep +0 -0
  86. data/suit/shared/app/models/.gitkeep +0 -0
  87. data/suit/shared/app/views/application/index.html.erb +16 -0
  88. data/suit/shared/app/views/layouts/application.html.erb +11 -0
  89. data/suit/shared/db/schema.rb +2 -0
  90. data/suit/shared/db/seeds.rb +7 -0
  91. data/suit/shared/public/404.html +26 -0
  92. data/suit/shared/public/422.html +26 -0
  93. data/suit/shared/public/500.html +26 -0
  94. data/suit/shared/public/favicon.ico +0 -0
  95. data/suit/shared/public/images/rails.png +0 -0
  96. data/suit/shared/public/javascripts/application.js +2 -0
  97. data/suit/shared/public/javascripts/controls.js +965 -0
  98. data/suit/shared/public/javascripts/dragdrop.js +974 -0
  99. data/suit/shared/public/javascripts/effects.js +1123 -0
  100. data/suit/shared/public/javascripts/prototype.js +6001 -0
  101. data/suit/shared/public/javascripts/rails.js +191 -0
  102. data/suit/shared/public/robots.txt +5 -0
  103. data/suit/shared/public/stylesheets/.gitkeep +0 -0
  104. data/suit/shared/public/stylesheets/app.css +99 -0
  105. data/suit/shared/test/fixtures/.gitkeep +0 -0
  106. data/suit/shared/test/integration/suit/example.rb +40 -0
  107. data/suit/shared/test/suit_application/capybara_extensions.rb +32 -0
  108. data/suit/shared/test/suit_application.rb +27 -0
  109. data/suit/shared/test/test_helper.rb +37 -0
  110. data/suit/shared/test/unit/.gitkeep +0 -0
  111. data/suit/shared/test/unit/actionpack/action_controller/routing_test.rb +14 -0
  112. data/suit/shared/test/unit/actionpack/action_controller/test_case_test.rb +17 -0
  113. data/suit/shared/test/unit/activesupport/active_support/dependencies_test.rb +15 -0
  114. data/suit/shared/test/unit/core/string/colorize_test.rb +43 -0
  115. data/suit/shared/test/unit/core/string/html_safe_test.rb +15 -0
  116. data/suit/shared/test/unit/core/string/inflections_test.rb +51 -0
  117. data/suit/shared/test/unit/rails/engine_test.rb +13 -0
  118. data/suit/shared/test/unit/test/unit/test_case_test.rb +19 -0
  119. data/suit/templates/shared/Gemfile +14 -0
  120. data/suit/templates/shared/config/database.yml +10 -0
  121. data/suit/templates/shared/config/initializers/.gitkeep +0 -0
  122. data/suit/templates/shared/db/schema.rb +2 -0
  123. metadata +189 -0
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ .DS_Store
2
+ .bundle
3
+ *.gem
4
+ Gemfile.lock
5
+ pkg/*
6
+ suit/rails-*/dummy/db/*.sqlite3
7
+ suit/rails-*/dummy/log/*.log
8
+ suit/rails-*/dummy/tmp/*
9
+ suit/shared/mysql
data/.suit ADDED
@@ -0,0 +1,4 @@
1
+ ---
2
+ :version: 0.1.0
3
+ :capybara: true
4
+ :mysql: false
data/CHANGELOG.rdoc ADDED
@@ -0,0 +1,5 @@
1
+ = Rich-Support CHANGELOG
2
+
3
+ == Version 0.1.0 (April 10, 2011)
4
+
5
+ * Initial release
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Paul Engel
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.textile ADDED
@@ -0,0 +1,141 @@
1
+ h1. Rich-Support
2
+
3
+ A small gem making your own gem Rails 2 and 3 compliant and providing the String class a few goodies
4
+
5
+ h2. Introduction
6
+
7
+ Rich-Support is a small module of E9s ("http://github.com/archan937/e9s":http://github.com/archan937/e9s) making your own gem Rails 2 and 3 compliant. It also adds a small amount of handy methods to the String class.
8
+
9
+ *Attention:* This gem does *NOT* add Rails 3 functionality to a Rails 2 application, but provides an unified interface for certain differences in implementation between Rails 2 and 3. A few examples:
10
+
11
+ * it provides a unified interface for the @after_initialize@ hook of the Rails application
12
+ * it provides the @ActiveSupport::Dependencies.autoload_paths@ to be called in both Rails 2 and 3
13
+ * it defines @String.html_safe@ if it hasn't been defined already (it only returns the String and does *NOT* HTML escapes the String)
14
+
15
+ A real world example of a Rich-Support implementation is the "Rich-CMS":https://github.com/archan937/rich_cms/tree/edge gem of which Rich-Support is extracted from.
16
+
17
+ h2. Installation
18
+
19
+ Add Rich-Support as gem dependency in your @gemspec@ file:
20
+
21
+ <pre>
22
+ s.add_dependency "rich_support"
23
+ </pre>
24
+
25
+ Require Rich-Support in your gem (e.g. in @libs/rich_cms.rb@ for the gem Rich-CMS)
26
+
27
+ <pre>
28
+ require "rich_support"
29
+ </pre>
30
+
31
+ Your gem is now Rails 2 and 3 compliant.
32
+
33
+ h2. Using the Rails configuration after_initialize hook regardless of the major Rails version
34
+
35
+ As calling the @after_initialize@ differs in the major Rails versions, but you can just call @Rich::Support.after_initialize@ instead as it will handle things for you:
36
+
37
+ <pre>
38
+ Rich::Support.after_initialize do
39
+ register_assets
40
+ copy_images
41
+ require_models
42
+ end
43
+ </pre>
44
+
45
+ h2. Registering your gem controllers, views and routes in Rails 2
46
+
47
+ As only Rails 3 recognizes your controllers, views and routes automatically, you will have to append them in Rails 2 yourself. Fortunately with Rich::Support, you will only have to append your gem path:
48
+
49
+ <pre>
50
+ Rich::Support.append_gem_path File.expand_path("../..", __FILE__)
51
+ </pre>
52
+
53
+ *Note*: The source file in this example is located in the @lib@ directory of the gem itself
54
+
55
+ Calling @append_gem_path@ registers the following in Rails 2:
56
+
57
+ * @controllers@ - Which is assumed to be located in @app/controllers@
58
+ * @views@ - Which is assumed to be located in @app/views@
59
+ * @routes@ - Which is assumed to be located in @config/routes.rb@
60
+
61
+ h2. Some String class goodies
62
+
63
+ Rich-Support adds a small amount of methods to the @String@ class:
64
+
65
+ * @String.upcase_first@ - Upcases the first character of a String and leaves the remainder alone unlike @String.capitalize@ which downcases it
66
+ * @String.upcase_first!@ - Only returns the upcased String when it has changed otherwise it returns a @nil@ value
67
+ * @String.copy_case@ - Copies the letter casing of a passed String (e.g. @"paul".copy_case("Engel")@ returns @"Paul"@ and @"CoDe".copy_case("HERO")@ returns @"CODE"@)
68
+ * @String.copy_case!@ - Only returns the case copied String when it has changed otherwise it returns a @nil@ value
69
+ * @String.singularize!@ and @String.pluralize!@ - Which (as you expected) only returns a String when it has changed otherwise a @nil@ value
70
+
71
+ h2. Developing Rich-Support yourself
72
+
73
+ 1. Create your own Rich-Support fork "https://github.com/archan937/rich_support/fork":https://github.com/archan937/rich_support/fork
74
+ 2. Clone your Rich-Support fork repository
75
+
76
+ <pre>
77
+ git clone git@github.com:<your_username>/rich_support.git && cd rich_support
78
+ </pre>
79
+
80
+ 3. Setup your environment in order to use the "GemSuit":https://github.com/archan937/gem_suit tests provided within Rich-Support
81
+
82
+ <pre>
83
+ gem install gem_suit && suit fit -v
84
+ </pre>
85
+
86
+ 4. Run unit tests in both Rails 2 and 3
87
+
88
+ <pre>
89
+ suit test unit -v
90
+ </pre>
91
+
92
+ 5. Start either of the dummy Rails applications for development purposes (Rails 3 at default)
93
+
94
+ <pre>
95
+ suit s
96
+ </pre>
97
+
98
+ To run the Rails 2 application:
99
+
100
+ <pre>
101
+ suit s -r2
102
+ </pre>
103
+
104
+ 6. *Get on programming* and send your pull request! ;)
105
+
106
+ *Note*: For more information about GemSuit, please visit "its Github page":https://github.com/archan937/gem_suit.
107
+
108
+ h2. Contact me
109
+
110
+ For support, remarks and requests please mail me at "paul.engel@holder.nl":mailto:paul.engel@holder.nl.
111
+
112
+ h2. Enrichments
113
+
114
+ The all-in-one gem at – "http://codehero.es/rails_gems_plugins/e9s":http://codehero.es/rails_gems_plugins/e9s – "http://github.com/archan937/e9s":http://github.com/archan937/e9s
115
+
116
+ h2. E9s modules
117
+
118
+ * Rich-Support <br>
119
+ "http://codehero.es":http://codehero.es <br>
120
+ "http://github.com/archan937/rich_support":http://github.com/archan937/rich_support
121
+ * Rich-CMS <br>
122
+ "http://codehero.es/rails_gems_plugins/rich_cms":http://codehero.es/rails_gems_plugins/rich_cms <br>
123
+ "http://github.com/archan937/rich_cms":http://github.com/archan937/rich_cms
124
+ * Rich-i18n <br>
125
+ "http://codehero.es/rails_gems_plugins/rich_i18n":http://codehero.es/rails_gems_plugins/rich_i18n <br>
126
+ "http://github.com/archan937/rich_i18n":http://github.com/archan937/rich_i18n
127
+ * Rich-pluralization <br>
128
+ "http://codehero.es/rails_gems_plugins/rich_pluralization":http://codehero.es/rails_gems_plugins/rich_pluralization <br>
129
+ "http://github.com/archan937/rich_pluralization":http://github.com/archan937/rich_pluralization
130
+
131
+ h2. License
132
+
133
+ Copyright (c) 2011 Paul Engel, released under the MIT license
134
+
135
+ "http://holder.nl":http://holder.nl – "http://codehero.es":http://codehero.es – "http://gettopup.com":http://gettopup.com – "http://twitter.com/archan937":http://twitter.com/archan937 – "paul.engel@holder.nl":mailto:paul.engel@holder.nl
136
+
137
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
138
+
139
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
140
+
141
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,29 @@
1
+ require "bundler"
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require "rake/testtask"
5
+ require "rake/rdoctask"
6
+ require "rich/support/core/string/colorize"
7
+
8
+ desc "Default: run unit tests."
9
+ task :default => :test
10
+
11
+ desc "Test Rich-Support."
12
+ task :test do
13
+ begin
14
+ require "gem_suit"
15
+ system "suit test unit -v"
16
+ rescue LoadError
17
+ puts "Please install GemSuit with 'gem install gem_suit'".red
18
+ end
19
+ end
20
+
21
+ desc "Generate documentation for Rich-Support."
22
+ Rake::RDocTask.new(:rdoc) do |rdoc|
23
+ rdoc.rdoc_dir = "rdoc"
24
+ rdoc.title = "Rich-Support"
25
+ rdoc.options << "--line-numbers" << "--inline-source"
26
+ rdoc.rdoc_files.include "README.textile"
27
+ rdoc.rdoc_files.include "MIT-LICENSE"
28
+ rdoc.rdoc_files.include "lib/**/*.rb"
29
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,28 @@
1
+ module ActionController
2
+ class TestCase
3
+
4
+ protected
5
+
6
+ def assert_named_route(result, name)
7
+ assert_equal result, named_routes[name.to_s]
8
+ end
9
+
10
+ def named_routes
11
+ @named_routes ||= Hash[*begin
12
+ if Rails::VERSION::MAJOR >= 3
13
+ Rails.application.routes.routes.collect do |route|
14
+ [route.name, route.path.gsub("(.:format)", "")] unless route.name.blank?
15
+ end
16
+ else
17
+ ActionController::Routing::Routes.routes.collect do |route|
18
+ name = ActionController::Routing::Routes.named_routes.routes.index(route).to_s
19
+ path = route.segments.collect(&:to_s).join
20
+ path.chop! if path.length > 1
21
+ [name, path] unless name.blank?
22
+ end
23
+ end
24
+ end.compact.flatten]
25
+ end
26
+
27
+ end
28
+ end
@@ -0,0 +1,3 @@
1
+ if defined?(ActionController)
2
+ require "rich/support/actionpack/action_controller/test_case"
3
+ end
@@ -0,0 +1,12 @@
1
+ module ActiveSupport
2
+ module Dependencies
3
+
4
+ extend self
5
+
6
+ unless respond_to? :autoload_paths
7
+ alias_method :autoload_paths , :load_paths
8
+ alias_method :autoload_once_paths, :load_once_paths
9
+ end
10
+
11
+ end
12
+ end
@@ -0,0 +1,3 @@
1
+ if defined?(ActiveSupport)
2
+ require "rich/support/activesupport/active_support/dependencies"
3
+ end
@@ -0,0 +1,41 @@
1
+ module Rich
2
+ module Support
3
+ module Core
4
+ module String
5
+ module Colorize
6
+
7
+ COLORS = {:red => 31, :green => 32, :yellow => 33}
8
+
9
+ def self.included(base)
10
+ COLORS.each do |name, code|
11
+ base.send :define_method, name do
12
+ _colorize code
13
+ end
14
+ end
15
+
16
+ base.send :include, InstanceMethods
17
+ end
18
+
19
+ module InstanceMethods
20
+ def colorize
21
+ self.gsub(/\{\{(#{COLORS.keys.join("|")}):(.+)\}\}/) do |match|
22
+ $2.send $1
23
+ end
24
+ end
25
+ end
26
+
27
+ private
28
+
29
+ def _colorize(color)
30
+ "\e[1m\e[#{color}m#{self}\e[0m"
31
+ end
32
+
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+ class String
40
+ include Rich::Support::Core::String::Colorize
41
+ end
@@ -0,0 +1,17 @@
1
+ module Rich
2
+ module Support
3
+ module Core
4
+ module String
5
+ module HtmlSafe
6
+
7
+ unless ::String.new.respond_to? :html_safe
8
+ def html_safe
9
+ self
10
+ end
11
+ end
12
+
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,39 @@
1
+ module Rich
2
+ module Support
3
+ module Core
4
+ module String
5
+ module Inflections
6
+
7
+ def upcase_first
8
+ empty? ?
9
+ self :
10
+ self[0].chr.capitalize + self[1, size]
11
+ end
12
+
13
+ def copy_case(s)
14
+ send((:downcase unless s.dup.downcase!) || (:upcase unless s.dup.upcase!) || (:upcase_first unless s.dup.upcase_first!) || :to_s)
15
+ end
16
+ alias_method :cp_case, :copy_case
17
+
18
+ def upcase_first!
19
+ self == (result = upcase_first) ? nil : replace(result)
20
+ end
21
+
22
+ def copy_case!(s)
23
+ self == (result = cp_case(s)) ? nil : replace(result)
24
+ end
25
+ alias_method :cp_case!, :copy_case!
26
+
27
+ def singularize!
28
+ downcase == (result = singularize).downcase ? nil : replace(result)
29
+ end
30
+
31
+ def pluralize!
32
+ downcase == (result = pluralize).downcase ? nil : replace(result)
33
+ end
34
+
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,7 @@
1
+ require "rich/support/core/string/html_safe"
2
+ require "rich/support/core/string/inflections"
3
+
4
+ class String
5
+ include Rich::Support::Core::String::HtmlSafe
6
+ include Rich::Support::Core::String::Inflections
7
+ end
@@ -0,0 +1,2 @@
1
+ require "rich/support/core/string"
2
+ require "rich/support/core/string/colorize"
@@ -0,0 +1,4 @@
1
+ unless defined?(Rails::Engine)
2
+ class Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ if defined?(Rails)
2
+ require "rich/support/rails/engine"
3
+ end
@@ -0,0 +1,92 @@
1
+ # https://github.com/jm/pending/blob/master/lib/pending.rb
2
+
3
+ unless Rails::VERSION::MAJOR >= 3
4
+
5
+ module Test
6
+ module Unit
7
+ class TestCase
8
+ @@pending_cases = []
9
+ @@at_exit = false
10
+
11
+ # The pending method lets you define a block of test code that is currently "pending"
12
+ # functionality.
13
+ #
14
+ # You can use it two ways. One is simply put a string as the parameter:
15
+ #
16
+ # def test_web_service_integration
17
+ # pending "This is not done yet..."
18
+ # end
19
+ #
20
+ # This will output a "P" in the test output alerting there is pending functionality.
21
+ #
22
+ # You can also supply a block of code:
23
+ #
24
+ # def test_new_helpers
25
+ # pending "New helpers for database display" do
26
+ # output = render_record(User.first)
27
+ # assert_equal "Jerry User (jerry@users.com)", output
28
+ # end
29
+ # end
30
+ #
31
+ # If the block doesn't fail, then the test will flunk with output like:
32
+ #
33
+ # <New helpers for database display> did not fail.
34
+ #
35
+ # If the test fails (i.e., the functionality isn't implemented), then it will
36
+ # not fail the surrounding test.
37
+ #
38
+ def pending(description = "", &block)
39
+ if block_given?
40
+ failed = false
41
+
42
+ begin
43
+ block.call
44
+ rescue
45
+ failed = true
46
+ end
47
+
48
+ flunk("<#{description}> did not fail.") unless failed
49
+ end
50
+
51
+ caller[0] =~ (/(.*):(.*):in `(.*)'/)
52
+ @@pending_cases << "#{$3} at #{$1}, line #{$2}"
53
+ print "P"
54
+
55
+ @@at_exit ||= begin
56
+ at_exit do
57
+ puts "\nPending Cases:"
58
+ @@pending_cases.each do |test_case|
59
+ puts test_case
60
+ end
61
+ end
62
+ end
63
+ end
64
+
65
+ # This method will define a test method using the description as the test name
66
+ # ("pending function" => "test_pending_function")
67
+ #
68
+ # Instead of doing this:
69
+ #
70
+ # def test_function_is_pending
71
+ # pending "this test is pending"
72
+ # end
73
+ #
74
+ # You can just do this:
75
+ #
76
+ # pending "function is pending"
77
+ #
78
+ # This method can be called with a block passed, the same as the instance method
79
+ #
80
+ def self.pending(description, &block)
81
+ test_name = "test_#{description.gsub(/\s+/,'_')}".to_sym
82
+ defined = instance_method(test_name) rescue false
83
+ raise "#{test_name} is already defined in #{self}" if defined
84
+ define_method(test_name) do
85
+ pending(description) {self.instance_eval(&block)}
86
+ end
87
+ end
88
+ end
89
+ end
90
+ end
91
+
92
+ end
@@ -0,0 +1,3 @@
1
+ if defined? Test
2
+ require "rich/support/test/unit/test_case"
3
+ end
@@ -0,0 +1,11 @@
1
+ module Rich
2
+ module Support
3
+ module VERSION
4
+ MAJOR = 0
5
+ MINOR = 1
6
+ TINY = 0
7
+
8
+ STRING = [MAJOR, MINOR, TINY].join(".")
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,51 @@
1
+ module Rich
2
+ module Support
3
+ extend self
4
+
5
+ def append_gem_path(path)
6
+ (@gem_paths ||= []) << path
7
+
8
+ check_controllers_for path
9
+ check_routes_for path
10
+ check_views_for path
11
+ end
12
+
13
+ def after_initialize(&block)
14
+ if Rails::VERSION::MAJOR >= 3
15
+ ActiveSupport.on_load :after_initialize, :yield => true, &block
16
+ else
17
+ Rails.configuration.after_initialize &block
18
+ end
19
+ end
20
+
21
+ private
22
+
23
+ def check_controllers_for(path)
24
+ return if Rails::VERSION::MAJOR >= 3
25
+ if File.exists?(controllers = File.expand_path("app/controllers", path))
26
+ $LOAD_PATH << controllers
27
+ ActiveSupport::Dependencies.autoload_paths << controllers
28
+ ActiveSupport::Dependencies.autoload_once_paths.delete controllers
29
+ end
30
+ end
31
+
32
+ def check_routes_for(path)
33
+ return if Rails::VERSION::MAJOR >= 3
34
+ if File.exists?(routes = File.expand_path("config/routes.rb", path))
35
+ require routes
36
+ end
37
+ end
38
+
39
+ def check_views_for(path)
40
+ return if Rails::VERSION::MAJOR >= 3
41
+ if File.exists?(views = File.expand_path("app/views", path))
42
+ if ActionController::Base.respond_to? :append_view_path
43
+ ActionController::Base.append_view_path views
44
+ elsif ActionController::Base.respond_to? :view_paths
45
+ ActionController::Base.self.view_paths << views
46
+ end
47
+ end
48
+ end
49
+
50
+ end
51
+ end
@@ -0,0 +1,7 @@
1
+ require "rich/support"
2
+ require "rich/support/core"
3
+ require "rich/support/actionpack"
4
+ require "rich/support/activesupport"
5
+ require "rich/support/rails"
6
+ require "rich/support/test"
7
+ require "rich/support/version"
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "rich/support/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "rich_support"
7
+ s.version = Rich::Support::VERSION::STRING
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Paul Engel"]
10
+ s.email = ["paul.engel@holder.nl"]
11
+ s.homepage = "https://github.com/archan937/rich_support"
12
+ s.summary = %q{A small gem making your own gem Rails 2 and 3 compliant and providing the String class a few goodies}
13
+ s.description = %q{Rich-Support is a small module of E9s (http://github.com/archan937/e9s) making your own gem Rails 2 and 3 compliant. It also adds a small amount of handy methods to the String class.}
14
+
15
+ s.rubyforge_project = "rich_support"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+ end
@@ -0,0 +1,14 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "rails", "2.3.11"
4
+ gem "sqlite3-ruby", :require => "sqlite3"
5
+
6
+ gem "rich_support", :path => File.expand_path("../../../..", __FILE__)
7
+
8
+ group :test do
9
+ gem "mysql"
10
+ gem "shoulda"
11
+ gem "mocha"
12
+ gem "capybara"
13
+ gem "launchy"
14
+ end