activesupport 1.4.4 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of activesupport might be problematic. Click here for more details.

Files changed (126) hide show
  1. data/CHANGELOG +263 -7
  2. data/lib/active_support.rb +9 -4
  3. data/lib/active_support/basic_object.rb +5 -0
  4. data/lib/active_support/buffered_logger.rb +107 -0
  5. data/lib/active_support/clean_logger.rb +94 -5
  6. data/lib/active_support/core_ext.rb +4 -1
  7. data/lib/active_support/core_ext/array.rb +8 -2
  8. data/lib/active_support/core_ext/array/access.rb +28 -0
  9. data/lib/active_support/core_ext/array/conversions.rb +28 -15
  10. data/lib/active_support/core_ext/array/extract_options.rb +19 -0
  11. data/lib/active_support/core_ext/array/grouping.rb +20 -7
  12. data/lib/active_support/core_ext/array/random_access.rb +12 -0
  13. data/lib/active_support/core_ext/bigdecimal.rb +1 -2
  14. data/lib/active_support/core_ext/bigdecimal/{formatting.rb → conversions.rb} +1 -2
  15. data/lib/active_support/core_ext/blank.rb +2 -8
  16. data/lib/active_support/core_ext/cgi.rb +2 -2
  17. data/lib/active_support/core_ext/class.rb +4 -3
  18. data/lib/active_support/core_ext/class/attribute_accessors.rb +1 -1
  19. data/lib/active_support/core_ext/class/delegating_attributes.rb +40 -0
  20. data/lib/active_support/core_ext/class/inheritable_attributes.rb +3 -3
  21. data/lib/active_support/core_ext/class/removal.rb +2 -2
  22. data/lib/active_support/core_ext/date.rb +5 -1
  23. data/lib/active_support/core_ext/date/behavior.rb +13 -0
  24. data/lib/active_support/core_ext/date/calculations.rb +188 -0
  25. data/lib/active_support/core_ext/date/conversions.rb +69 -13
  26. data/lib/active_support/core_ext/date_time.rb +10 -0
  27. data/lib/active_support/core_ext/date_time/calculations.rb +77 -0
  28. data/lib/active_support/core_ext/date_time/conversions.rb +54 -0
  29. data/lib/active_support/core_ext/duplicable.rb +37 -0
  30. data/lib/active_support/core_ext/enumerable.rb +1 -0
  31. data/lib/active_support/core_ext/exception.rb +2 -2
  32. data/lib/active_support/core_ext/file.rb +21 -0
  33. data/lib/active_support/core_ext/float.rb +5 -0
  34. data/lib/active_support/core_ext/float/rounding.rb +24 -0
  35. data/lib/active_support/core_ext/hash.rb +5 -5
  36. data/lib/active_support/core_ext/hash/conversions.rb +86 -34
  37. data/lib/active_support/core_ext/hash/diff.rb +8 -0
  38. data/lib/active_support/core_ext/hash/except.rb +24 -0
  39. data/lib/active_support/core_ext/hash/indifferent_access.rb +15 -2
  40. data/lib/active_support/core_ext/hash/keys.rb +10 -3
  41. data/lib/active_support/core_ext/hash/reverse_merge.rb +2 -2
  42. data/lib/active_support/core_ext/hash/slice.rb +28 -0
  43. data/lib/active_support/core_ext/integer.rb +2 -2
  44. data/lib/active_support/core_ext/kernel.rb +5 -4
  45. data/lib/active_support/core_ext/kernel/debugger.rb +13 -0
  46. data/lib/active_support/core_ext/module.rb +8 -7
  47. data/lib/active_support/core_ext/module/aliasing.rb +17 -5
  48. data/lib/active_support/core_ext/module/attr_accessor_with_default.rb +31 -0
  49. data/lib/active_support/core_ext/module/attribute_accessors.rb +1 -1
  50. data/lib/active_support/core_ext/module/delegation.rb +21 -0
  51. data/lib/active_support/core_ext/name_error.rb +2 -2
  52. data/lib/active_support/core_ext/numeric.rb +2 -2
  53. data/lib/active_support/core_ext/numeric/time.rb +30 -11
  54. data/lib/active_support/core_ext/object.rb +3 -2
  55. data/lib/active_support/core_ext/object/extending.rb +40 -29
  56. data/lib/active_support/core_ext/object/instance_variables.rb +22 -0
  57. data/lib/active_support/core_ext/object/misc.rb +29 -4
  58. data/lib/active_support/core_ext/pathname.rb +1 -1
  59. data/lib/active_support/core_ext/range.rb +7 -1
  60. data/lib/active_support/core_ext/range/blockless_step.rb +22 -0
  61. data/lib/active_support/core_ext/range/conversions.rb +8 -6
  62. data/lib/active_support/core_ext/range/include_range.rb +22 -0
  63. data/lib/active_support/core_ext/range/overlaps.rb +12 -0
  64. data/lib/active_support/core_ext/string.rb +10 -7
  65. data/lib/active_support/core_ext/string/conversions.rb +5 -1
  66. data/lib/active_support/core_ext/string/unicode.rb +2 -2
  67. data/lib/active_support/core_ext/string/xchar.rb +11 -0
  68. data/lib/active_support/core_ext/symbol.rb +12 -10
  69. data/lib/active_support/core_ext/test.rb +1 -0
  70. data/lib/active_support/core_ext/test/unit/assertions.rb +62 -0
  71. data/lib/active_support/core_ext/time.rb +4 -2
  72. data/lib/active_support/core_ext/time/behavior.rb +13 -0
  73. data/lib/active_support/core_ext/time/calculations.rb +87 -54
  74. data/lib/active_support/core_ext/time/conversions.rb +71 -10
  75. data/lib/active_support/dependencies.rb +25 -24
  76. data/lib/active_support/deprecation.rb +4 -2
  77. data/lib/active_support/duration.rb +86 -0
  78. data/lib/active_support/inflections.rb +2 -1
  79. data/lib/active_support/inflector.rb +13 -6
  80. data/lib/active_support/json.rb +22 -39
  81. data/lib/active_support/json/decoding.rb +60 -0
  82. data/lib/active_support/json/encoders/date.rb +5 -0
  83. data/lib/active_support/json/encoders/date_time.rb +5 -0
  84. data/lib/active_support/json/encoders/enumerable.rb +12 -0
  85. data/lib/active_support/json/encoders/false_class.rb +5 -0
  86. data/lib/active_support/json/encoders/hash.rb +50 -0
  87. data/lib/active_support/json/encoders/nil_class.rb +5 -0
  88. data/lib/active_support/json/encoders/numeric.rb +5 -0
  89. data/lib/active_support/json/encoders/object.rb +6 -0
  90. data/lib/active_support/json/encoders/regexp.rb +5 -0
  91. data/lib/active_support/json/encoders/string.rb +30 -0
  92. data/lib/active_support/json/encoders/symbol.rb +5 -0
  93. data/lib/active_support/json/encoders/time.rb +5 -0
  94. data/lib/active_support/json/encoders/true_class.rb +5 -0
  95. data/lib/active_support/json/encoding.rb +38 -0
  96. data/lib/active_support/json/variable.rb +10 -0
  97. data/lib/active_support/multibyte.rb +7 -5
  98. data/lib/active_support/multibyte/chars.rb +6 -0
  99. data/lib/active_support/multibyte/handlers/utf8_handler.rb +115 -5
  100. data/lib/active_support/option_merger.rb +7 -7
  101. data/lib/active_support/ordered_options.rb +22 -17
  102. data/lib/active_support/test_case.rb +5 -0
  103. data/lib/active_support/testing.rb +1 -0
  104. data/lib/active_support/testing/default.rb +12 -0
  105. data/lib/active_support/values/time_zone.rb +3 -3
  106. data/lib/active_support/vendor.rb +14 -0
  107. data/lib/active_support/vendor/builder-2.1.2/blankslate.rb +113 -0
  108. data/lib/active_support/vendor/{builder.rb → builder-2.1.2/builder.rb} +0 -0
  109. data/lib/active_support/vendor/builder-2.1.2/builder/blankslate.rb +20 -0
  110. data/lib/active_support/vendor/builder-2.1.2/builder/css.rb +250 -0
  111. data/lib/active_support/vendor/{builder → builder-2.1.2/builder}/xchar.rb +11 -8
  112. data/lib/active_support/vendor/{builder → builder-2.1.2/builder}/xmlbase.rb +38 -44
  113. data/lib/active_support/vendor/{builder → builder-2.1.2/builder}/xmlevents.rb +1 -1
  114. data/lib/active_support/vendor/{builder → builder-2.1.2/builder}/xmlmarkup.rb +40 -39
  115. data/lib/active_support/vendor/{xml_simple.rb → xml-simple-1.0.11/xmlsimple.rb} +3 -3
  116. data/lib/active_support/version.rb +3 -3
  117. data/lib/active_support/whiny_nil.rb +12 -12
  118. data/lib/activesupport.rb +1 -0
  119. metadata +69 -17
  120. data/lib/active_support/binding_of_caller.rb +0 -84
  121. data/lib/active_support/breakpoint.rb +0 -528
  122. data/lib/active_support/caching_tools.rb +0 -62
  123. data/lib/active_support/json/encoders.rb +0 -25
  124. data/lib/active_support/json/encoders/core.rb +0 -70
  125. data/lib/active_support/reloadable.rb +0 -60
  126. data/lib/active_support/vendor/builder/blankslate.rb +0 -63
@@ -1,25 +1,25 @@
1
1
  module ActiveSupport
2
2
  class OptionMerger #:nodoc:
3
- instance_methods.each do |method|
4
- undef_method(method) if method !~ /^(__|instance_eval|class)/
3
+ instance_methods.each do |method|
4
+ undef_method(method) if method !~ /^(__|instance_eval|class|object_id)/
5
5
  end
6
-
6
+
7
7
  def initialize(context, options)
8
8
  @context, @options = context, options
9
9
  end
10
-
10
+
11
11
  private
12
12
  def method_missing(method, *arguments, &block)
13
13
  merge_argument_options! arguments
14
- @context.send(method, *arguments, &block)
14
+ @context.send!(method, *arguments, &block)
15
15
  end
16
-
16
+
17
17
  def merge_argument_options!(arguments)
18
18
  arguments << if arguments.last.respond_to? :to_hash
19
19
  @options.merge(arguments.pop)
20
20
  else
21
21
  @options.dup
22
- end
22
+ end
23
23
  end
24
24
  end
25
25
  end
@@ -1,26 +1,31 @@
1
1
  # OrderedHash is namespaced to prevent conflicts with other implementations
2
2
  module ActiveSupport
3
- class OrderedHash < Array #:nodoc:
4
- def []=(key, value)
5
- if pair = assoc(key)
6
- pair.pop
7
- pair << value
8
- else
9
- self << [key, value]
3
+ # Hash is ordered in Ruby 1.9!
4
+ if RUBY_VERSION >= '1.9'
5
+ OrderedHash = ::Hash
6
+ else
7
+ class OrderedHash < Array #:nodoc:
8
+ def []=(key, value)
9
+ if pair = assoc(key)
10
+ pair.pop
11
+ pair << value
12
+ else
13
+ self << [key, value]
14
+ end
10
15
  end
11
- end
12
16
 
13
- def [](key)
14
- pair = assoc(key)
15
- pair ? pair.last : nil
16
- end
17
+ def [](key)
18
+ pair = assoc(key)
19
+ pair ? pair.last : nil
20
+ end
17
21
 
18
- def keys
19
- collect { |key, value| key }
20
- end
22
+ def keys
23
+ collect { |key, value| key }
24
+ end
21
25
 
22
- def values
23
- collect { |key, value| value }
26
+ def values
27
+ collect { |key, value| value }
28
+ end
24
29
  end
25
30
  end
26
31
  end
@@ -0,0 +1,5 @@
1
+ module ActiveSupport
2
+ class TestCase < Test::Unit::TestCase
3
+ include ActiveSupport::Testing::Default
4
+ end
5
+ end
@@ -0,0 +1 @@
1
+ require 'active_support/testing/default'
@@ -0,0 +1,12 @@
1
+ module ActiveSupport
2
+ module Testing
3
+ module Default
4
+ def run(*args)
5
+ #method_name appears to be a symbol on 1.8.4 and a string on 1.8.6
6
+ return if @method_name.to_s == "default_test"
7
+ super
8
+ end
9
+ end
10
+ end
11
+ end
12
+
@@ -76,7 +76,7 @@ class TimeZone
76
76
  # Create a new TimeZone instance with the given name and offset.
77
77
  def create(name, offset)
78
78
  zone = allocate
79
- zone.send :initialize, name, offset
79
+ zone.send!(:initialize, name, offset)
80
80
  zone
81
81
  end
82
82
 
@@ -98,8 +98,8 @@ class TimeZone
98
98
  [-36_000, "Hawaii" ],
99
99
  [-32_400, "Alaska" ],
100
100
  [-28_800, "Pacific Time (US & Canada)", "Tijuana" ],
101
- [-25_200, "Mountain Time (US & Canada)", "Chihuahua", "La Paz",
102
- "Mazatlan", "Arizona" ],
101
+ [-25_200, "Mountain Time (US & Canada)", "Chihuahua", "Mazatlan",
102
+ "Arizona" ],
103
103
  [-21_600, "Central Time (US & Canada)", "Saskatchewan", "Guadalajara",
104
104
  "Mexico City", "Monterrey", "Central America" ],
105
105
  [-18_000, "Eastern Time (US & Canada)", "Indiana (East)", "Bogota",
@@ -0,0 +1,14 @@
1
+ # Prefer gems to the bundled libs.
2
+ require 'rubygems'
3
+
4
+ begin
5
+ gem 'builder', '~> 2.1.2'
6
+ rescue Gem::LoadError
7
+ $:.unshift "#{File.dirname(__FILE__)}/vendor/builder-2.1.2"
8
+ end
9
+
10
+ begin
11
+ gem 'xml-simple', '~> 1.0.11'
12
+ rescue Gem::LoadError
13
+ $:.unshift "#{File.dirname(__FILE__)}/vendor/xml-simple-1.0.11"
14
+ end
@@ -0,0 +1,113 @@
1
+ #!/usr/bin/env ruby
2
+ #--
3
+ # Copyright 2004, 2006 by Jim Weirich (jim@weirichhouse.org).
4
+ # All rights reserved.
5
+
6
+ # Permission is granted for use, copying, modification, distribution,
7
+ # and distribution of modified versions of this work as long as the
8
+ # above copyright notice is included.
9
+ #++
10
+
11
+ ######################################################################
12
+ # BlankSlate provides an abstract base class with no predefined
13
+ # methods (except for <tt>\_\_send__</tt> and <tt>\_\_id__</tt>).
14
+ # BlankSlate is useful as a base class when writing classes that
15
+ # depend upon <tt>method_missing</tt> (e.g. dynamic proxies).
16
+ #
17
+ class BlankSlate
18
+ class << self
19
+
20
+ # Hide the method named +name+ in the BlankSlate class. Don't
21
+ # hide +instance_eval+ or any method beginning with "__".
22
+ def hide(name)
23
+ if instance_methods.include?(name.to_s) and
24
+ name !~ /^(__|instance_eval)/
25
+ @hidden_methods ||= {}
26
+ @hidden_methods[name.to_sym] = instance_method(name)
27
+ undef_method name
28
+ end
29
+ end
30
+
31
+ def find_hidden_method(name)
32
+ @hidden_methods ||= {}
33
+ @hidden_methods[name] || superclass.find_hidden_method(name)
34
+ end
35
+
36
+ # Redefine a previously hidden method so that it may be called on a blank
37
+ # slate object.
38
+ def reveal(name)
39
+ bound_method = nil
40
+ unbound_method = find_hidden_method(name)
41
+ fail "Don't know how to reveal method '#{name}'" unless unbound_method
42
+ define_method(name) do |*args|
43
+ bound_method ||= unbound_method.bind(self)
44
+ bound_method.call(*args)
45
+ end
46
+ end
47
+ end
48
+
49
+ instance_methods.each { |m| hide(m) }
50
+ end
51
+
52
+ ######################################################################
53
+ # Since Ruby is very dynamic, methods added to the ancestors of
54
+ # BlankSlate <em>after BlankSlate is defined</em> will show up in the
55
+ # list of available BlankSlate methods. We handle this by defining a
56
+ # hook in the Object and Kernel classes that will hide any method
57
+ # defined after BlankSlate has been loaded.
58
+ #
59
+ module Kernel
60
+ class << self
61
+ alias_method :blank_slate_method_added, :method_added
62
+
63
+ # Detect method additions to Kernel and remove them in the
64
+ # BlankSlate class.
65
+ def method_added(name)
66
+ result = blank_slate_method_added(name)
67
+ return result if self != Kernel
68
+ BlankSlate.hide(name)
69
+ result
70
+ end
71
+ end
72
+ end
73
+
74
+ ######################################################################
75
+ # Same as above, except in Object.
76
+ #
77
+ class Object
78
+ class << self
79
+ alias_method :blank_slate_method_added, :method_added
80
+
81
+ # Detect method additions to Object and remove them in the
82
+ # BlankSlate class.
83
+ def method_added(name)
84
+ result = blank_slate_method_added(name)
85
+ return result if self != Object
86
+ BlankSlate.hide(name)
87
+ result
88
+ end
89
+
90
+ def find_hidden_method(name)
91
+ nil
92
+ end
93
+ end
94
+ end
95
+
96
+ ######################################################################
97
+ # Also, modules included into Object need to be scanned and have their
98
+ # instance methods removed from blank slate. In theory, modules
99
+ # included into Kernel would have to be removed as well, but a
100
+ # "feature" of Ruby prevents late includes into modules from being
101
+ # exposed in the first place.
102
+ #
103
+ class Module
104
+ alias blankslate_original_append_features append_features
105
+ def append_features(mod)
106
+ result = blankslate_original_append_features(mod)
107
+ return result if mod != Object
108
+ instance_methods.each do |name|
109
+ BlankSlate.hide(name)
110
+ end
111
+ result
112
+ end
113
+ end
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+ #--
3
+ # Copyright 2004, 2006 by Jim Weirich (jim@weirichhouse.org).
4
+ # All rights reserved.
5
+
6
+ # Permission is granted for use, copying, modification, distribution,
7
+ # and distribution of modified versions of this work as long as the
8
+ # above copyright notice is included.
9
+ #++
10
+
11
+ require 'blankslate'
12
+
13
+ ######################################################################
14
+ # BlankSlate has been promoted to a top level name and is now
15
+ # available as a standalone gem. We make the name available in the
16
+ # Builder namespace for compatibility.
17
+ #
18
+ module Builder
19
+ BlankSlate = ::BlankSlate
20
+ end
@@ -0,0 +1,250 @@
1
+ #!/usr/bin/env ruby
2
+ #--
3
+ # Copyright 2004, 2005 by Jim Weirich (jim@weirichhouse.org).
4
+ # Copyright 2005 by Scott Barron (scott@elitists.net).
5
+ # All rights reserved.
6
+ #
7
+ # Permission is granted for use, copying, modification, distribution,
8
+ # and distribution of modified versions of this work as long as the
9
+ # above copyright notice is included.
10
+ #
11
+ # Much of this is taken from Jim's work in xmlbase.rb and xmlmarkup.rb.
12
+ # Documentation has also been copied and pasted and modified to reflect
13
+ # that we're building CSS here instead of XML. Jim is conducting the
14
+ # orchestra here and I'm just off in the corner playing a flute.
15
+ #++
16
+
17
+ # Provide a flexible and easy to use Builder for creating Cascading
18
+ # Style Sheets (CSS).
19
+
20
+
21
+ require 'builder/blankslate'
22
+
23
+ module Builder
24
+
25
+ # Create a Cascading Style Sheet (CSS) using Ruby.
26
+ #
27
+ # Example usage:
28
+ #
29
+ # css = Builder::CSS.new
30
+ #
31
+ # text_color = '#7F7F7F'
32
+ # preferred_fonts = 'Helvetica, Arial, sans_serif'
33
+ #
34
+ # css.comment! 'This is our stylesheet'
35
+ # css.body {
36
+ # background_color '#FAFAFA'
37
+ # font_size 'small'
38
+ # font_family preferred_fonts
39
+ # color text_color
40
+ # }
41
+ #
42
+ # css.id!('navbar') {
43
+ # width '500px'
44
+ # }
45
+ #
46
+ # css.class!('navitem') {
47
+ # color 'red'
48
+ # }
49
+ #
50
+ # css.a :hover {
51
+ # text_decoration 'underline'
52
+ # }
53
+ #
54
+ # css.div(:id => 'menu') {
55
+ # background 'green'
56
+ # }
57
+ #
58
+ # css.div(:class => 'foo') {
59
+ # background 'red'
60
+ # }
61
+ #
62
+ # This will yield the following stylesheet:
63
+ #
64
+ # /* This is our stylesheet */
65
+ # body {
66
+ # background_color: #FAFAFA;
67
+ # font_size: small;
68
+ # font_family: Helvetica, Arial, sans_serif;
69
+ # color: #7F7F7F;
70
+ # }
71
+ #
72
+ # #navbar {
73
+ # width: 500px;
74
+ # }
75
+ #
76
+ # .navitem {
77
+ # color: red;
78
+ # }
79
+ #
80
+ # a:hover {
81
+ # text_decoration: underline;
82
+ # }
83
+ #
84
+ # div#menu {
85
+ # background: green;
86
+ # }
87
+ #
88
+ # div.foo {
89
+ # background: red;
90
+ # }
91
+ #
92
+ class CSS < BlankSlate
93
+
94
+ # Create a CSS builder.
95
+ #
96
+ # out:: Object receiving the markup.1 +out+ must respond to
97
+ # <tt><<</tt>.
98
+ # indent:: Number of spaces used for indentation (0 implies no
99
+ # indentation and no line breaks).
100
+ #
101
+ def initialize(indent=2)
102
+ @indent = indent
103
+ @target = []
104
+ @parts = []
105
+ @library = {}
106
+ end
107
+
108
+ def +(part)
109
+ _join_with_op! '+'
110
+ self
111
+ end
112
+
113
+ def >>(part)
114
+ _join_with_op! ''
115
+ self
116
+ end
117
+
118
+ def >(part)
119
+ _join_with_op! '>'
120
+ self
121
+ end
122
+
123
+ def |(part)
124
+ _join_with_op! ','
125
+ self
126
+ end
127
+
128
+ # Return the target of the builder
129
+ def target!
130
+ @target * ''
131
+ end
132
+
133
+ # Create a comment string in the output.
134
+ def comment!(comment_text)
135
+ @target << "/* #{comment_text} */\n"
136
+ end
137
+
138
+ def id!(arg, &block)
139
+ _start_container('#'+arg.to_s, nil, block_given?)
140
+ _css_block(block) if block
141
+ _unify_block
142
+ self
143
+ end
144
+
145
+ def class!(arg, &block)
146
+ _start_container('.'+arg.to_s, nil, block_given?)
147
+ _css_block(block) if block
148
+ _unify_block
149
+ self
150
+ end
151
+
152
+ def store!(sym, &block)
153
+ @library[sym] = block.to_proc
154
+ end
155
+
156
+ def group!(*args, &block)
157
+ args.each do |arg|
158
+ if arg.is_a?(Symbol)
159
+ instance_eval(&@library[arg])
160
+ else
161
+ instance_eval(&arg)
162
+ end
163
+ _text ', ' unless arg == args.last
164
+ end
165
+ if block
166
+ _css_block(block)
167
+ _unify_block
168
+ end
169
+ end
170
+
171
+ def method_missing(sym, *args, &block)
172
+ sym = "#{sym}:#{args.shift}" if args.first.kind_of?(Symbol)
173
+ if block
174
+ _start_container(sym, args.first)
175
+ _css_block(block)
176
+ _unify_block
177
+ elsif @in_block
178
+ _indent
179
+ _css_line(sym, *args)
180
+ _newline
181
+ return self
182
+ else
183
+ _start_container(sym, args.first, false)
184
+ _unify_block
185
+ end
186
+ self
187
+ end
188
+
189
+ # "Cargo culted" from Jim who also "cargo culted" it. See xmlbase.rb.
190
+ def nil?
191
+ false
192
+ end
193
+
194
+ private
195
+ def _unify_block
196
+ @target << @parts * ''
197
+ @parts = []
198
+ end
199
+
200
+ def _join_with_op!(op)
201
+ rhs, lhs = @target.pop, @target.pop
202
+ @target << "#{lhs} #{op} #{rhs}"
203
+ end
204
+
205
+ def _text(text)
206
+ @parts << text
207
+ end
208
+
209
+ def _css_block(block)
210
+ _newline
211
+ _nested_structures(block)
212
+ _end_container
213
+ _end_block
214
+ end
215
+
216
+ def _end_block
217
+ _newline
218
+ _newline
219
+ end
220
+
221
+ def _newline
222
+ _text "\n"
223
+ end
224
+
225
+ def _indent
226
+ _text ' ' * @indent
227
+ end
228
+
229
+ def _nested_structures(block)
230
+ @in_block = true
231
+ self.instance_eval(&block)
232
+ @in_block = false
233
+ end
234
+
235
+ def _start_container(sym, atts = {}, with_bracket = true)
236
+ selector = sym.to_s
237
+ selector << ".#{atts[:class]}" if atts && atts[:class]
238
+ selector << '#' + "#{atts[:id]}" if atts && atts[:id]
239
+ @parts << "#{selector}#{with_bracket ? ' {' : ''}"
240
+ end
241
+
242
+ def _end_container
243
+ @parts << "}"
244
+ end
245
+
246
+ def _css_line(sym, *args)
247
+ _text("#{sym.to_s.gsub('_','-')}: #{args * ' '};")
248
+ end
249
+ end
250
+ end