yard 0.6.8 → 0.7.0

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

Potentially problematic release.


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

Files changed (224) hide show
  1. data/.yardopts +1 -0
  2. data/ChangeLog +723 -0
  3. data/README.md +16 -6
  4. data/docs/CodeObjects.md +10 -16
  5. data/docs/GettingStarted.md +232 -32
  6. data/docs/Glossary.md +1 -2
  7. data/docs/Handlers.md +10 -16
  8. data/docs/Overview.md +14 -13
  9. data/docs/Parser.md +13 -22
  10. data/docs/Tags.md +209 -16
  11. data/docs/Templates.md +237 -26
  12. data/docs/WhatsNew.md +178 -2
  13. data/lib/yard.rb +13 -10
  14. data/lib/yard/autoload.rb +22 -18
  15. data/lib/yard/cli/command.rb +13 -12
  16. data/lib/yard/cli/command_parser.rb +20 -19
  17. data/lib/yard/cli/config.rb +19 -19
  18. data/lib/yard/cli/diff.rb +46 -21
  19. data/lib/yard/cli/gems.rb +11 -11
  20. data/lib/yard/cli/graph.rb +13 -13
  21. data/lib/yard/cli/help.rb +1 -1
  22. data/lib/yard/cli/list.rb +22 -0
  23. data/lib/yard/cli/server.rb +17 -17
  24. data/lib/yard/cli/stats.rb +32 -32
  25. data/lib/yard/cli/yardoc.rb +181 -135
  26. data/lib/yard/cli/yri.rb +29 -29
  27. data/lib/yard/code_objects/base.rb +101 -101
  28. data/lib/yard/code_objects/class_object.rb +20 -20
  29. data/lib/yard/code_objects/constant_object.rb +1 -1
  30. data/lib/yard/code_objects/extended_method_object.rb +5 -5
  31. data/lib/yard/code_objects/extra_file_object.rb +89 -0
  32. data/lib/yard/code_objects/macro_object.rb +215 -0
  33. data/lib/yard/code_objects/method_object.rb +30 -30
  34. data/lib/yard/code_objects/module_object.rb +1 -1
  35. data/lib/yard/code_objects/namespace_object.rb +39 -39
  36. data/lib/yard/code_objects/proxy.rb +38 -38
  37. data/lib/yard/code_objects/root_object.rb +1 -1
  38. data/lib/yard/config.rb +40 -40
  39. data/lib/yard/core_ext/array.rb +2 -2
  40. data/lib/yard/core_ext/file.rb +11 -11
  41. data/lib/yard/core_ext/insertion.rb +10 -10
  42. data/lib/yard/core_ext/module.rb +2 -2
  43. data/lib/yard/core_ext/string.rb +2 -2
  44. data/lib/yard/core_ext/symbol_hash.rb +14 -14
  45. data/lib/yard/docstring.rb +122 -54
  46. data/lib/yard/globals.rb +2 -2
  47. data/lib/yard/handlers/base.rb +216 -127
  48. data/lib/yard/handlers/processor.rb +65 -27
  49. data/lib/yard/handlers/ruby/alias_handler.rb +6 -3
  50. data/lib/yard/handlers/ruby/attribute_handler.rb +7 -6
  51. data/lib/yard/handlers/ruby/base.rb +50 -31
  52. data/lib/yard/handlers/ruby/class_condition_handler.rb +11 -11
  53. data/lib/yard/handlers/ruby/class_handler.rb +10 -10
  54. data/lib/yard/handlers/ruby/class_variable_handler.rb +3 -3
  55. data/lib/yard/handlers/ruby/constant_handler.rb +7 -7
  56. data/lib/yard/handlers/ruby/exception_handler.rb +2 -2
  57. data/lib/yard/handlers/ruby/extend_handler.rb +1 -1
  58. data/lib/yard/handlers/ruby/legacy/alias_handler.rb +8 -5
  59. data/lib/yard/handlers/ruby/legacy/attribute_handler.rb +6 -5
  60. data/lib/yard/handlers/ruby/legacy/base.rb +42 -27
  61. data/lib/yard/handlers/ruby/legacy/class_condition_handler.rb +9 -9
  62. data/lib/yard/handlers/ruby/legacy/class_handler.rb +13 -12
  63. data/lib/yard/handlers/ruby/legacy/class_variable_handler.rb +3 -6
  64. data/lib/yard/handlers/ruby/legacy/constant_handler.rb +5 -8
  65. data/lib/yard/handlers/ruby/legacy/exception_handler.rb +1 -1
  66. data/lib/yard/handlers/ruby/legacy/extend_handler.rb +1 -0
  67. data/lib/yard/handlers/ruby/legacy/macro_handler.rb +40 -0
  68. data/lib/yard/handlers/ruby/legacy/method_handler.rb +10 -10
  69. data/lib/yard/handlers/ruby/legacy/mixin_handler.rb +4 -3
  70. data/lib/yard/handlers/ruby/legacy/module_handler.rb +2 -1
  71. data/lib/yard/handlers/ruby/legacy/private_constant_handler.rb +4 -4
  72. data/lib/yard/handlers/ruby/legacy/visibility_handler.rb +2 -1
  73. data/lib/yard/handlers/ruby/legacy/yield_handler.rb +3 -3
  74. data/lib/yard/handlers/ruby/macro_handler.rb +41 -0
  75. data/lib/yard/handlers/ruby/macro_handler_methods.rb +130 -0
  76. data/lib/yard/handlers/ruby/method_condition_handler.rb +1 -1
  77. data/lib/yard/handlers/ruby/method_handler.rb +13 -13
  78. data/lib/yard/handlers/ruby/mixin_handler.rb +4 -4
  79. data/lib/yard/handlers/ruby/module_handler.rb +2 -1
  80. data/lib/yard/handlers/ruby/private_constant_handler.rb +4 -4
  81. data/lib/yard/handlers/ruby/struct_handler_methods.rb +11 -11
  82. data/lib/yard/handlers/ruby/visibility_handler.rb +1 -1
  83. data/lib/yard/handlers/ruby/yield_handler.rb +5 -5
  84. data/lib/yard/logging.rb +11 -11
  85. data/lib/yard/parser/base.rb +8 -8
  86. data/lib/yard/parser/c_parser.rb +42 -33
  87. data/lib/yard/parser/ruby/ast_node.rb +62 -61
  88. data/lib/yard/parser/ruby/legacy/ruby_lex.rb +66 -66
  89. data/lib/yard/parser/ruby/legacy/ruby_parser.rb +4 -4
  90. data/lib/yard/parser/ruby/legacy/statement.rb +11 -11
  91. data/lib/yard/parser/ruby/legacy/statement_list.rb +15 -15
  92. data/lib/yard/parser/ruby/legacy/token_list.rb +9 -9
  93. data/lib/yard/parser/ruby/ruby_parser.rb +51 -37
  94. data/lib/yard/parser/source_parser.rb +271 -46
  95. data/lib/yard/rake/yardoc_task.rb +18 -17
  96. data/lib/yard/registry.rb +64 -64
  97. data/lib/yard/registry_store.rb +34 -34
  98. data/lib/yard/rubygems/backports.rb +8 -0
  99. data/lib/yard/rubygems/backports/LICENSE.txt +57 -0
  100. data/lib/yard/rubygems/backports/MIT.txt +20 -0
  101. data/lib/yard/rubygems/backports/gem.rb +8 -0
  102. data/lib/yard/rubygems/backports/source_index.rb +353 -0
  103. data/lib/yard/rubygems/specification.rb +2 -2
  104. data/lib/yard/serializers/base.rb +20 -20
  105. data/lib/yard/serializers/file_system_serializer.rb +28 -24
  106. data/lib/yard/serializers/process_serializer.rb +3 -3
  107. data/lib/yard/serializers/stdout_serializer.rb +6 -6
  108. data/lib/yard/serializers/yardoc_serializer.rb +17 -17
  109. data/lib/yard/server/adapter.rb +12 -12
  110. data/lib/yard/server/commands/base.rb +26 -26
  111. data/lib/yard/server/commands/display_file_command.rb +3 -2
  112. data/lib/yard/server/commands/display_object_command.rb +5 -5
  113. data/lib/yard/server/commands/frames_command.rb +1 -1
  114. data/lib/yard/server/commands/library_command.rb +7 -7
  115. data/lib/yard/server/commands/library_index_command.rb +2 -2
  116. data/lib/yard/server/commands/list_command.rb +8 -8
  117. data/lib/yard/server/commands/search_command.rb +8 -8
  118. data/lib/yard/server/commands/static_file_command.rb +3 -3
  119. data/lib/yard/server/doc_server_helper.rb +6 -3
  120. data/lib/yard/server/doc_server_serializer.rb +1 -1
  121. data/lib/yard/server/library_version.rb +45 -45
  122. data/lib/yard/server/rack_adapter.rb +10 -10
  123. data/lib/yard/server/router.rb +28 -28
  124. data/lib/yard/server/static_caching.rb +5 -5
  125. data/lib/yard/server/templates/default/fulldoc/html/css/custom.css +3 -3
  126. data/lib/yard/server/templates/default/fulldoc/html/js/live.js +1 -1
  127. data/lib/yard/server/templates/default/layout/html/breadcrumb.erb +2 -2
  128. data/lib/yard/server/templates/default/layout/html/headers.erb +13 -8
  129. data/lib/yard/server/templates/default/layout/html/setup.rb +7 -0
  130. data/lib/yard/server/templates/doc_server/full_list/html/full_list.erb +2 -2
  131. data/lib/yard/server/templates/doc_server/full_list/html/setup.rb +14 -4
  132. data/lib/yard/server/templates/doc_server/library_list/html/contents.erb +2 -2
  133. data/lib/yard/server/templates/doc_server/library_list/html/headers.erb +2 -2
  134. data/lib/yard/server/templates/doc_server/processing/html/processing.erb +1 -1
  135. data/lib/yard/server/templates/doc_server/search/html/search.erb +1 -1
  136. data/lib/yard/server/webrick_adapter.rb +2 -2
  137. data/lib/yard/tags/default_factory.rb +19 -19
  138. data/lib/yard/tags/default_tag.rb +1 -1
  139. data/lib/yard/tags/library.rb +68 -63
  140. data/lib/yard/tags/option_tag.rb +1 -1
  141. data/lib/yard/tags/overload_tag.rb +9 -9
  142. data/lib/yard/tags/ref_tag_list.rb +2 -2
  143. data/lib/yard/tags/tag.rb +7 -7
  144. data/lib/yard/templates/engine.rb +31 -31
  145. data/lib/yard/templates/erb_cache.rb +1 -1
  146. data/lib/yard/templates/helpers/base_helper.rb +46 -32
  147. data/lib/yard/templates/helpers/filter_helper.rb +2 -2
  148. data/lib/yard/templates/helpers/html_helper.rb +120 -81
  149. data/lib/yard/templates/helpers/html_syntax_highlight_helper.rb +4 -4
  150. data/lib/yard/templates/helpers/markup/rdoc_markup.rb +9 -9
  151. data/lib/yard/templates/helpers/markup_helper.rb +37 -30
  152. data/lib/yard/templates/helpers/method_helper.rb +7 -7
  153. data/lib/yard/templates/helpers/text_helper.rb +7 -7
  154. data/lib/yard/templates/helpers/uml_helper.rb +3 -3
  155. data/lib/yard/templates/section.rb +14 -14
  156. data/lib/yard/templates/template.rb +54 -54
  157. data/lib/yard/verifier.rb +27 -27
  158. data/spec/cli/list_spec.rb +8 -0
  159. data/spec/cli/yardoc_spec.rb +58 -10
  160. data/spec/code_objects/extra_file_object_spec.rb +132 -0
  161. data/spec/code_objects/macro_object_spec.rb +154 -0
  162. data/spec/docstring_spec.rb +90 -0
  163. data/spec/handlers/base_spec.rb +22 -0
  164. data/spec/handlers/examples/macro_handler_001.rb.txt +73 -0
  165. data/spec/handlers/examples/method_handler_001.rb.txt +17 -0
  166. data/spec/handlers/macro_handler_spec.rb +140 -0
  167. data/spec/handlers/method_handler_spec.rb +28 -0
  168. data/spec/handlers/processor_spec.rb +4 -0
  169. data/spec/handlers/spec_helper.rb +1 -1
  170. data/spec/parser/c_parser_spec.rb +47 -16
  171. data/spec/parser/examples/extrafile.c.txt +8 -0
  172. data/spec/parser/examples/multifile.c.txt +6 -0
  173. data/spec/parser/ruby/ruby_parser_spec.rb +5 -0
  174. data/spec/parser/source_parser_spec.rb +235 -0
  175. data/spec/rake/yardoc_task_spec.rb +22 -17
  176. data/spec/serializers/file_system_serializer_spec.rb +6 -0
  177. data/spec/server/commands/library_command_spec.rb +39 -0
  178. data/spec/spec_helper.rb +14 -0
  179. data/spec/templates/examples/method001.html +6 -6
  180. data/spec/templates/examples/method002.html +4 -4
  181. data/spec/templates/examples/method003.html +10 -10
  182. data/spec/templates/examples/method005.html +2 -2
  183. data/spec/templates/examples/module001.dot +2 -0
  184. data/spec/templates/examples/module001.html +76 -37
  185. data/spec/templates/examples/module001.txt +1 -1
  186. data/spec/templates/helpers/base_helper_spec.rb +7 -2
  187. data/spec/templates/helpers/html_helper_spec.rb +49 -5
  188. data/spec/templates/helpers/markup_helper_spec.rb +9 -8
  189. data/spec/templates/module_spec.rb +7 -0
  190. data/spec/templates/onefile_spec.rb +47 -0
  191. data/templates/default/fulldoc/html/css/style.css +7 -5
  192. data/templates/default/fulldoc/html/full_list.erb +13 -10
  193. data/templates/default/fulldoc/html/full_list_files.erb +1 -1
  194. data/templates/default/fulldoc/html/js/app.js +16 -14
  195. data/templates/default/fulldoc/html/js/full_list.js +7 -6
  196. data/templates/default/fulldoc/html/setup.rb +78 -17
  197. data/templates/default/layout/html/files.erb +1 -1
  198. data/templates/default/layout/html/headers.erb +11 -7
  199. data/templates/default/layout/html/search.erb +4 -4
  200. data/templates/default/layout/html/setup.rb +28 -8
  201. data/templates/default/module/html/inherited_attributes.erb +17 -0
  202. data/templates/default/module/setup.rb +1 -1
  203. data/templates/default/onefile/html/files.erb +2 -2
  204. data/templates/default/onefile/html/layout.erb +1 -1
  205. data/templates/default/onefile/html/setup.rb +7 -5
  206. data/templates/default/tags/html/option.erb +1 -1
  207. data/templates/default/tags/html/tag.erb +3 -3
  208. data/templates/guide/class/html/setup.rb +1 -0
  209. data/templates/guide/docstring/html/setup.rb +1 -0
  210. data/templates/guide/fulldoc/html/css/style.css +91 -0
  211. data/templates/guide/fulldoc/html/js/app.js +33 -0
  212. data/templates/guide/fulldoc/html/setup.rb +54 -0
  213. data/templates/guide/layout/html/layout.erb +81 -0
  214. data/templates/guide/layout/html/setup.rb +24 -0
  215. data/templates/guide/method/html/header.erb +18 -0
  216. data/templates/guide/method/html/setup.rb +21 -0
  217. data/templates/guide/module/html/header.erb +7 -0
  218. data/templates/guide/module/html/method_list.erb +5 -0
  219. data/templates/guide/module/html/setup.rb +26 -0
  220. data/templates/guide/tags/html/setup.rb +8 -0
  221. metadata +40 -7
  222. data/lib/yard/handlers/ruby/legacy/process_handler.rb +0 -13
  223. data/lib/yard/handlers/ruby/process_handler.rb +0 -18
  224. data/spec/handlers/process_handler_spec.rb +0 -17
@@ -9,7 +9,7 @@ module YARD
9
9
  def equal?(other)
10
10
  other == :root ? true : super(other)
11
11
  end
12
-
12
+
13
13
  def hash; :root.hash end
14
14
  end
15
15
  end
data/lib/yard/config.rb CHANGED
@@ -3,18 +3,18 @@ module YARD
3
3
  # the loading of plugins. To access options call {options}, and to load
4
4
  # a plugin use {load_plugin}. All other public methods are used by YARD
5
5
  # during load time.
6
- #
6
+ #
7
7
  # == User Configuration Files
8
- #
9
- # Persistent user configuration files can be stored in the file
8
+ #
9
+ # Persistent user configuration files can be stored in the file
10
10
  # +~/.yard/config+, which is read when YARD first loads. The file should
11
11
  # be formatted as YAML, and should contain a map of keys and values.
12
- #
12
+ #
13
13
  # Although you can specify any key-value mapping in the configuration file,
14
14
  # YARD defines special keys specified in {DEFAULT_CONFIG_OPTIONS}.
15
- #
15
+ #
16
16
  # An example of a configuration file is listed below:
17
- #
17
+ #
18
18
  # !!!yaml
19
19
  # load_plugins: true # Auto-load plugins when YARD starts
20
20
  # ignored_plugins:
@@ -22,30 +22,30 @@ module YARD
22
22
  # - broken2 # yard- prefix not necessary
23
23
  # autoload_plugins:
24
24
  # - yard-rspec
25
- #
25
+ #
26
26
  # == Automatic Loading of Plugins
27
- #
28
- # YARD 0.6.2 will no longer automatically load all plugins by default. This
29
- # option can be reset by setting 'load_plugins' to true in the configuration
30
- # file. In addition, you can specify a set of specific plugins to load on
31
- # load through the 'autoload_plugins' list setting. This setting is
27
+ #
28
+ # YARD 0.6.2 will no longer automatically load all plugins by default. This
29
+ # option can be reset by setting 'load_plugins' to true in the configuration
30
+ # file. In addition, you can specify a set of specific plugins to load on
31
+ # load through the 'autoload_plugins' list setting. This setting is
32
32
  # independent of the 'load_plugins' value and will always be processed.
33
- #
33
+ #
34
34
  # == Ignored Plugins File
35
- #
35
+ #
36
36
  # YARD 0.5 and below used a +~/.yard/ignored_plugins+ file to specify
37
37
  # plugins to be ignored at load time. Ignored plugins in 0.6.2 and above
38
38
  # should now be specified in the main configuration file, though YARD
39
39
  # will support the +ignored_plugins+ file until 0.7.x.
40
- #
40
+ #
41
41
  # == Safe Mode
42
- #
42
+ #
43
43
  # YARD supports running in safe-mode. By doing this, it will avoid executing
44
44
  # any user code such as require files or queries. Plugins will still be
45
45
  # loaded with safe mode on, because plugins are properly namespaced with
46
46
  # a 'yard-' prefix, must be installed as a gem, and therefore cannot be
47
47
  # touched by the user. To specify safe mode, use the +safe_mode+ key.
48
- #
48
+ #
49
49
  # @since 0.6.2
50
50
  # @see options
51
51
  class Config
@@ -58,14 +58,14 @@ module YARD
58
58
 
59
59
  # The location where YARD stores user-specific settings
60
60
  CONFIG_DIR = File.expand_path('~/.yard')
61
-
61
+
62
62
  # The main configuration YAML file.
63
63
  CONFIG_FILE = File.join(CONFIG_DIR, 'config')
64
-
65
- # File listing all ignored plugins
64
+
65
+ # File listing all ignored plugins
66
66
  # @deprecated Set `ignored_plugins` in the {CONFIG_FILE} instead.
67
67
  IGNORED_PLUGINS = File.join(CONFIG_DIR, 'ignored_plugins')
68
-
68
+
69
69
  # Default configuration options
70
70
  DEFAULT_CONFIG_OPTIONS = {
71
71
  :load_plugins => false, # Whether to load plugins automatically with YARD
@@ -73,11 +73,11 @@ module YARD
73
73
  :autoload_plugins => [], # A list of plugins to be automatically loaded
74
74
  :safe_mode => false # Does not execute or eval any user-level code
75
75
  }
76
-
76
+
77
77
  # The prefix used for YARD plugins. Name your gem with this prefix
78
78
  # to allow it to be used as a plugin.
79
79
  YARD_PLUGIN_PREFIX = /^yard[-_]/
80
-
80
+
81
81
  # Loads settings from {CONFIG_FILE}. This method is called by YARD at
82
82
  # load time and should not be called by the user.
83
83
  # @return [void]
@@ -92,28 +92,28 @@ module YARD
92
92
  log.error "Invalid configuration file, using default options."
93
93
  options.update(DEFAULT_CONFIG_OPTIONS)
94
94
  end
95
-
95
+
96
96
  # Saves settings to {CONFIG_FILE}.
97
97
  # @return [void]
98
98
  def self.save
99
99
  require 'yaml'
100
100
  File.open(CONFIG_FILE, 'w') {|f| f.write(YAML.dump(options)) }
101
101
  end
102
-
102
+
103
103
  # Loads gems that match the name 'yard-*' (recommended) or 'yard_*' except
104
- # those listed in +~/.yard/ignored_plugins+. This is called immediately
104
+ # those listed in +~/.yard/ignored_plugins+. This is called immediately
105
105
  # after YARD is loaded to allow plugin support.
106
- #
106
+ #
107
107
  # @return [Boolean] true if all plugins loaded successfully, false otherwise.
108
108
  def self.load_plugins
109
109
  load_gem_plugins &&
110
110
  load_autoload_plugins &&
111
111
  load_commandline_plugins ? true : false
112
112
  end
113
-
113
+
114
114
  # Loads an individual plugin by name. It is not necessary to include the
115
115
  # +yard-+ plugin prefix here.
116
- #
116
+ #
117
117
  # @param [String] name the name of the plugin (with or without +yard-+ prefix)
118
118
  # @return [Boolean] whether the plugin was successfully loaded
119
119
  def self.load_plugin(name)
@@ -126,9 +126,9 @@ module YARD
126
126
  rescue LoadError => e
127
127
  load_plugin_failed(name, e)
128
128
  end
129
-
129
+
130
130
  private
131
-
131
+
132
132
  # Load gem plugins if :load_plugins is true
133
133
  def self.load_gem_plugins
134
134
  return true unless options[:load_plugins]
@@ -148,12 +148,12 @@ module YARD
148
148
  log.debug "RubyGems is not present, skipping plugin loading"
149
149
  false
150
150
  end
151
-
151
+
152
152
  # Load plugins set in :autoload_plugins
153
153
  def self.load_autoload_plugins
154
154
  options[:autoload_plugins].each {|name| load_plugin(name) }
155
155
  end
156
-
156
+
157
157
  # Load plugins from {#arguments}
158
158
  def self.load_commandline_plugins
159
159
  with_yardopts do
@@ -163,7 +163,7 @@ module YARD
163
163
  end
164
164
  end
165
165
  end
166
-
166
+
167
167
  # Print a warning if the plugin failed to load
168
168
  # @return [false]
169
169
  def self.load_plugin_failed(name, exception)
@@ -171,14 +171,14 @@ module YARD
171
171
  log.backtrace(exception) if $DEBUG
172
172
  false
173
173
  end
174
-
174
+
175
175
  # Legacy support for {IGNORED_PLUGINS}
176
176
  def self.add_ignored_plugins_file
177
177
  if File.file?(IGNORED_PLUGINS)
178
178
  options[:ignored_plugins] += File.read(IGNORED_PLUGINS).split(/\s+/)
179
179
  end
180
180
  end
181
-
181
+
182
182
  # Translates plugin names to add yard- prefix.
183
183
  def self.translate_plugin_names
184
184
  options[:ignored_plugins].map! {|name| translate_plugin_name(name) }
@@ -196,7 +196,7 @@ module YARD
196
196
  {}
197
197
  end
198
198
  end
199
-
199
+
200
200
  # Sanitizes and normalizes a plugin name to include the 'yard-' prefix.
201
201
  # @param [String] name the plugin name
202
202
  # @return [String] the sanitized and normalized plugin name.
@@ -205,7 +205,7 @@ module YARD
205
205
  name = "yard-" + name unless name =~ YARD_PLUGIN_PREFIX
206
206
  name
207
207
  end
208
-
208
+
209
209
  # Temporarily loads .yardopts file into @yardopts
210
210
  def self.with_yardopts(&block)
211
211
  yfile = CLI::Yardoc::DEFAULT_YARDOPTS_FILE
@@ -214,12 +214,12 @@ module YARD
214
214
  @yardopts = nil
215
215
  result
216
216
  end
217
-
217
+
218
218
  # @return [Array<String>] arguments from commandline and yardopts file
219
219
  def self.arguments
220
220
  ARGV + @yardopts
221
221
  end
222
222
  end
223
-
223
+
224
224
  Config.options = Config::DEFAULT_CONFIG_OPTIONS
225
225
  end
@@ -2,13 +2,13 @@ class Array
2
2
  # Places values before or after another object (by value) in
3
3
  # an array. This is used in tandem with the before and after
4
4
  # methods of the {Insertion} class.
5
- #
5
+ #
6
6
  # @example Places an item before another
7
7
  # [1, 2, 3].place(4).before(3) # => [1, 2, 4, 3]
8
8
  # @example Places an item after another
9
9
  # [:a, :b, :c].place(:x).after(:a) # => [:a, :x, :b, :c]
10
10
  # @param [Array] values value to insert
11
- # @return [Insertion] an insertion object to
11
+ # @return [Insertion] an insertion object to
12
12
  # @see Insertion#before
13
13
  # @see Insertion#after
14
14
  def place(*values) Insertion.new(self, values) end
@@ -3,31 +3,31 @@ require 'fileutils'
3
3
  class File
4
4
  RELATIVE_PARENTDIR = '..'
5
5
  RELATIVE_SAMEDIR = '.'
6
-
6
+
7
7
  # @group Manipulating Paths
8
-
8
+
9
9
  # Turns a path +to+ into a relative path from starting
10
10
  # point +from+. The argument +from+ is assumed to be
11
11
  # a filename. To treat it as a directory, make sure it
12
12
  # ends in +File::SEPARATOR+ ('/' on UNIX filesystems).
13
- #
14
- # @param [String] from the starting filename
13
+ #
14
+ # @param [String] from the starting filename
15
15
  # (or directory with +from_isdir+ set to +true+).
16
16
  # @param [String] to the final path that should be made relative.
17
17
  # @return [String] the relative path from +from+ to +to+.
18
18
  def self.relative_path(from, to)
19
19
  from = expand_path(from).split(SEPARATOR)
20
20
  to = expand_path(to).split(SEPARATOR)
21
- from.length.times do
22
- break if from[0] != to[0]
21
+ from.length.times do
22
+ break if from[0] != to[0]
23
23
  from.shift; to.shift
24
24
  end
25
25
  fname = from.pop
26
26
  join(*(from.map { RELATIVE_PARENTDIR } + to))
27
27
  end
28
-
28
+
29
29
  # Cleans a path by removing extraneous '..', '.' and '/' characters
30
- #
30
+ #
31
31
  # @example Clean a path
32
32
  # File.cleanpath('a/b//./c/../e') # => "a/b/e"
33
33
  # @param [String] path the path to clean
@@ -44,9 +44,9 @@ class File
44
44
  end
45
45
  File.join(*path)
46
46
  end
47
-
47
+
48
48
  # @group Reading Files
49
-
49
+
50
50
  # Forces opening a file (for writing) by first creating the file's directory
51
51
  # @param [String] file the filename to open
52
52
  # @since 0.5.2
@@ -55,7 +55,7 @@ class File
55
55
  FileUtils.mkdir_p(dir) unless directory?(dir)
56
56
  open(file, *args, &block)
57
57
  end
58
-
58
+
59
59
  # Reads a file with binary encoding
60
60
  # @return [String] the ascii-8bit encoded data
61
61
  # @since 0.5.3
@@ -1,34 +1,34 @@
1
1
  # The Insertion class inserts a value before or after another
2
2
  # value in a list.
3
- #
3
+ #
4
4
  # @example
5
5
  # Insertion.new([1, 2, 3], 4).before(3) # => [1, 2, 4, 3]
6
6
  class Insertion
7
7
  # Creates an insertion object on a list with a value to be
8
8
  # inserted. To finalize the insertion, call {#before} or
9
9
  # {#after} on the object.
10
- #
10
+ #
11
11
  # @param [Array] list the list to perform the insertion on
12
12
  # @param [Object] value the value to insert
13
13
  def initialize(list, value) @list, @values = list, (Array === value ? value : [value]) end
14
-
14
+
15
15
  # Inserts the value before +val+
16
16
  # @param [Object] val the object the value will be inserted before
17
17
  # @param [Boolean] recursive look inside sublists
18
18
  def before(val, recursive = false) insertion(val, 0, recursive) end
19
-
20
- # Inserts the value after +val+.
21
- #
19
+
20
+ # Inserts the value after +val+.
21
+ #
22
22
  # @example If subsections are ignored
23
23
  # Insertion.new([1, [2], 3], :X).after(1) # => [1, [2], :X, 3]
24
24
  # @param [Object] val the object the value will be inserted after
25
25
  # @param [Boolean] recursive look inside sublists
26
26
  def after(val, recursive = false) insertion(val, 1, recursive) end
27
-
27
+
28
28
  # Alias for {#before} with +recursive+ set to true
29
29
  # @since 0.6.0
30
30
  def before_any(val) insertion(val, 0, true) end
31
-
31
+
32
32
  # Alias for {#after} with +recursive+ set to true
33
33
  # @since 0.6.0
34
34
  def after_any(val) insertion(val, 1, true) end
@@ -36,7 +36,7 @@ class Insertion
36
36
  private
37
37
 
38
38
  # This method performs the actual insertion
39
- #
39
+ #
40
40
  # @param [Object] val the value to insert
41
41
  # @param [Fixnum] rel the relative index (0 or 1) of where the object
42
42
  # should be placed
@@ -51,7 +51,7 @@ class Insertion
51
51
  return(list) unless item == tmp
52
52
  end
53
53
  end
54
-
54
+
55
55
  if index = list.index(val)
56
56
  list[index+rel,0] = @values
57
57
  end
@@ -1,6 +1,6 @@
1
1
  class Module
2
2
  # Returns the class name of a full module namespace path
3
- #
3
+ #
4
4
  # @example
5
5
  # module A::B::C; class_name end # => "C"
6
6
  # @return [String] the last part of a module path
@@ -9,7 +9,7 @@ class Module
9
9
  end
10
10
 
11
11
  # Returns the module namespace path minus the class/module name
12
- #
12
+ #
13
13
  # @example
14
14
  # module A::B::C; namespace_name end # => "A::B"
15
15
  # @return [String] the namespace minus the class/module name
@@ -2,7 +2,7 @@ class String
2
2
  # Splits text into tokens the way a shell would, handling quoted
3
3
  # text as a single token. Use '\"' and "\'" to escape quotes and
4
4
  # '\\' to escape a backslash.
5
- #
5
+ #
6
6
  # @return [Array] an array representing the tokens
7
7
  def shell_split
8
8
  out = [""]
@@ -45,7 +45,7 @@ class String
45
45
  escape_next = false
46
46
  elsif char == state
47
47
  out.last << quote
48
- state = :none
48
+ state = :none
49
49
  else
50
50
  quote << char
51
51
  end
@@ -1,8 +1,8 @@
1
- # A subclass of Hash where all keys are converted into Symbols, and
1
+ # A subclass of Hash where all keys are converted into Symbols, and
2
2
  # optionally, all String values are converted into Symbols.
3
3
  class SymbolHash < Hash
4
4
  # Creates a new SymbolHash object
5
- #
5
+ #
6
6
  # @param [Boolean] symbolize_value converts any String values into Symbols
7
7
  # if this is set to +true+.
8
8
  def initialize(symbolize_value = true)
@@ -11,15 +11,15 @@ class SymbolHash < Hash
11
11
 
12
12
  # @overload [](hash)
13
13
  # Creates a SymbolHash object from an existing Hash
14
- #
14
+ #
15
15
  # @example
16
16
  # SymbolHash['x' => 1, :y => 2] # => #<SymbolHash:0x...>
17
17
  # @param [Hash] hash the hash object
18
18
  # @return [SymbolHash] a new SymbolHash from a hash object
19
- #
19
+ #
20
20
  # @overload [](*list)
21
21
  # Creates a SymbolHash from an even list of keys and values
22
- #
22
+ #
23
23
  # @example
24
24
  # SymbolHash[key1, value1, key2, value2, ...]
25
25
  # @param [Array] list an even list of key followed by value
@@ -33,40 +33,40 @@ class SymbolHash < Hash
33
33
  end
34
34
  obj
35
35
  end
36
-
36
+
37
37
  # Assigns a value to a symbolized key
38
38
  # @param [#to_sym] key the key
39
39
  # @param [Object] value the value to be assigned. If this is a String and
40
40
  # values are set to be symbolized, it will be converted into a Symbol.
41
- def []=(key, value)
42
- super(key.to_sym, value.instance_of?(String) && @symbolize_value ? value.to_sym : value)
41
+ def []=(key, value)
42
+ super(key.to_sym, value.instance_of?(String) && @symbolize_value ? value.to_sym : value)
43
43
  end
44
-
44
+
45
45
  # Accessed a symbolized key
46
46
  # @param [#to_sym] key the key to access
47
47
  # @return [Object] the value associated with the key
48
48
  def [](key) super(key.to_sym) end
49
-
49
+
50
50
  # Deleted a key and value associated with it
51
51
  # @param [#to_sym] key the key to delete
52
52
  # @return [void]
53
53
  def delete(key) super(key.to_sym) end
54
-
54
+
55
55
  # Tests if a symbolized key exists
56
56
  # @param [#to_sym] key the key to test
57
57
  # @return [Boolean] whether the key exists
58
58
  def has_key?(key) super(key.to_sym) end
59
-
59
+
60
60
  # Updates the object with the contents of another Hash object
61
61
  # This method modifies the original SymbolHash object
62
- #
62
+ #
63
63
  # @param [Hash] hash the hash object to copy the values from
64
64
  # @return [SymbolHash] self
65
65
  def update(hash) hash.each {|k,v| self[k] = v }; self end
66
66
  alias_method :merge!, :update
67
67
 
68
68
  # Merges the contents of another hash into a new SymbolHash object
69
- #
69
+ #
70
70
  # @param [Hash] hash the hash of objects to copy
71
71
  # @return [SymbolHash] a new SymbolHash containing the merged data
72
72
  def merge(hash) dup.merge!(hash) end