fortitude 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +26 -2
  3. data/CHANGES.md +29 -0
  4. data/lib/fortitude.rb +6 -92
  5. data/lib/fortitude/doctypes.rb +6 -4
  6. data/lib/fortitude/doctypes/base.rb +6 -2
  7. data/lib/fortitude/doctypes/html4.rb +2 -1
  8. data/lib/fortitude/doctypes/html4_frameset.rb +2 -0
  9. data/lib/fortitude/doctypes/html4_strict.rb +1 -0
  10. data/lib/fortitude/doctypes/html4_tags_frameset.rb +3 -2
  11. data/lib/fortitude/doctypes/html4_tags_strict.rb +3 -2
  12. data/lib/fortitude/doctypes/html4_tags_transitional.rb +3 -2
  13. data/lib/fortitude/doctypes/html4_transitional.rb +1 -0
  14. data/lib/fortitude/doctypes/html5.rb +3 -2
  15. data/lib/fortitude/doctypes/unknown_doctype.rb +1 -0
  16. data/lib/fortitude/doctypes/xhtml10.rb +2 -1
  17. data/lib/fortitude/doctypes/xhtml10_frameset.rb +1 -0
  18. data/lib/fortitude/doctypes/xhtml10_strict.rb +1 -0
  19. data/lib/fortitude/doctypes/xhtml10_transitional.rb +1 -0
  20. data/lib/fortitude/doctypes/xhtml11.rb +2 -1
  21. data/lib/fortitude/{fortitude_ruby_ext.rb → extensions/fortitude_ruby_ext.rb} +16 -11
  22. data/lib/fortitude/extensions/native_extensions.rb +33 -0
  23. data/lib/fortitude/{assign_locals_from_template.rb.smpl → method_templates/assign_locals_from_template.rb.smpl} +0 -0
  24. data/lib/fortitude/{need_assignment_template.rb.smpl → method_templates/need_assignment_template.rb.smpl} +0 -0
  25. data/lib/fortitude/{need_method_template.rb.smpl → method_templates/need_method_template.rb.smpl} +0 -0
  26. data/lib/fortitude/method_templates/simple_template.rb +50 -0
  27. data/lib/fortitude/{tag_method_template.rb.smpl → method_templates/tag_method_template.rb.smpl} +0 -0
  28. data/lib/fortitude/{text_method_template.rb.smpl → method_templates/text_method_template.rb.smpl} +0 -0
  29. data/lib/fortitude/rails.rb +26 -0
  30. data/lib/fortitude/rails/railtie.rb +256 -0
  31. data/lib/fortitude/rails/widget_methods.rb +0 -4
  32. data/lib/fortitude/rendering_context.rb +2 -2
  33. data/lib/fortitude/support/assigns_proxy.rb +77 -0
  34. data/lib/fortitude/support/class_inheritable_attributes.rb +98 -0
  35. data/lib/fortitude/support/instance_variable_set.rb +76 -0
  36. data/lib/fortitude/support/staticized_method.rb +87 -0
  37. data/lib/fortitude/tags/partial_tag_placeholder.rb +19 -0
  38. data/lib/fortitude/tags/tag.rb +189 -0
  39. data/lib/fortitude/tags/tag_return_value.rb +13 -0
  40. data/lib/fortitude/tags/tag_store.rb +53 -0
  41. data/lib/fortitude/tags/tag_support.rb +51 -0
  42. data/lib/fortitude/tags/tags_module.rb +16 -0
  43. data/lib/fortitude/tilt.rb +17 -0
  44. data/lib/fortitude/tilt/fortitude_template.rb +13 -13
  45. data/lib/fortitude/version.rb +1 -1
  46. data/lib/fortitude/widget.rb +36 -886
  47. data/lib/fortitude/widget/around_content.rb +53 -0
  48. data/lib/fortitude/widget/capturing.rb +37 -0
  49. data/lib/fortitude/widget/content.rb +51 -0
  50. data/lib/fortitude/widget/doctypes.rb +53 -0
  51. data/lib/fortitude/widget/helpers.rb +62 -0
  52. data/lib/fortitude/widget/integration.rb +76 -0
  53. data/lib/fortitude/widget/localization.rb +63 -0
  54. data/lib/fortitude/widget/modules_and_subclasses.rb +58 -0
  55. data/lib/fortitude/widget/needs.rb +164 -0
  56. data/lib/fortitude/widget/non_rails_widget_methods.rb +13 -0
  57. data/lib/fortitude/widget/rendering.rb +93 -0
  58. data/lib/fortitude/widget/start_and_end_comments.rb +69 -0
  59. data/lib/fortitude/widget/staticization.rb +50 -0
  60. data/lib/fortitude/widget/tag_like_methods.rb +102 -0
  61. data/lib/fortitude/widget/tags.rb +55 -0
  62. data/lib/fortitude/widget/temporary_overrides.rb +28 -0
  63. data/lib/fortitude/widget/widget_class_inheritable_attributes.rb +35 -0
  64. data/lib/fortitude/widgets.rb +12 -0
  65. data/lib/fortitude_jruby_native_ext.jar +0 -0
  66. data/spec/helpers/system_helpers.rb +3 -3
  67. data/spec/system/attribute_rules_system_spec.rb +9 -9
  68. data/spec/system/doctypes_system_spec.rb +15 -0
  69. data/spec/system/escaping_system_spec.rb +2 -2
  70. data/spec/system/formatting_system_spec.rb +2 -2
  71. data/spec/system/id_uniqueness_system_spec.rb +5 -5
  72. data/spec/system/method_precedence_system_spec.rb +1 -1
  73. data/spec/system/needs_system_spec.rb +13 -0
  74. data/spec/system/setting_inheritance_system_spec.rb +20 -20
  75. data/spec/system/tag_rendering_system_spec.rb +27 -20
  76. data/spec/system/tag_rules_system_spec.rb +1 -1
  77. data/spec/system/tag_updating_system_spec.rb +3 -3
  78. data/spec/system/tilt_system_spec.rb +4 -0
  79. data/spec/system/void_tags_system_spec.rb +44 -5
  80. metadata +42 -21
  81. data/lib/fortitude/assigns_proxy.rb +0 -75
  82. data/lib/fortitude/class_inheritable_attributes.rb +0 -96
  83. data/lib/fortitude/instance_variable_set.rb +0 -74
  84. data/lib/fortitude/non_rails_widget_methods.rb +0 -15
  85. data/lib/fortitude/partial_tag_placeholder.rb +0 -17
  86. data/lib/fortitude/railtie.rb +0 -254
  87. data/lib/fortitude/simple_template.rb +0 -45
  88. data/lib/fortitude/staticized_method.rb +0 -85
  89. data/lib/fortitude/tag.rb +0 -162
  90. data/lib/fortitude/tag_return_value.rb +0 -11
  91. data/lib/fortitude/tag_store.rb +0 -48
  92. data/lib/fortitude/tag_support.rb +0 -48
  93. data/lib/fortitude/tags_module.rb +0 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 434f5a087c5b30e778267de15a4bf61de1a414ab
4
- data.tar.gz: 01cb3a65d7b6086e4203837c455255cd2d9a5419
3
+ metadata.gz: 18462239455549b7d5cb928e800d12039ee251d5
4
+ data.tar.gz: 36098bcd9321189387d6321c9211e335adb4d530
5
5
  SHA512:
6
- metadata.gz: 30efa375a3fb544c59a271b7f82a512a1cd845cbb227c21a2b4f65cb2b6d4e90c427b95d7691cb09267401048048005f21fbac1e765c97bb4757094af29a6755
7
- data.tar.gz: 7b51d93fbca484ce657f11cdae73737155169bd2185f1dec0a0dc9d1658922d72e7a498e315094d41177b8e5d8b61a3965d02eb96c5bb9d02c7e5f2b511b195b
6
+ metadata.gz: f2ccd3ba05b45c281a0d5919ab747c8a2afcaec9c06c7b303e45a757502c6201f58968279af65077a358cd8d92662cb93e9b59cb03b5a45de7db014e2a9fe112
7
+ data.tar.gz: db8657d85913dfa462056ca3965bcf41120cc64bd3fca78976a228eee205a552f78f354877f4c7ce5896b9cfba5b121da5516cabac05b572fc0d4272cffd32a3
data/.travis.yml CHANGED
@@ -13,8 +13,7 @@ env:
13
13
  - FORTITUDE_NATIVE_EXTENSIONS=false FORTITUDE_SPECS_RAILS_VERSION=4.1.1
14
14
  - FORTITUDE_NATIVE_EXTENSIONS=false FORTITUDE_SPECS_RAILS_VERSION=3.0.20
15
15
  before_script:
16
- - export JRUBY_OPTS="$JRUBY_OPTS -J-Xmx256m -J-Xms256m -J-Xss2048k"
17
- - echo "JRUBY_OPTS=$JRUBY_OPTS"
16
+ - export JRUBY_OPTS="$JRUBY_OPTS -J-Xmx128m -J-Xms128m -J-Xss2048k"
18
17
  matrix:
19
18
  exclude:
20
19
  # Rails 4.x doesn't support Ruby 1.8.7
@@ -24,3 +23,28 @@ matrix:
24
23
  env: FORTITUDE_NATIVE_EXTENSIONS=false FORTITUDE_SPECS_RAILS_VERSION=4.1.1
25
24
  - rvm: 1.8.7
26
25
  env: FORTITUDE_SPECS_RAILS_VERSION=4.0.5
26
+ # 2014-06-19 ageweke -- ARGH. After trying about seventeen different things, no matter what I do,
27
+ # Travis fails JRuby builds about 20% of the time with "Killed". Their documentation indicates that this
28
+ # is likely an out-of-memory issue (i.e., entire VM's memory is consumed). However, I'm running JRuby with
29
+ # only 128MB allocated to each VM (per above) -- yuck -- and it's still happening; this makes no sense, as it
30
+ # would take something like 20+ concurrent JRuby processes to consume 3GB, and we should never be running
31
+ # more than 2-3.
32
+ #
33
+ # At this point, I have little choice other than to mark these as 'allowed failures', and check in on each
34
+ # one manually to make sure there aren't other failures, too. This is very frustrating, but I can't seem to
35
+ # find a way around it. If there's a fix out there somewhere, I'm all ears!
36
+ allow_failures:
37
+ - rvm: jruby-1.7.12
38
+ env: FORTITUDE_SPECS_RAILS_VERSION=4.1.1
39
+ - rvm: jruby-1.7.12
40
+ env: FORTITUDE_SPECS_RAILS_VERSION=4.0.5
41
+ - rvm: jruby-1.7.12
42
+ env: FORTITUDE_SPECS_RAILS_VERSION=3.2.18
43
+ - rvm: jruby-1.7.12
44
+ env: FORTITUDE_SPECS_RAILS_VERSION=3.1.12
45
+ - rvm: jruby-1.7.12
46
+ env: FORTITUDE_SPECS_RAILS_VERSION=3.0.20
47
+ - rvm: jruby-1.7.12
48
+ env: FORTITUDE_NATIVE_EXTENSIONS=false FORTITUDE_SPECS_RAILS_VERSION=4.1.1
49
+ - rvm: jruby-1.7.12
50
+ env: FORTITUDE_NATIVE_EXTENSIONS=false FORTITUDE_SPECS_RAILS_VERSION=3.0.20
data/CHANGES.md ADDED
@@ -0,0 +1,29 @@
1
+ # Fortitude Releases
2
+
3
+ ## 0.0.2, 21 June 2014
4
+
5
+ * Void tags (those that can't take content, ever, like `<hr>` or `<br>`) are now never closed in HTML4 doctypes
6
+ (_i.e._, just output as plain `<hr>`, with no close tag), since using self-closing syntax (`<hr/>`) is
7
+ [broken](http://stackoverflow.com/questions/3558119/are-self-closing-tags-valid-in-html5) and an end tag (`</hr>`)
8
+ is illegal according to the [W3C Validator](http://validator.w3.org/). In XHTML doctypes, they are always closed
9
+ using self-closing syntax (`<hr/>`) since they have to be closed somehow and that's a good way to indicate that
10
+ they are void (can't ever take content). In HTML5, they are left unclosed by default (since HTML5 knows they're void
11
+ and isn't expecting an end tag for them, ever), but you can use `close_void_tags true` to add self-closing syntax
12
+ for them (`<br/>`) if you want, since
13
+ [that is now allowed in HTML5](http://stackoverflow.com/questions/3558119/are-self-closing-tags-valid-in-html5).
14
+ See [this article](http://www.colorglare.com/2014/02/03/to-close-or-not-to-close.html) for even more discussion.
15
+ * Empty tags (those that _can_ take content, but just happen not to) are now always closed using a separate tag
16
+ (_e.g._, `<p></p>`), since it is
17
+ [not legal or correct](http://stackoverflow.com/questions/3558119/are-self-closing-tags-valid-in-html5) to use
18
+ self-closing syntax (`<p/>`) here in HTML doctypes (HTML4 or HTML5), and it is perfectly legal in XHTML doctypes to
19
+ use a separate closing tag &mdash; and, in a way, nice, since it lets you visually differentiate between void tags
20
+ and normal tags that just happen to be empty.
21
+ * Very significant internal refactoring of code to make development easier, and new developers' lives easier.
22
+ * Fixed support for Tilt < 2.x; earlier Tilt versions expect to be able to instantiate a template class with an empty
23
+ string and have it not raise an exception, as a way of testing whether an engine works. (Empty strings are not
24
+ valid Fortitude templates, since we expect to see a class declaration in there.) Now we trap that case explicitly to
25
+ do nothing, which allows Tilt 1.4.x to work.
26
+
27
+ ## 0.0.1, 18 June 2014
28
+
29
+ * Very first release of Fortitude.
data/lib/fortitude.rb CHANGED
@@ -1,93 +1,7 @@
1
1
  require "fortitude/version"
2
-
3
- module Fortitude
4
- module Widgets
5
- autoload :Html5, 'fortitude/widgets/html5'
6
- autoload :Html4Strict, 'fortitude/widgets/html4_strict'
7
- autoload :Html4Transitional, 'fortitude/widgets/html4_transitional'
8
- autoload :Html4Frameset, 'fortitude/widgets/html4_frameset'
9
- autoload :Xhtml10Strict, 'fortitude/widgets/xhtml10_strict'
10
- autoload :Xhtml10Transitional, 'fortitude/widgets/xhtml10_transitional'
11
- autoload :Xhtml10Frameset, 'fortitude/widgets/xhtml10_frameset'
12
- autoload :Xhtml11, 'fortitude/widgets/xhtml11'
13
- end
14
- end
15
-
16
- # See if we can load Rails -- but don't fail if we can't; we'll just use this to decide whether we should
17
- # load the Railtie or not.
18
- begin
19
- gem 'rails'
20
- rescue Gem::LoadError => le
21
- # ok
22
- end
23
-
24
- begin
25
- require 'rails'
26
- rescue LoadError => le
27
- # ok
28
- end
29
-
30
- if defined?(::Rails)
31
- require 'action_view'
32
-
33
- require 'fortitude/rails/widget_methods'
34
- require 'fortitude/rails/renderer'
35
- require 'fortitude/rails/template_handler'
36
- require 'fortitude/railtie'
37
- else
38
- require 'fortitude/non_rails_widget_methods'
39
-
40
- ::String.class_eval do
41
- alias_method :original_concat, :concat
42
- end
43
- end
44
-
45
- require 'fortitude/widget'
46
-
47
- native_loaded = false
48
-
49
- if %w{false off 0}.include?((ENV['FORTITUDE_NATIVE_EXTENSIONS'] || '').strip.downcase)
50
- $stderr.puts <<-EOM
51
- WARNING: Fortitude native extensions disabled via environment variable FORTITUDE_NATIVE_EXTENSIONS.
52
- Performance may be reduced by a factor of 3-5x!
53
- EOM
54
- else
55
- begin
56
- if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
57
- require 'fortitude_jruby_native_ext.jar'
58
- else
59
- require File.join(File.dirname(__FILE__), 'fortitude_native_ext')
60
- end
61
-
62
- native_loaded = true
63
- rescue LoadError => le
64
- $stderr.puts <<-EOM
65
- WARNING: The Fortitude gem cannot load its native extensions. Performance may be reduced by a factor of 3-5x!
66
- Load path: #{$:.inspect}
67
- Error: #{le.message} (#{le.class})
68
- EOM
69
- native_loaded = false
70
- end
71
- end
72
-
73
- unless native_loaded
74
- require 'fortitude/fortitude_ruby_ext'
75
- end
76
-
77
- if defined?(::ActiveSupport::SafeBuffer)
78
- ::ActiveSupport::SafeBuffer.class_eval do
79
- public :original_concat
80
- end
81
- end
82
-
83
- begin
84
- require 'tilt'
85
- rescue LoadError => le
86
- # ok, whatever
87
- end
88
-
89
- if defined?(::Tilt)
90
- require 'fortitude/tilt/fortitude_template'
91
-
92
- Tilt.register(Fortitude::Tilt::FortitudeTemplate, 'rb')
93
- end
2
+ require "fortitude/widgets"
3
+ require "fortitude/rails"
4
+ require "fortitude/extensions/native_extensions"
5
+ require "fortitude/rendering_context"
6
+ require "fortitude/widget"
7
+ require "fortitude/tilt"
@@ -1,11 +1,13 @@
1
- require 'fortitude/doctypes/html5'
1
+ require 'fortitude/doctypes/base'
2
+ require 'fortitude/doctypes/html4'
3
+ require 'fortitude/doctypes/html4_frameset'
2
4
  require 'fortitude/doctypes/html4_strict'
3
5
  require 'fortitude/doctypes/html4_transitional'
4
- require 'fortitude/doctypes/html4_frameset'
5
- require 'fortitude/doctypes/unknown_doctype'
6
+ require 'fortitude/doctypes/html5'
7
+ require 'fortitude/doctypes/xhtml10'
8
+ require 'fortitude/doctypes/xhtml10_frameset'
6
9
  require 'fortitude/doctypes/xhtml10_strict'
7
10
  require 'fortitude/doctypes/xhtml10_transitional'
8
- require 'fortitude/doctypes/xhtml10_frameset'
9
11
  require 'fortitude/doctypes/xhtml11'
10
12
 
11
13
  module Fortitude
@@ -1,9 +1,9 @@
1
- require 'fortitude/tag_store'
1
+ require 'fortitude/tags/tag_store'
2
2
 
3
3
  module Fortitude
4
4
  module Doctypes
5
5
  class Base
6
- extend Fortitude::TagStore
6
+ extend Fortitude::Tags::TagStore
7
7
 
8
8
  class << self
9
9
  def delegate_tag_stores
@@ -30,6 +30,10 @@ module Fortitude
30
30
  w.doctype(@doctype_line)
31
31
  end
32
32
 
33
+ def close_void_tags_must_be
34
+ nil
35
+ end
36
+
33
37
  def to_s
34
38
  "<Doctype #{name.inspect}>"
35
39
  end
@@ -1,3 +1,4 @@
1
+ require 'fortitude/doctypes'
1
2
  require 'fortitude/doctypes/base'
2
3
  require 'fortitude/doctypes/html4_tags_strict'
3
4
 
@@ -12,7 +13,7 @@ module Fortitude
12
13
  false
13
14
  end
14
15
 
15
- def close_void_tags?
16
+ def close_void_tags_must_be
16
17
  false
17
18
  end
18
19
  end
@@ -1,5 +1,7 @@
1
+ require 'fortitude/doctypes'
1
2
  require 'fortitude/doctypes/html4'
2
3
  require 'fortitude/doctypes/html4_tags_frameset'
4
+ require 'fortitude/doctypes/html4_transitional'
3
5
 
4
6
  module Fortitude
5
7
  module Doctypes
@@ -1,3 +1,4 @@
1
+ require 'fortitude/doctypes'
1
2
  require 'fortitude/doctypes/html4'
2
3
 
3
4
  module Fortitude
@@ -1,10 +1,11 @@
1
- require 'fortitude/tag_store'
1
+ require 'fortitude/doctypes'
2
+ require 'fortitude/tags/tag_store'
2
3
  require 'fortitude/doctypes/html4_tags_transitional'
3
4
 
4
5
  module Fortitude
5
6
  module Doctypes
6
7
  module Html4TagsFrameset
7
- extend Fortitude::TagStore
8
+ extend Fortitude::Tags::TagStore
8
9
 
9
10
  class << self
10
11
  def delegate_tag_stores
@@ -1,9 +1,10 @@
1
- require 'fortitude/tag_store'
1
+ require 'fortitude/doctypes'
2
+ require 'fortitude/tags/tag_store'
2
3
 
3
4
  module Fortitude
4
5
  module Doctypes
5
6
  module Html4TagsStrict
6
- extend Fortitude::TagStore
7
+ extend Fortitude::Tags::TagStore
7
8
 
8
9
  # HTML4.01 DTD
9
10
  I18N_ATTRIBUTES = %w{lang dir}
@@ -1,10 +1,11 @@
1
- require 'fortitude/tag_store'
1
+ require 'fortitude/doctypes'
2
+ require 'fortitude/tags/tag_store'
2
3
  require 'fortitude/doctypes/html4_tags_strict'
3
4
 
4
5
  module Fortitude
5
6
  module Doctypes
6
7
  module Html4TagsTransitional
7
- extend Fortitude::TagStore
8
+ extend Fortitude::Tags::TagStore
8
9
 
9
10
  class << self
10
11
  def delegate_tag_stores
@@ -1,3 +1,4 @@
1
+ require 'fortitude/doctypes'
1
2
  require 'fortitude/doctypes/html4'
2
3
  require 'fortitude/doctypes/html4_tags_transitional'
3
4
 
@@ -1,3 +1,4 @@
1
+ require 'fortitude/doctypes'
1
2
  require 'fortitude/doctypes/base'
2
3
 
3
4
  module Fortitude
@@ -15,8 +16,8 @@ module Fortitude
15
16
  false
16
17
  end
17
18
 
18
- def close_void_tags?
19
- false
19
+ def close_void_tags_must_be
20
+ nil
20
21
  end
21
22
 
22
23
  # HTML5 spec, section 3.2.5
@@ -1,3 +1,4 @@
1
+ require 'fortitude/doctypes'
1
2
  require 'fortitude/doctypes/base'
2
3
 
3
4
  module Fortitude
@@ -1,3 +1,4 @@
1
+ require 'fortitude/doctypes'
1
2
  require 'fortitude/doctypes/base'
2
3
 
3
4
  module Fortitude
@@ -11,7 +12,7 @@ module Fortitude
11
12
  true
12
13
  end
13
14
 
14
- def close_void_tags?
15
+ def close_void_tags_must_be
15
16
  true
16
17
  end
17
18
  end
@@ -1,3 +1,4 @@
1
+ require 'fortitude/doctypes'
1
2
  require 'fortitude/doctypes/xhtml10'
2
3
 
3
4
  module Fortitude
@@ -1,3 +1,4 @@
1
+ require 'fortitude/doctypes'
1
2
  require 'fortitude/doctypes/xhtml10'
2
3
 
3
4
  module Fortitude
@@ -1,3 +1,4 @@
1
+ require 'fortitude/doctypes'
1
2
  require 'fortitude/doctypes/xhtml10'
2
3
 
3
4
  module Fortitude
@@ -1,3 +1,4 @@
1
+ require 'fortitude/doctypes'
1
2
  require 'fortitude/doctypes/base'
2
3
 
3
4
  module Fortitude
@@ -15,7 +16,7 @@ module Fortitude
15
16
  true
16
17
  end
17
18
 
18
- def close_void_tags?
19
+ def close_void_tags_must_be
19
20
  true
20
21
  end
21
22
 
@@ -13,17 +13,22 @@ require 'erb'
13
13
  end
14
14
 
15
15
  ::Hash.class_eval do
16
- FORTITUDE_HYPHEN = "-".html_safe.freeze
17
- FORTITUDE_EQUALS_QUOTE = "=\"".html_safe.freeze
18
- FORTITUDE_QUOTE = "\"".html_safe.freeze
19
- FORTITUDE_SPACE = " ".html_safe.freeze
20
-
21
- TARGET_BASE = "".html_safe.freeze
16
+ {
17
+ 'FORTITUDE_HYPHEN' => '-',
18
+ 'FORTITUDE_EQUALS_QUOTE' => '="',
19
+ 'FORTITUDE_QUOTE' => '"',
20
+ 'FORTITUDE_SPACE' => ' ',
21
+ 'TARGET_BASE' => ""
22
+ }.each do |constant_name, value|
23
+ value = value.html_safe if value.respond_to?(:html_safe)
24
+ value = value.freeze
25
+ const_set(constant_name, value)
26
+ end
22
27
 
23
28
  def fortitude_append_as_attributes(output, prefix)
24
29
  raise ArgumentError, "You can only append to a String" unless output.kind_of?(String)
25
30
 
26
- target = TARGET_BASE.dup
31
+ target = ::Hash::TARGET_BASE.dup
27
32
 
28
33
  each do |key, value|
29
34
  if value.kind_of?(Hash)
@@ -33,10 +38,10 @@ end
33
38
  else raise ArgumentError, "You can only use a String as a prefix"
34
39
  end
35
40
 
36
- new_prefix.original_concat(FORTITUDE_HYPHEN)
41
+ new_prefix.original_concat(::Hash::FORTITUDE_HYPHEN)
37
42
  value.fortitude_append_as_attributes(target, new_prefix)
38
43
  else
39
- target.original_concat(FORTITUDE_SPACE)
44
+ target.original_concat(::Hash::FORTITUDE_SPACE)
40
45
 
41
46
  case prefix
42
47
  when String then target.original_concat(prefix)
@@ -45,9 +50,9 @@ end
45
50
  end
46
51
 
47
52
  fortitude_append_to(key, target)
48
- target.original_concat(FORTITUDE_EQUALS_QUOTE)
53
+ target.original_concat(::Hash::FORTITUDE_EQUALS_QUOTE)
49
54
  fortitude_append_to(value, target)
50
- target.original_concat(FORTITUDE_QUOTE)
55
+ target.original_concat(::Hash::FORTITUDE_QUOTE)
51
56
  end
52
57
  end
53
58
 
@@ -0,0 +1,33 @@
1
+ native_loaded = false
2
+
3
+ if %w{false off 0}.include?((ENV['FORTITUDE_NATIVE_EXTENSIONS'] || '').strip.downcase)
4
+ $stderr.puts <<-EOM
5
+ WARNING: Fortitude native extensions disabled via environment variable FORTITUDE_NATIVE_EXTENSIONS.
6
+ Performance may be reduced by a factor of 3-5x!
7
+ EOM
8
+ else
9
+ begin
10
+ if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
11
+ require 'fortitude_jruby_native_ext.jar'
12
+ else
13
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'fortitude_native_ext'))
14
+ end
15
+
16
+ native_loaded = true
17
+ rescue LoadError => le
18
+ $stderr.puts <<-EOM
19
+ WARNING: The Fortitude gem cannot load its native extensions. Performance may be reduced by a factor of 3-5x!
20
+ Load path: #{$:.inspect}
21
+ Error: #{le.message} (#{le.class})
22
+ EOM
23
+ native_loaded = false
24
+ end
25
+ end
26
+
27
+ unless native_loaded
28
+ require 'fortitude/extensions/fortitude_ruby_ext'
29
+ end
30
+
31
+ require 'active_support'
32
+
33
+ ::ActiveSupport::SafeBuffer.class_eval { public :original_concat } if defined?(::ActiveSupport::SafeBuffer)