csd 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (258) hide show
  1. data/COPYING +1 -2
  2. data/README.rdoc +7 -1
  3. data/Rakefile +7 -2
  4. data/VERSION +1 -1
  5. data/csd.gemspec +18 -216
  6. data/lib/csd.rb +6 -16
  7. data/lib/csd/application.rb +2 -2
  8. data/lib/csd/application/default.rb +15 -14
  9. data/lib/csd/application/default/base.rb +1 -1
  10. data/lib/csd/application/minisip.rb +43 -11
  11. data/lib/csd/application/minisip/about.yml +5 -5
  12. data/lib/csd/application/minisip/base.rb +82 -70
  13. data/lib/csd/application/minisip/error.rb +1 -1
  14. data/lib/csd/application/minisip/options/common.rb +1 -1
  15. data/lib/csd/application/minisip/options/compile.rb +1 -1
  16. data/lib/csd/application/minisip/options/package.rb +1 -1
  17. data/lib/csd/application/minisip/unix.rb +40 -27
  18. data/lib/csd/application/minisip/unix/darwin.rb +12 -0
  19. data/lib/csd/application/minisip/unix/linux.rb +1 -11
  20. data/lib/csd/application/minisip/unix/linux/debian.rb +14 -25
  21. data/lib/csd/application/minisip/unix/linux/debian/ubuntu10.rb +12 -13
  22. data/lib/csd/applications.rb +5 -5
  23. data/lib/csd/commands.rb +164 -89
  24. data/lib/csd/container.rb +61 -0
  25. data/lib/csd/error.rb +10 -1
  26. data/lib/csd/extensions.rb +3 -2
  27. data/lib/csd/extensions/core/array.rb +29 -1
  28. data/lib/csd/extensions/core/dir.rb +15 -24
  29. data/lib/csd/extensions/core/object.rb +10 -2
  30. data/lib/csd/extensions/core/option_parser.rb +22 -3
  31. data/lib/csd/extensions/core/pathname.rb +30 -2
  32. data/lib/csd/extensions/core/string.rb +51 -4
  33. data/lib/csd/extensions/gem/platform.rb +18 -3
  34. data/lib/csd/{options.rb → options_parser.rb} +16 -20
  35. data/lib/csd/path_container.rb +24 -0
  36. data/lib/csd/user_interface.rb +2 -0
  37. data/lib/csd/user_interface/base.rb +26 -0
  38. data/lib/csd/user_interface/cli.rb +37 -0
  39. data/lib/csd/vendor/active_support/MIT-LICENSE +20 -0
  40. data/lib/csd/vendor/active_support/inflector.rb +155 -0
  41. data/lib/csd/vendor/term/GPL2-LICENSE +339 -0
  42. data/lib/csd/vendor/term/ansicolor.rb +113 -0
  43. data/lib/csd/version.rb +13 -4
  44. data/test/application/test_minisip.rb +45 -0
  45. data/test/functional/test_applications.rb +10 -16
  46. data/test/functional/test_commands.rb +260 -23
  47. data/test/unit/test_string.rb +1 -1
  48. metadata +18 -216
  49. data/lib/active_support.rb +0 -75
  50. data/lib/active_support/all.rb +0 -3
  51. data/lib/active_support/backtrace_cleaner.rb +0 -94
  52. data/lib/active_support/base64.rb +0 -42
  53. data/lib/active_support/basic_object.rb +0 -21
  54. data/lib/active_support/benchmarkable.rb +0 -60
  55. data/lib/active_support/buffered_logger.rb +0 -132
  56. data/lib/active_support/builder.rb +0 -6
  57. data/lib/active_support/cache.rb +0 -626
  58. data/lib/active_support/cache/compressed_mem_cache_store.rb +0 -13
  59. data/lib/active_support/cache/file_store.rb +0 -188
  60. data/lib/active_support/cache/mem_cache_store.rb +0 -191
  61. data/lib/active_support/cache/memory_store.rb +0 -159
  62. data/lib/active_support/cache/strategy/local_cache.rb +0 -164
  63. data/lib/active_support/cache/synchronized_memory_store.rb +0 -11
  64. data/lib/active_support/callbacks.rb +0 -600
  65. data/lib/active_support/concern.rb +0 -29
  66. data/lib/active_support/configurable.rb +0 -36
  67. data/lib/active_support/core_ext.rb +0 -3
  68. data/lib/active_support/core_ext/array.rb +0 -7
  69. data/lib/active_support/core_ext/array/access.rb +0 -46
  70. data/lib/active_support/core_ext/array/conversions.rb +0 -164
  71. data/lib/active_support/core_ext/array/extract_options.rb +0 -29
  72. data/lib/active_support/core_ext/array/grouping.rb +0 -100
  73. data/lib/active_support/core_ext/array/random_access.rb +0 -20
  74. data/lib/active_support/core_ext/array/uniq_by.rb +0 -17
  75. data/lib/active_support/core_ext/array/wrap.rb +0 -22
  76. data/lib/active_support/core_ext/benchmark.rb +0 -7
  77. data/lib/active_support/core_ext/big_decimal.rb +0 -1
  78. data/lib/active_support/core_ext/big_decimal/conversions.rb +0 -27
  79. data/lib/active_support/core_ext/cgi.rb +0 -1
  80. data/lib/active_support/core_ext/cgi/escape_skipping_slashes.rb +0 -19
  81. data/lib/active_support/core_ext/class.rb +0 -4
  82. data/lib/active_support/core_ext/class/attribute.rb +0 -67
  83. data/lib/active_support/core_ext/class/attribute_accessors.rb +0 -63
  84. data/lib/active_support/core_ext/class/delegating_attributes.rb +0 -44
  85. data/lib/active_support/core_ext/class/inheritable_attributes.rb +0 -232
  86. data/lib/active_support/core_ext/class/subclasses.rb +0 -55
  87. data/lib/active_support/core_ext/date/acts_like.rb +0 -8
  88. data/lib/active_support/core_ext/date/calculations.rb +0 -240
  89. data/lib/active_support/core_ext/date/conversions.rb +0 -99
  90. data/lib/active_support/core_ext/date/freeze.rb +0 -31
  91. data/lib/active_support/core_ext/date_time/acts_like.rb +0 -13
  92. data/lib/active_support/core_ext/date_time/calculations.rb +0 -113
  93. data/lib/active_support/core_ext/date_time/conversions.rb +0 -102
  94. data/lib/active_support/core_ext/date_time/zones.rb +0 -17
  95. data/lib/active_support/core_ext/enumerable.rb +0 -119
  96. data/lib/active_support/core_ext/exception.rb +0 -3
  97. data/lib/active_support/core_ext/file.rb +0 -2
  98. data/lib/active_support/core_ext/file/atomic.rb +0 -41
  99. data/lib/active_support/core_ext/file/path.rb +0 -5
  100. data/lib/active_support/core_ext/float.rb +0 -1
  101. data/lib/active_support/core_ext/float/rounding.rb +0 -19
  102. data/lib/active_support/core_ext/hash.rb +0 -8
  103. data/lib/active_support/core_ext/hash/conversions.rb +0 -150
  104. data/lib/active_support/core_ext/hash/deep_merge.rb +0 -16
  105. data/lib/active_support/core_ext/hash/diff.rb +0 -13
  106. data/lib/active_support/core_ext/hash/except.rb +0 -24
  107. data/lib/active_support/core_ext/hash/indifferent_access.rb +0 -14
  108. data/lib/active_support/core_ext/hash/keys.rb +0 -45
  109. data/lib/active_support/core_ext/hash/reverse_merge.rb +0 -28
  110. data/lib/active_support/core_ext/hash/slice.rb +0 -38
  111. data/lib/active_support/core_ext/integer.rb +0 -3
  112. data/lib/active_support/core_ext/integer/inflections.rb +0 -14
  113. data/lib/active_support/core_ext/integer/multiple.rb +0 -6
  114. data/lib/active_support/core_ext/integer/time.rb +0 -39
  115. data/lib/active_support/core_ext/kernel.rb +0 -5
  116. data/lib/active_support/core_ext/kernel/agnostics.rb +0 -11
  117. data/lib/active_support/core_ext/kernel/debugger.rb +0 -16
  118. data/lib/active_support/core_ext/kernel/reporting.rb +0 -62
  119. data/lib/active_support/core_ext/kernel/requires.rb +0 -26
  120. data/lib/active_support/core_ext/kernel/singleton_class.rb +0 -13
  121. data/lib/active_support/core_ext/load_error.rb +0 -23
  122. data/lib/active_support/core_ext/logger.rb +0 -146
  123. data/lib/active_support/core_ext/module.rb +0 -12
  124. data/lib/active_support/core_ext/module/aliasing.rb +0 -70
  125. data/lib/active_support/core_ext/module/anonymous.rb +0 -24
  126. data/lib/active_support/core_ext/module/attr_accessor_with_default.rb +0 -31
  127. data/lib/active_support/core_ext/module/attr_internal.rb +0 -32
  128. data/lib/active_support/core_ext/module/attribute_accessors.rb +0 -66
  129. data/lib/active_support/core_ext/module/delegation.rb +0 -146
  130. data/lib/active_support/core_ext/module/deprecation.rb +0 -9
  131. data/lib/active_support/core_ext/module/introspection.rb +0 -88
  132. data/lib/active_support/core_ext/module/method_names.rb +0 -14
  133. data/lib/active_support/core_ext/module/reachable.rb +0 -10
  134. data/lib/active_support/core_ext/module/remove_method.rb +0 -6
  135. data/lib/active_support/core_ext/module/synchronization.rb +0 -42
  136. data/lib/active_support/core_ext/name_error.rb +0 -18
  137. data/lib/active_support/core_ext/numeric.rb +0 -2
  138. data/lib/active_support/core_ext/numeric/bytes.rb +0 -44
  139. data/lib/active_support/core_ext/numeric/time.rb +0 -77
  140. data/lib/active_support/core_ext/object.rb +0 -14
  141. data/lib/active_support/core_ext/object/acts_like.rb +0 -10
  142. data/lib/active_support/core_ext/object/blank.rb +0 -76
  143. data/lib/active_support/core_ext/object/conversions.rb +0 -4
  144. data/lib/active_support/core_ext/object/duplicable.rb +0 -65
  145. data/lib/active_support/core_ext/object/extending.rb +0 -11
  146. data/lib/active_support/core_ext/object/instance_variables.rb +0 -67
  147. data/lib/active_support/core_ext/object/misc.rb +0 -2
  148. data/lib/active_support/core_ext/object/returning.rb +0 -42
  149. data/lib/active_support/core_ext/object/to_param.rb +0 -49
  150. data/lib/active_support/core_ext/object/to_query.rb +0 -27
  151. data/lib/active_support/core_ext/object/try.rb +0 -36
  152. data/lib/active_support/core_ext/object/with_options.rb +0 -26
  153. data/lib/active_support/core_ext/proc.rb +0 -14
  154. data/lib/active_support/core_ext/process.rb +0 -1
  155. data/lib/active_support/core_ext/process/daemon.rb +0 -23
  156. data/lib/active_support/core_ext/range.rb +0 -4
  157. data/lib/active_support/core_ext/range/blockless_step.rb +0 -29
  158. data/lib/active_support/core_ext/range/conversions.rb +0 -21
  159. data/lib/active_support/core_ext/range/include_range.rb +0 -21
  160. data/lib/active_support/core_ext/range/overlaps.rb +0 -8
  161. data/lib/active_support/core_ext/regexp.rb +0 -5
  162. data/lib/active_support/core_ext/rexml.rb +0 -46
  163. data/lib/active_support/core_ext/string.rb +0 -12
  164. data/lib/active_support/core_ext/string/access.rb +0 -99
  165. data/lib/active_support/core_ext/string/behavior.rb +0 -7
  166. data/lib/active_support/core_ext/string/conversions.rb +0 -61
  167. data/lib/active_support/core_ext/string/encoding.rb +0 -11
  168. data/lib/active_support/core_ext/string/exclude.rb +0 -6
  169. data/lib/active_support/core_ext/string/filters.rb +0 -49
  170. data/lib/active_support/core_ext/string/inflections.rb +0 -149
  171. data/lib/active_support/core_ext/string/interpolation.rb +0 -2
  172. data/lib/active_support/core_ext/string/multibyte.rb +0 -72
  173. data/lib/active_support/core_ext/string/output_safety.rb +0 -109
  174. data/lib/active_support/core_ext/string/starts_ends_with.rb +0 -4
  175. data/lib/active_support/core_ext/string/xchar.rb +0 -18
  176. data/lib/active_support/core_ext/time/acts_like.rb +0 -8
  177. data/lib/active_support/core_ext/time/calculations.rb +0 -282
  178. data/lib/active_support/core_ext/time/conversions.rb +0 -85
  179. data/lib/active_support/core_ext/time/marshal.rb +0 -56
  180. data/lib/active_support/core_ext/time/publicize_conversion_methods.rb +0 -10
  181. data/lib/active_support/core_ext/time/zones.rb +0 -78
  182. data/lib/active_support/core_ext/uri.rb +0 -22
  183. data/lib/active_support/dependencies.rb +0 -628
  184. data/lib/active_support/dependencies/autoload.rb +0 -50
  185. data/lib/active_support/deprecation.rb +0 -18
  186. data/lib/active_support/deprecation/behaviors.rb +0 -38
  187. data/lib/active_support/deprecation/method_wrappers.rb +0 -29
  188. data/lib/active_support/deprecation/proxy_wrappers.rb +0 -74
  189. data/lib/active_support/deprecation/reporting.rb +0 -56
  190. data/lib/active_support/duration.rb +0 -105
  191. data/lib/active_support/gzip.rb +0 -25
  192. data/lib/active_support/hash_with_indifferent_access.rb +0 -145
  193. data/lib/active_support/i18n.rb +0 -8
  194. data/lib/active_support/inflections.rb +0 -56
  195. data/lib/active_support/inflector.rb +0 -7
  196. data/lib/active_support/inflector/inflections.rb +0 -211
  197. data/lib/active_support/inflector/methods.rb +0 -141
  198. data/lib/active_support/inflector/transliterate.rb +0 -97
  199. data/lib/active_support/json.rb +0 -2
  200. data/lib/active_support/json/backends/jsongem.rb +0 -43
  201. data/lib/active_support/json/backends/yajl.rb +0 -40
  202. data/lib/active_support/json/backends/yaml.rb +0 -90
  203. data/lib/active_support/json/decoding.rb +0 -51
  204. data/lib/active_support/json/encoding.rb +0 -254
  205. data/lib/active_support/json/variable.rb +0 -11
  206. data/lib/active_support/lazy_load_hooks.rb +0 -27
  207. data/lib/active_support/locale/en.yml +0 -36
  208. data/lib/active_support/memoizable.rb +0 -103
  209. data/lib/active_support/message_encryptor.rb +0 -71
  210. data/lib/active_support/message_verifier.rb +0 -62
  211. data/lib/active_support/multibyte.rb +0 -44
  212. data/lib/active_support/multibyte/chars.rb +0 -480
  213. data/lib/active_support/multibyte/exceptions.rb +0 -8
  214. data/lib/active_support/multibyte/unicode.rb +0 -393
  215. data/lib/active_support/multibyte/utils.rb +0 -60
  216. data/lib/active_support/notifications.rb +0 -81
  217. data/lib/active_support/notifications/fanout.rb +0 -93
  218. data/lib/active_support/notifications/instrumenter.rb +0 -56
  219. data/lib/active_support/option_merger.rb +0 -25
  220. data/lib/active_support/ordered_hash.rb +0 -158
  221. data/lib/active_support/ordered_options.rb +0 -27
  222. data/lib/active_support/railtie.rb +0 -100
  223. data/lib/active_support/rescuable.rb +0 -114
  224. data/lib/active_support/ruby/shim.rb +0 -22
  225. data/lib/active_support/secure_random.rb +0 -199
  226. data/lib/active_support/string_inquirer.rb +0 -21
  227. data/lib/active_support/test_case.rb +0 -42
  228. data/lib/active_support/testing/assertions.rb +0 -82
  229. data/lib/active_support/testing/declarative.rb +0 -40
  230. data/lib/active_support/testing/default.rb +0 -9
  231. data/lib/active_support/testing/deprecation.rb +0 -55
  232. data/lib/active_support/testing/isolation.rb +0 -154
  233. data/lib/active_support/testing/pending.rb +0 -48
  234. data/lib/active_support/testing/performance.rb +0 -455
  235. data/lib/active_support/testing/setup_and_teardown.rb +0 -111
  236. data/lib/active_support/time.rb +0 -34
  237. data/lib/active_support/time/autoload.rb +0 -5
  238. data/lib/active_support/time_with_zone.rb +0 -341
  239. data/lib/active_support/values/time_zone.rb +0 -377
  240. data/lib/active_support/values/unicode_tables.dat +0 -0
  241. data/lib/active_support/version.rb +0 -10
  242. data/lib/active_support/whiny_nil.rb +0 -60
  243. data/lib/active_support/xml_mini.rb +0 -158
  244. data/lib/active_support/xml_mini/jdom.rb +0 -168
  245. data/lib/active_support/xml_mini/libxml.rb +0 -80
  246. data/lib/active_support/xml_mini/libxmlsax.rb +0 -85
  247. data/lib/active_support/xml_mini/nokogiri.rb +0 -78
  248. data/lib/active_support/xml_mini/nokogirisax.rb +0 -83
  249. data/lib/active_support/xml_mini/rexml.rb +0 -129
  250. data/lib/csd/extensions/core/file.rb +0 -14
  251. data/lib/csd/global_open_struct.rb +0 -19
  252. data/lib/csd/path.rb +0 -32
  253. data/lib/csd/ui.rb +0 -2
  254. data/lib/csd/ui/cli.rb +0 -8
  255. data/lib/csd/ui/ui.rb +0 -45
  256. data/lib/term/ansicolor.rb +0 -102
  257. data/lib/term/ansicolor/.keep +0 -0
  258. data/lib/term/ansicolor/version.rb +0 -10
@@ -1,50 +0,0 @@
1
- require "active_support/inflector/methods"
2
- require "active_support/lazy_load_hooks"
3
-
4
- module ActiveSupport
5
- module Autoload
6
- @@autoloads = {}
7
- @@under_path = nil
8
- @@at_path = nil
9
- @@eager_autoload = false
10
-
11
- def autoload(const_name, path = @@at_path)
12
- full = [self.name, @@under_path, const_name.to_s, path].compact.join("::")
13
- location = path || Inflector.underscore(full)
14
-
15
- if @@eager_autoload
16
- @@autoloads[const_name] = location
17
- end
18
- super const_name, location
19
- end
20
-
21
- def autoload_under(path)
22
- @@under_path, old_path = path, @@under_path
23
- yield
24
- ensure
25
- @@under_path = old_path
26
- end
27
-
28
- def autoload_at(path)
29
- @@at_path, old_path = path, @@at_path
30
- yield
31
- ensure
32
- @@at_path = old_path
33
- end
34
-
35
- def eager_autoload
36
- old_eager, @@eager_autoload = @@eager_autoload, true
37
- yield
38
- ensure
39
- @@eager_autoload = old_eager
40
- end
41
-
42
- def self.eager_autoload!
43
- @@autoloads.values.each { |file| require file }
44
- end
45
-
46
- def autoloads
47
- @@autoloads
48
- end
49
- end
50
- end
@@ -1,18 +0,0 @@
1
- require 'active_support/deprecation/behaviors'
2
- require 'active_support/deprecation/reporting'
3
- require 'active_support/deprecation/method_wrappers'
4
- require 'active_support/deprecation/proxy_wrappers'
5
-
6
- module ActiveSupport
7
- module Deprecation #:nodoc:
8
- class << self
9
- # The version the deprecated behavior will be removed, by default.
10
- attr_accessor :deprecation_horizon
11
- end
12
- self.deprecation_horizon = '3.0'
13
-
14
- # By default, warnings are not silenced and debugging is off.
15
- self.silenced = false
16
- self.debug = false
17
- end
18
- end
@@ -1,38 +0,0 @@
1
- module ActiveSupport
2
- module Deprecation
3
- class << self
4
- # Behavior is a block that takes a message argument.
5
- attr_writer :behavior
6
-
7
- # Whether to print a backtrace along with the warning.
8
- attr_accessor :debug
9
-
10
- def behavior
11
- @behavior ||= default_behavior
12
- end
13
-
14
- def default_behavior
15
- Deprecation::DEFAULT_BEHAVIORS[defined?(Rails.env) ? Rails.env.to_s : 'test']
16
- end
17
- end
18
-
19
- # Default warning behaviors per Rails.env. Ignored in production.
20
- DEFAULT_BEHAVIORS = {
21
- 'test' => Proc.new { |message, callstack|
22
- $stderr.puts(message)
23
- $stderr.puts callstack.join("\n ") if debug
24
- },
25
- 'development' => Proc.new { |message, callstack|
26
- logger =
27
- if defined?(Rails) && Rails.logger
28
- Rails.logger
29
- else
30
- require 'logger'
31
- Logger.new($stderr)
32
- end
33
- logger.warn message
34
- logger.debug callstack.join("\n ") if debug
35
- }
36
- }
37
- end
38
- end
@@ -1,29 +0,0 @@
1
- require 'active_support/core_ext/module/deprecation'
2
- require 'active_support/core_ext/module/aliasing'
3
- require 'active_support/core_ext/array/extract_options'
4
-
5
- module ActiveSupport
6
- class << Deprecation
7
- # Declare that a method has been deprecated.
8
- def deprecate_methods(target_module, *method_names)
9
- options = method_names.extract_options!
10
- method_names += options.keys
11
-
12
- method_names.each do |method_name|
13
- target_module.alias_method_chain(method_name, :deprecation) do |target, punctuation|
14
- target_module.module_eval(<<-end_eval, __FILE__, __LINE__ + 1)
15
- def #{target}_with_deprecation#{punctuation}(*args, &block)
16
- ::ActiveSupport::Deprecation.warn(
17
- ::ActiveSupport::Deprecation.deprecated_method_warning(
18
- :#{method_name},
19
- #{options[method_name].inspect}),
20
- caller
21
- )
22
- send(:#{target}_without_deprecation#{punctuation}, *args, &block)
23
- end
24
- end_eval
25
- end
26
- end
27
- end
28
- end
29
- end
@@ -1,74 +0,0 @@
1
- require 'active_support/inflector'
2
-
3
- module ActiveSupport
4
- module Deprecation
5
- class DeprecationProxy #:nodoc:
6
- instance_methods.each { |m| undef_method m unless m =~ /^__|^object_id$/ }
7
-
8
- # Don't give a deprecation warning on inspect since test/unit and error
9
- # logs rely on it for diagnostics.
10
- def inspect
11
- target.inspect
12
- end
13
-
14
- private
15
- def method_missing(called, *args, &block)
16
- warn caller, called, args
17
- target.__send__(called, *args, &block)
18
- end
19
- end
20
-
21
- class DeprecatedObjectProxy < DeprecationProxy #:nodoc:
22
- def initialize(object, message)
23
- @object = object
24
- @message = message
25
- end
26
-
27
- private
28
- def target
29
- @object
30
- end
31
-
32
- def warn(callstack, called, args)
33
- ActiveSupport::Deprecation.warn(@message, callstack)
34
- end
35
- end
36
-
37
- # Stand-in for <tt>@request</tt>, <tt>@attributes</tt>, <tt>@params</tt>, etc.
38
- # which emits deprecation warnings on any method call (except +inspect+).
39
- class DeprecatedInstanceVariableProxy < DeprecationProxy #:nodoc:
40
- def initialize(instance, method, var = "@#{method}")
41
- @instance, @method, @var = instance, method, var
42
- end
43
-
44
- private
45
- def target
46
- @instance.__send__(@method)
47
- end
48
-
49
- def warn(callstack, called, args)
50
- ActiveSupport::Deprecation.warn("#{@var} is deprecated! Call #{@method}.#{called} instead of #{@var}.#{called}. Args: #{args.inspect}", callstack)
51
- end
52
- end
53
-
54
- class DeprecatedConstantProxy < DeprecationProxy #:nodoc:
55
- def initialize(old_const, new_const)
56
- @old_const = old_const
57
- @new_const = new_const
58
- end
59
-
60
- def class
61
- target.class
62
- end
63
-
64
- private
65
- def target
66
- ActiveSupport::Inflector.constantize(@new_const.to_s)
67
- end
68
-
69
- def warn(callstack, called, args)
70
- ActiveSupport::Deprecation.warn("#{@old_const} is deprecated! Use #{@new_const} instead.", callstack)
71
- end
72
- end
73
- end
74
- end
@@ -1,56 +0,0 @@
1
- module ActiveSupport
2
- module Deprecation
3
- class << self
4
- attr_accessor :silenced
5
-
6
- def warn(message = nil, callstack = caller)
7
- if behavior && !silenced
8
- behavior.call(deprecation_message(callstack, message), callstack)
9
- end
10
- end
11
-
12
- # Silence deprecation warnings within the block.
13
- def silence
14
- old_silenced, @silenced = @silenced, true
15
- yield
16
- ensure
17
- @silenced = old_silenced
18
- end
19
-
20
- def deprecated_method_warning(method_name, message = nil)
21
- warning = "#{method_name} is deprecated and will be removed from Rails #{deprecation_horizon}"
22
- case message
23
- when Symbol then "#{warning} (use #{message} instead)"
24
- when String then "#{warning} (#{message})"
25
- else warning
26
- end
27
- end
28
-
29
- private
30
- def deprecation_message(callstack, message = nil)
31
- message ||= "You are using deprecated behavior which will be removed from the next major or minor release."
32
- message += '.' unless message =~ /\.$/
33
- "DEPRECATION WARNING: #{message} #{deprecation_caller_message(callstack)}"
34
- end
35
-
36
- def deprecation_caller_message(callstack)
37
- file, line, method = extract_callstack(callstack)
38
- if file
39
- if line && method
40
- "(called from #{method} at #{file}:#{line})"
41
- else
42
- "(called from #{file}:#{line})"
43
- end
44
- end
45
- end
46
-
47
- def extract_callstack(callstack)
48
- if md = callstack.first.match(/^(.+?):(\d+)(?::in `(.*?)')?/)
49
- md.captures
50
- else
51
- callstack.first
52
- end
53
- end
54
- end
55
- end
56
- end
@@ -1,105 +0,0 @@
1
- require 'active_support/basic_object'
2
- require 'active_support/core_ext/array/conversions'
3
- require 'active_support/core_ext/object/acts_like'
4
-
5
- module ActiveSupport
6
- # Provides accurate date and time measurements using Date#advance and
7
- # Time#advance, respectively. It mainly supports the methods on Numeric,
8
- # such as in this example:
9
- #
10
- # 1.month.ago # equivalent to Time.now.advance(:months => -1)
11
- class Duration < BasicObject
12
- attr_accessor :value, :parts
13
-
14
- def initialize(value, parts) #:nodoc:
15
- @value, @parts = value, parts
16
- end
17
-
18
- # Adds another Duration or a Numeric to this Duration. Numeric values
19
- # are treated as seconds.
20
- def +(other)
21
- if Duration === other
22
- Duration.new(value + other.value, @parts + other.parts)
23
- else
24
- Duration.new(value + other, @parts + [[:seconds, other]])
25
- end
26
- end
27
-
28
- # Subtracts another Duration or a Numeric from this Duration. Numeric
29
- # values are treated as seconds.
30
- def -(other)
31
- self + (-other)
32
- end
33
-
34
- def -@ #:nodoc:
35
- Duration.new(-value, parts.map { |type,number| [type, -number] })
36
- end
37
-
38
- def is_a?(klass) #:nodoc:
39
- Duration == klass || value.is_a?(klass)
40
- end
41
- alias :kind_of? :is_a?
42
-
43
- # Returns true if <tt>other</tt> is also a Duration instance with the
44
- # same <tt>value</tt>, or if <tt>other == value</tt>.
45
- def ==(other)
46
- if Duration === other
47
- other.value == value
48
- else
49
- other == value
50
- end
51
- end
52
-
53
- def self.===(other) #:nodoc:
54
- other.is_a?(Duration)
55
- rescue ::NoMethodError
56
- false
57
- end
58
-
59
- # Calculates a new Time or Date that is as far in the future
60
- # as this Duration represents.
61
- def since(time = ::Time.current)
62
- sum(1, time)
63
- end
64
- alias :from_now :since
65
-
66
- # Calculates a new Time or Date that is as far in the past
67
- # as this Duration represents.
68
- def ago(time = ::Time.current)
69
- sum(-1, time)
70
- end
71
- alias :until :ago
72
-
73
- def inspect #:nodoc:
74
- consolidated = parts.inject(::Hash.new(0)) { |h,part| h[part.first] += part.last; h }
75
- parts = [:years, :months, :days, :minutes, :seconds].map do |length|
76
- n = consolidated[length]
77
- "#{n} #{n == 1 ? length.to_s.singularize : length.to_s}" if n.nonzero?
78
- end.compact
79
- parts = ["0 seconds"] if parts.empty?
80
- parts.to_sentence(:locale => :en)
81
- end
82
-
83
- protected
84
-
85
- def sum(sign, time = ::Time.current) #:nodoc:
86
- parts.inject(time) do |t,(type,number)|
87
- if t.acts_like?(:time) || t.acts_like?(:date)
88
- if type == :seconds
89
- t.since(sign * number)
90
- else
91
- t.advance(type => sign * number)
92
- end
93
- else
94
- raise ::ArgumentError, "expected a time or date, got #{time.inspect}"
95
- end
96
- end
97
- end
98
-
99
- private
100
-
101
- def method_missing(method, *args, &block) #:nodoc:
102
- value.send(method, *args)
103
- end
104
- end
105
- end
@@ -1,25 +0,0 @@
1
- require 'zlib'
2
- require 'stringio'
3
-
4
- module ActiveSupport
5
- # A convenient wrapper for the zlib standard library that allows compression/decompression of strings with gzip.
6
- module Gzip
7
- class Stream < StringIO
8
- def close; rewind; end
9
- end
10
-
11
- # Decompresses a gzipped string.
12
- def self.decompress(source)
13
- Zlib::GzipReader.new(StringIO.new(source)).read
14
- end
15
-
16
- # Compresses a string using gzip.
17
- def self.compress(source)
18
- output = Stream.new
19
- gz = Zlib::GzipWriter.new(output)
20
- gz.write(source)
21
- gz.close
22
- output.string
23
- end
24
- end
25
- end
@@ -1,145 +0,0 @@
1
- require 'active_support/core_ext/hash/keys'
2
-
3
- # This class has dubious semantics and we only have it so that
4
- # people can write params[:key] instead of params['key']
5
- # and they get the same value for both keys.
6
-
7
- module ActiveSupport
8
- class HashWithIndifferentAccess < Hash
9
- def extractable_options?
10
- true
11
- end
12
-
13
- def initialize(constructor = {})
14
- if constructor.is_a?(Hash)
15
- super()
16
- update(constructor)
17
- else
18
- super(constructor)
19
- end
20
- end
21
-
22
- def default(key = nil)
23
- if key.is_a?(Symbol) && include?(key = key.to_s)
24
- self[key]
25
- else
26
- super
27
- end
28
- end
29
-
30
- alias_method :regular_writer, :[]= unless method_defined?(:regular_writer)
31
- alias_method :regular_update, :update unless method_defined?(:regular_update)
32
-
33
- # Assigns a new value to the hash:
34
- #
35
- # hash = HashWithIndifferentAccess.new
36
- # hash[:key] = "value"
37
- #
38
- def []=(key, value)
39
- regular_writer(convert_key(key), convert_value(value))
40
- end
41
-
42
- # Updates the instantized hash with values from the second:
43
- #
44
- # hash_1 = HashWithIndifferentAccess.new
45
- # hash_1[:key] = "value"
46
- #
47
- # hash_2 = HashWithIndifferentAccess.new
48
- # hash_2[:key] = "New Value!"
49
- #
50
- # hash_1.update(hash_2) # => {"key"=>"New Value!"}
51
- #
52
- def update(other_hash)
53
- other_hash.each_pair { |key, value| regular_writer(convert_key(key), convert_value(value)) }
54
- self
55
- end
56
-
57
- alias_method :merge!, :update
58
-
59
- # Checks the hash for a key matching the argument passed in:
60
- #
61
- # hash = HashWithIndifferentAccess.new
62
- # hash["key"] = "value"
63
- # hash.key? :key # => true
64
- # hash.key? "key" # => true
65
- #
66
- def key?(key)
67
- super(convert_key(key))
68
- end
69
-
70
- alias_method :include?, :key?
71
- alias_method :has_key?, :key?
72
- alias_method :member?, :key?
73
-
74
- # Fetches the value for the specified key, same as doing hash[key]
75
- def fetch(key, *extras)
76
- super(convert_key(key), *extras)
77
- end
78
-
79
- # Returns an array of the values at the specified indices:
80
- #
81
- # hash = HashWithIndifferentAccess.new
82
- # hash[:a] = "x"
83
- # hash[:b] = "y"
84
- # hash.values_at("a", "b") # => ["x", "y"]
85
- #
86
- def values_at(*indices)
87
- indices.collect {|key| self[convert_key(key)]}
88
- end
89
-
90
- # Returns an exact copy of the hash.
91
- def dup
92
- HashWithIndifferentAccess.new(self)
93
- end
94
-
95
- # Merges the instantized and the specified hashes together, giving precedence to the values from the second hash
96
- # Does not overwrite the existing hash.
97
- def merge(hash)
98
- self.dup.update(hash)
99
- end
100
-
101
- # Performs the opposite of merge, with the keys and values from the first hash taking precedence over the second.
102
- # This overloaded definition prevents returning a regular hash, if reverse_merge is called on a HashWithDifferentAccess.
103
- def reverse_merge(other_hash)
104
- super other_hash.with_indifferent_access
105
- end
106
-
107
- def reverse_merge!(other_hash)
108
- replace(reverse_merge( other_hash ))
109
- end
110
-
111
- # Removes a specified key from the hash.
112
- def delete(key)
113
- super(convert_key(key))
114
- end
115
-
116
- def stringify_keys!; self end
117
- def stringify_keys; dup end
118
- undef :symbolize_keys!
119
- def symbolize_keys; to_hash.symbolize_keys end
120
- def to_options!; self end
121
-
122
- # Convert to a Hash with String keys.
123
- def to_hash
124
- Hash.new(default).merge!(self)
125
- end
126
-
127
- protected
128
- def convert_key(key)
129
- key.kind_of?(Symbol) ? key.to_s : key
130
- end
131
-
132
- def convert_value(value)
133
- case value
134
- when Hash
135
- value.with_indifferent_access
136
- when Array
137
- value.collect { |e| e.is_a?(Hash) ? e.with_indifferent_access : e }
138
- else
139
- value
140
- end
141
- end
142
- end
143
- end
144
-
145
- HashWithIndifferentAccess = ActiveSupport::HashWithIndifferentAccess