echonet_lite 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (346) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +5 -0
  5. data/CODE_OF_CONDUCT.md +74 -0
  6. data/Gemfile +6 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +43 -0
  9. data/Rakefile +6 -0
  10. data/bin/console +14 -0
  11. data/bin/setup +8 -0
  12. data/echonet_lite.gemspec +37 -0
  13. data/lib/echonet_lite.rb +149 -0
  14. data/lib/echonet_lite/version.rb +3 -0
  15. data/vendor/bundle/bin/htmldiff +29 -0
  16. data/vendor/bundle/bin/htmldiff.bat +6 -0
  17. data/vendor/bundle/bin/ldiff +29 -0
  18. data/vendor/bundle/bin/ldiff.bat +6 -0
  19. data/vendor/bundle/bin/rspec +27 -0
  20. data/vendor/bundle/bin/rspec.bat +6 -0
  21. data/vendor/bundle/cache/diff-lcs-1.3.gem +0 -0
  22. data/vendor/bundle/cache/echonet_lite-0.1.0.gem +0 -0
  23. data/vendor/bundle/cache/ipaddr-1.0.0.gem +0 -0
  24. data/vendor/bundle/cache/ipaddress-0.8.3.gem +0 -0
  25. data/vendor/bundle/cache/rspec-3.6.0.gem +0 -0
  26. data/vendor/bundle/cache/rspec-core-3.6.0.gem +0 -0
  27. data/vendor/bundle/cache/rspec-expectations-3.6.0.gem +0 -0
  28. data/vendor/bundle/cache/rspec-mocks-3.6.0.gem +0 -0
  29. data/vendor/bundle/cache/rspec-support-3.6.0.gem +0 -0
  30. data/vendor/bundle/doc/echonet_lite-0.1.0/ri/EL/GSET-c.ri +0 -0
  31. data/vendor/bundle/doc/echonet_lite-0.1.0/ri/EL/Hexadecimal_str-c.ri +0 -0
  32. data/vendor/bundle/doc/echonet_lite-0.1.0/ri/EL/Receive-c.ri +0 -0
  33. data/vendor/bundle/doc/echonet_lite-0.1.0/ri/EL/ReceivePrint-c.ri +0 -0
  34. data/vendor/bundle/doc/echonet_lite-0.1.0/ri/EL/SETC-c.ri +0 -0
  35. data/vendor/bundle/doc/echonet_lite-0.1.0/ri/EL/SETI-c.ri +0 -0
  36. data/vendor/bundle/doc/echonet_lite-0.1.0/ri/EL/cdesc-EL.ri +0 -0
  37. data/vendor/bundle/doc/echonet_lite-0.1.0/ri/EL/pattern-c.ri +0 -0
  38. data/vendor/bundle/doc/echonet_lite-0.1.0/ri/EL/search-c.ri +0 -0
  39. data/vendor/bundle/doc/echonet_lite-0.1.0/ri/EL/sendOPC1-c.ri +0 -0
  40. data/vendor/bundle/doc/echonet_lite-0.1.0/ri/EL/sendString-c.ri +0 -0
  41. data/vendor/bundle/doc/echonet_lite-0.1.0/ri/EL/udp_send-c.ri +0 -0
  42. data/vendor/bundle/doc/echonet_lite-0.1.0/ri/EchonetLite/cdesc-EchonetLite.ri +0 -0
  43. data/vendor/bundle/doc/echonet_lite-0.1.0/ri/cache.ri +0 -0
  44. data/vendor/bundle/gems/diff-lcs-1.3/.rspec +1 -0
  45. data/vendor/bundle/gems/diff-lcs-1.3/Code-of-Conduct.md +74 -0
  46. data/vendor/bundle/gems/diff-lcs-1.3/Contributing.md +83 -0
  47. data/vendor/bundle/gems/diff-lcs-1.3/History.md +220 -0
  48. data/vendor/bundle/gems/diff-lcs-1.3/License.md +39 -0
  49. data/vendor/bundle/gems/diff-lcs-1.3/Manifest.txt +37 -0
  50. data/vendor/bundle/gems/diff-lcs-1.3/README.rdoc +84 -0
  51. data/vendor/bundle/gems/diff-lcs-1.3/Rakefile +57 -0
  52. data/vendor/bundle/gems/diff-lcs-1.3/autotest/discover.rb +1 -0
  53. data/vendor/bundle/gems/diff-lcs-1.3/bin/htmldiff +32 -0
  54. data/vendor/bundle/gems/diff-lcs-1.3/bin/ldiff +6 -0
  55. data/vendor/bundle/gems/diff-lcs-1.3/docs/COPYING.txt +339 -0
  56. data/vendor/bundle/gems/diff-lcs-1.3/docs/artistic.txt +127 -0
  57. data/vendor/bundle/gems/diff-lcs-1.3/lib/diff-lcs.rb +3 -0
  58. data/vendor/bundle/gems/diff-lcs-1.3/lib/diff/lcs.rb +725 -0
  59. data/vendor/bundle/gems/diff-lcs-1.3/lib/diff/lcs/array.rb +7 -0
  60. data/vendor/bundle/gems/diff-lcs-1.3/lib/diff/lcs/block.rb +37 -0
  61. data/vendor/bundle/gems/diff-lcs-1.3/lib/diff/lcs/callbacks.rb +322 -0
  62. data/vendor/bundle/gems/diff-lcs-1.3/lib/diff/lcs/change.rb +181 -0
  63. data/vendor/bundle/gems/diff-lcs-1.3/lib/diff/lcs/htmldiff.rb +149 -0
  64. data/vendor/bundle/gems/diff-lcs-1.3/lib/diff/lcs/hunk.rb +276 -0
  65. data/vendor/bundle/gems/diff-lcs-1.3/lib/diff/lcs/internals.rb +307 -0
  66. data/vendor/bundle/gems/diff-lcs-1.3/lib/diff/lcs/ldiff.rb +167 -0
  67. data/vendor/bundle/gems/diff-lcs-1.3/lib/diff/lcs/string.rb +5 -0
  68. data/vendor/bundle/gems/diff-lcs-1.3/spec/change_spec.rb +65 -0
  69. data/vendor/bundle/gems/diff-lcs-1.3/spec/diff_spec.rb +47 -0
  70. data/vendor/bundle/gems/diff-lcs-1.3/spec/fixtures/ds1.csv +50 -0
  71. data/vendor/bundle/gems/diff-lcs-1.3/spec/fixtures/ds2.csv +51 -0
  72. data/vendor/bundle/gems/diff-lcs-1.3/spec/hunk_spec.rb +72 -0
  73. data/vendor/bundle/gems/diff-lcs-1.3/spec/issues_spec.rb +49 -0
  74. data/vendor/bundle/gems/diff-lcs-1.3/spec/lcs_spec.rb +56 -0
  75. data/vendor/bundle/gems/diff-lcs-1.3/spec/ldiff_spec.rb +47 -0
  76. data/vendor/bundle/gems/diff-lcs-1.3/spec/patch_spec.rb +422 -0
  77. data/vendor/bundle/gems/diff-lcs-1.3/spec/sdiff_spec.rb +214 -0
  78. data/vendor/bundle/gems/diff-lcs-1.3/spec/spec_helper.rb +321 -0
  79. data/vendor/bundle/gems/diff-lcs-1.3/spec/traverse_balanced_spec.rb +310 -0
  80. data/vendor/bundle/gems/diff-lcs-1.3/spec/traverse_sequences_spec.rb +139 -0
  81. data/vendor/bundle/gems/echonet_lite-0.1.0/.gitignore +12 -0
  82. data/vendor/bundle/gems/echonet_lite-0.1.0/.rspec +2 -0
  83. data/vendor/bundle/gems/echonet_lite-0.1.0/.travis.yml +5 -0
  84. data/vendor/bundle/gems/echonet_lite-0.1.0/CODE_OF_CONDUCT.md +74 -0
  85. data/vendor/bundle/gems/echonet_lite-0.1.0/Gemfile +6 -0
  86. data/vendor/bundle/gems/echonet_lite-0.1.0/LICENSE.txt +21 -0
  87. data/vendor/bundle/gems/echonet_lite-0.1.0/README.md +43 -0
  88. data/vendor/bundle/gems/echonet_lite-0.1.0/Rakefile +6 -0
  89. data/vendor/bundle/gems/echonet_lite-0.1.0/bin/console +14 -0
  90. data/vendor/bundle/gems/echonet_lite-0.1.0/bin/setup +8 -0
  91. data/vendor/bundle/gems/echonet_lite-0.1.0/echonet_lite.gemspec +37 -0
  92. data/vendor/bundle/gems/echonet_lite-0.1.0/lib/echonet_lite.rb +149 -0
  93. data/vendor/bundle/gems/echonet_lite-0.1.0/lib/echonet_lite/version.rb +3 -0
  94. data/vendor/bundle/gems/ipaddr-1.0.0/.gitignore +9 -0
  95. data/vendor/bundle/gems/ipaddr-1.0.0/.travis.yml +6 -0
  96. data/vendor/bundle/gems/ipaddr-1.0.0/Gemfile +4 -0
  97. data/vendor/bundle/gems/ipaddr-1.0.0/LICENSE.txt +23 -0
  98. data/vendor/bundle/gems/ipaddr-1.0.0/README.md +54 -0
  99. data/vendor/bundle/gems/ipaddr-1.0.0/Rakefile +10 -0
  100. data/vendor/bundle/gems/ipaddr-1.0.0/bin/console +14 -0
  101. data/vendor/bundle/gems/ipaddr-1.0.0/bin/setup +8 -0
  102. data/vendor/bundle/gems/ipaddr-1.0.0/ipaddr.gemspec +28 -0
  103. data/vendor/bundle/gems/ipaddr-1.0.0/lib/ipaddr.rb +662 -0
  104. data/vendor/bundle/gems/ipaddress-0.8.3/.document +5 -0
  105. data/vendor/bundle/gems/ipaddress-0.8.3/.gitignore +18 -0
  106. data/vendor/bundle/gems/ipaddress-0.8.3/.rock.yml +5 -0
  107. data/vendor/bundle/gems/ipaddress-0.8.3/CHANGELOG.rdoc +115 -0
  108. data/vendor/bundle/gems/ipaddress-0.8.3/Gemfile +3 -0
  109. data/vendor/bundle/gems/ipaddress-0.8.3/LICENSE.txt +20 -0
  110. data/vendor/bundle/gems/ipaddress-0.8.3/README.rdoc +998 -0
  111. data/vendor/bundle/gems/ipaddress-0.8.3/Rakefile +66 -0
  112. data/vendor/bundle/gems/ipaddress-0.8.3/ipaddress.gemspec +26 -0
  113. data/vendor/bundle/gems/ipaddress-0.8.3/lib/ipaddress.rb +227 -0
  114. data/vendor/bundle/gems/ipaddress-0.8.3/lib/ipaddress/ipv4.rb +1114 -0
  115. data/vendor/bundle/gems/ipaddress-0.8.3/lib/ipaddress/ipv6.rb +895 -0
  116. data/vendor/bundle/gems/ipaddress-0.8.3/lib/ipaddress/mongoid.rb +75 -0
  117. data/vendor/bundle/gems/ipaddress-0.8.3/lib/ipaddress/prefix.rb +265 -0
  118. data/vendor/bundle/gems/ipaddress-0.8.3/lib/ipaddress/version.rb +3 -0
  119. data/vendor/bundle/gems/ipaddress-0.8.3/test/ipaddress/ipv4_test.rb +600 -0
  120. data/vendor/bundle/gems/ipaddress-0.8.3/test/ipaddress/ipv6_test.rb +426 -0
  121. data/vendor/bundle/gems/ipaddress-0.8.3/test/ipaddress/mongoid_test.rb +70 -0
  122. data/vendor/bundle/gems/ipaddress-0.8.3/test/ipaddress/prefix_test.rb +153 -0
  123. data/vendor/bundle/gems/ipaddress-0.8.3/test/ipaddress_test.rb +82 -0
  124. data/vendor/bundle/gems/ipaddress-0.8.3/test/test_helper.rb +35 -0
  125. data/vendor/bundle/gems/rspec-3.6.0/LICENSE.md +27 -0
  126. data/vendor/bundle/gems/rspec-3.6.0/README.md +39 -0
  127. data/vendor/bundle/gems/rspec-3.6.0/lib/rspec.rb +3 -0
  128. data/vendor/bundle/gems/rspec-3.6.0/lib/rspec/version.rb +5 -0
  129. data/vendor/bundle/gems/rspec-core-3.6.0/.document +5 -0
  130. data/vendor/bundle/gems/rspec-core-3.6.0/.yardopts +8 -0
  131. data/vendor/bundle/gems/rspec-core-3.6.0/Changelog.md +2167 -0
  132. data/vendor/bundle/gems/rspec-core-3.6.0/LICENSE.md +26 -0
  133. data/vendor/bundle/gems/rspec-core-3.6.0/README.md +384 -0
  134. data/vendor/bundle/gems/rspec-core-3.6.0/exe/rspec +4 -0
  135. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/autorun.rb +3 -0
  136. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core.rb +185 -0
  137. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/backtrace_formatter.rb +65 -0
  138. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/bisect/coordinator.rb +66 -0
  139. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/bisect/example_minimizer.rb +169 -0
  140. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/bisect/runner.rb +169 -0
  141. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/bisect/server.rb +70 -0
  142. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/configuration.rb +2177 -0
  143. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/configuration_options.rb +196 -0
  144. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/drb.rb +113 -0
  145. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/dsl.rb +98 -0
  146. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/example.rb +653 -0
  147. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/example_group.rb +883 -0
  148. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/example_status_persister.rb +235 -0
  149. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/filter_manager.rb +231 -0
  150. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/flat_map.rb +20 -0
  151. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/formatters.rb +265 -0
  152. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/formatters/base_formatter.rb +70 -0
  153. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/formatters/base_text_formatter.rb +75 -0
  154. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/formatters/bisect_formatter.rb +69 -0
  155. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/formatters/bisect_progress_formatter.rb +144 -0
  156. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/formatters/console_codes.rb +68 -0
  157. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/formatters/deprecation_formatter.rb +223 -0
  158. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/formatters/documentation_formatter.rb +70 -0
  159. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/formatters/exception_presenter.rb +496 -0
  160. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/formatters/fallback_message_formatter.rb +28 -0
  161. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/formatters/helpers.rb +110 -0
  162. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/formatters/html_formatter.rb +153 -0
  163. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/formatters/html_printer.rb +414 -0
  164. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/formatters/html_snippet_extractor.rb +118 -0
  165. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/formatters/json_formatter.rb +101 -0
  166. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/formatters/profile_formatter.rb +68 -0
  167. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/formatters/progress_formatter.rb +29 -0
  168. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/formatters/protocol.rb +182 -0
  169. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/formatters/snippet_extractor.rb +134 -0
  170. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/formatters/syntax_highlighter.rb +91 -0
  171. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/hooks.rb +624 -0
  172. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/invocations.rb +85 -0
  173. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/memoized_helpers.rb +535 -0
  174. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/metadata.rb +499 -0
  175. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/metadata_filter.rb +255 -0
  176. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/minitest_assertions_adapter.rb +31 -0
  177. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/mocking_adapters/flexmock.rb +31 -0
  178. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/mocking_adapters/mocha.rb +57 -0
  179. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/mocking_adapters/null.rb +14 -0
  180. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/mocking_adapters/rr.rb +31 -0
  181. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/mocking_adapters/rspec.rb +32 -0
  182. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/notifications.rb +514 -0
  183. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/option_parser.rb +309 -0
  184. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/ordering.rb +158 -0
  185. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/output_wrapper.rb +29 -0
  186. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/pending.rb +165 -0
  187. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/profiler.rb +32 -0
  188. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/project_initializer.rb +48 -0
  189. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/project_initializer/.rspec +1 -0
  190. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/project_initializer/spec/spec_helper.rb +100 -0
  191. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/rake_task.rb +168 -0
  192. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/reporter.rb +260 -0
  193. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/ruby_project.rb +53 -0
  194. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/runner.rb +193 -0
  195. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/sandbox.rb +37 -0
  196. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/set.rb +54 -0
  197. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/shared_context.rb +55 -0
  198. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/shared_example_group.rb +271 -0
  199. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/shell_escape.rb +49 -0
  200. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/test_unit_assertions_adapter.rb +30 -0
  201. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/version.rb +9 -0
  202. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/warnings.rb +40 -0
  203. data/vendor/bundle/gems/rspec-core-3.6.0/lib/rspec/core/world.rb +264 -0
  204. data/vendor/bundle/gems/rspec-expectations-3.6.0/.document +5 -0
  205. data/vendor/bundle/gems/rspec-expectations-3.6.0/.yardopts +6 -0
  206. data/vendor/bundle/gems/rspec-expectations-3.6.0/Changelog.md +1072 -0
  207. data/vendor/bundle/gems/rspec-expectations-3.6.0/LICENSE.md +25 -0
  208. data/vendor/bundle/gems/rspec-expectations-3.6.0/README.md +305 -0
  209. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/expectations.rb +82 -0
  210. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/expectations/block_snippet_extractor.rb +253 -0
  211. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/expectations/configuration.rb +201 -0
  212. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/expectations/expectation_target.rb +127 -0
  213. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/expectations/fail_with.rb +39 -0
  214. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/expectations/failure_aggregator.rb +194 -0
  215. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/expectations/handler.rb +170 -0
  216. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/expectations/minitest_integration.rb +58 -0
  217. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/expectations/syntax.rb +132 -0
  218. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/expectations/version.rb +8 -0
  219. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers.rb +1025 -0
  220. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/aliased_matcher.rb +116 -0
  221. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in.rb +52 -0
  222. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/all.rb +85 -0
  223. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/base_matcher.rb +193 -0
  224. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/be.rb +288 -0
  225. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/be_between.rb +77 -0
  226. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/be_instance_of.rb +22 -0
  227. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/be_kind_of.rb +16 -0
  228. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/be_within.rb +72 -0
  229. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/change.rb +387 -0
  230. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/compound.rb +272 -0
  231. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/contain_exactly.rb +301 -0
  232. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/cover.rb +24 -0
  233. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/eq.rb +40 -0
  234. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/eql.rb +34 -0
  235. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/equal.rb +81 -0
  236. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/exist.rb +90 -0
  237. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/has.rb +103 -0
  238. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/have_attributes.rb +114 -0
  239. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/include.rb +143 -0
  240. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/match.rb +106 -0
  241. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/operators.rb +128 -0
  242. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/output.rb +200 -0
  243. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/raise_error.rb +230 -0
  244. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/respond_to.rb +165 -0
  245. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/satisfy.rb +60 -0
  246. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/start_or_end_with.rb +94 -0
  247. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/throw_symbol.rb +132 -0
  248. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/built_in/yield.rb +432 -0
  249. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/composable.rb +169 -0
  250. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/dsl.rb +527 -0
  251. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/english_phrasing.rb +58 -0
  252. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/expecteds_for_multiple_diffs.rb +73 -0
  253. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/fail_matchers.rb +42 -0
  254. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/generated_descriptions.rb +42 -0
  255. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/matcher_delegator.rb +35 -0
  256. data/vendor/bundle/gems/rspec-expectations-3.6.0/lib/rspec/matchers/matcher_protocol.rb +99 -0
  257. data/vendor/bundle/gems/rspec-mocks-3.6.0/.document +5 -0
  258. data/vendor/bundle/gems/rspec-mocks-3.6.0/.yardopts +6 -0
  259. data/vendor/bundle/gems/rspec-mocks-3.6.0/Changelog.md +1073 -0
  260. data/vendor/bundle/gems/rspec-mocks-3.6.0/LICENSE.md +25 -0
  261. data/vendor/bundle/gems/rspec-mocks-3.6.0/README.md +460 -0
  262. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks.rb +130 -0
  263. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/any_instance.rb +11 -0
  264. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/any_instance/chain.rb +110 -0
  265. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/any_instance/error_generator.rb +31 -0
  266. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/any_instance/expect_chain_chain.rb +31 -0
  267. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/any_instance/expectation_chain.rb +50 -0
  268. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/any_instance/message_chains.rb +83 -0
  269. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/any_instance/proxy.rb +116 -0
  270. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/any_instance/recorder.rb +289 -0
  271. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/any_instance/stub_chain.rb +51 -0
  272. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/any_instance/stub_chain_chain.rb +23 -0
  273. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/argument_list_matcher.rb +100 -0
  274. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/argument_matchers.rb +320 -0
  275. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/configuration.rb +212 -0
  276. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/error_generator.rb +369 -0
  277. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/example_methods.rb +434 -0
  278. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/instance_method_stasher.rb +146 -0
  279. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/marshal_extension.rb +41 -0
  280. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/matchers/expectation_customization.rb +20 -0
  281. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/matchers/have_received.rb +130 -0
  282. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/matchers/receive.rb +132 -0
  283. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/matchers/receive_message_chain.rb +82 -0
  284. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/matchers/receive_messages.rb +77 -0
  285. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/message_chain.rb +87 -0
  286. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/message_expectation.rb +740 -0
  287. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/method_double.rb +287 -0
  288. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/method_reference.rb +202 -0
  289. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/minitest_integration.rb +68 -0
  290. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/mutate_const.rb +339 -0
  291. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/object_reference.rb +149 -0
  292. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/order_group.rb +81 -0
  293. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/proxy.rb +484 -0
  294. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/space.rb +238 -0
  295. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/standalone.rb +3 -0
  296. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/syntax.rb +325 -0
  297. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/targets.rb +124 -0
  298. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/test_double.rb +171 -0
  299. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/verifying_double.rb +129 -0
  300. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/verifying_message_expectation.rb +54 -0
  301. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/verifying_proxy.rb +220 -0
  302. data/vendor/bundle/gems/rspec-mocks-3.6.0/lib/rspec/mocks/version.rb +9 -0
  303. data/vendor/bundle/gems/rspec-support-3.6.0/Changelog.md +211 -0
  304. data/vendor/bundle/gems/rspec-support-3.6.0/LICENSE.md +23 -0
  305. data/vendor/bundle/gems/rspec-support-3.6.0/README.md +40 -0
  306. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support.rb +139 -0
  307. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/caller_filter.rb +83 -0
  308. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/comparable_version.rb +46 -0
  309. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/differ.rb +215 -0
  310. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/directory_maker.rb +63 -0
  311. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/encoded_string.rb +165 -0
  312. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/fuzzy_matcher.rb +48 -0
  313. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/hunk_generator.rb +47 -0
  314. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/matcher_definition.rb +42 -0
  315. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/method_signature_verifier.rb +392 -0
  316. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/mutex.rb +73 -0
  317. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/object_formatter.rb +268 -0
  318. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/recursive_const_methods.rb +76 -0
  319. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/reentrant_mutex.rb +53 -0
  320. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/ruby_features.rb +162 -0
  321. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/source.rb +75 -0
  322. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/source/location.rb +21 -0
  323. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/source/node.rb +107 -0
  324. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/source/token.rb +87 -0
  325. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/spec.rb +81 -0
  326. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/spec/deprecation_helpers.rb +64 -0
  327. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/spec/formatting_support.rb +9 -0
  328. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/spec/in_sub_process.rb +69 -0
  329. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/spec/library_wide_checks.rb +150 -0
  330. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/spec/shell_out.rb +84 -0
  331. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/spec/stderr_splitter.rb +63 -0
  332. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/spec/string_matcher.rb +46 -0
  333. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/spec/with_isolated_directory.rb +13 -0
  334. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/spec/with_isolated_stderr.rb +13 -0
  335. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/version.rb +7 -0
  336. data/vendor/bundle/gems/rspec-support-3.6.0/lib/rspec/support/warnings.rb +39 -0
  337. data/vendor/bundle/specifications/diff-lcs-1.3.gemspec +61 -0
  338. data/vendor/bundle/specifications/echonet_lite-0.1.0.gemspec +43 -0
  339. data/vendor/bundle/specifications/ipaddr-1.0.0.gemspec +38 -0
  340. data/vendor/bundle/specifications/ipaddress-0.8.3.gemspec +35 -0
  341. data/vendor/bundle/specifications/rspec-3.6.0.gemspec +42 -0
  342. data/vendor/bundle/specifications/rspec-core-3.6.0.gemspec +62 -0
  343. data/vendor/bundle/specifications/rspec-expectations-3.6.0.gemspec +50 -0
  344. data/vendor/bundle/specifications/rspec-mocks-3.6.0.gemspec +50 -0
  345. data/vendor/bundle/specifications/rspec-support-3.6.0.gemspec +41 -0
  346. metadata +444 -0
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,18 @@
1
+ *.a
2
+ /.bundle/
3
+ *.bundle
4
+ /coverage/
5
+ /doc/
6
+ .DS_Store
7
+ /Gemfile.lock
8
+ ipaddr.html
9
+ mkmf.log
10
+ *.o
11
+ /pkg/
12
+ rdoc
13
+ server.rb
14
+ *.so
15
+ /spec/reports/
16
+ *.sw?
17
+ /tmp/
18
+ /_yardoc/
@@ -0,0 +1,5 @@
1
+ runtime: ruby21
2
+ doc: exec rake rdoc
3
+ build: |
4
+ rock clean
5
+ {{parent}}
@@ -0,0 +1,115 @@
1
+ == ipaddress 0.8.2
2
+
3
+ CHANGED:: merged bundler branch to cleanup gemspec and Rakefiles
4
+ FIXED:: IPAddress::IPv4.split handling (Issue #40)
5
+ NEW:: Added #[]= method to IPv4/6 classes to add octet writing support. (Issue #24)
6
+ NEW:: IPV4#multicast?
7
+ NEW:: IPV4#loopback?
8
+ NEW:: IPV4#to()
9
+
10
+ == ipaddress 0.8.1
11
+
12
+ CHANGED:: ipaddress now uses minitest for testing, all tests passing
13
+
14
+ == ipaddress 0.8.0
15
+
16
+ CHANGED:: ipaddress now uses this[https://gist.github.com/cpetschnig/294476] regexp to validate IPv6 addresses. Thanks to Christoph Petschnig for his regexp and to Bronislav Robenek for fixing this.
17
+ CHANGED:: Removed extension methods and extension directory to facilitate integration with the stdlib
18
+ CHANGED:: Reworked IPv4#<=>, now intuitively sorts objects based on the prefix
19
+ CHANGED:: IPv4#supernet now returns "0.0.0.0/0" if supernetting with a prefix less than 1
20
+ CHANGED:: IPv4#subnet now accept a new prefix instead of number of subnets (as per RFC3531)
21
+ NEW:: IPv6#network
22
+ NEW:: Prefix128#host_prefix
23
+ NEW:: IPv6#broadcast_u128
24
+ NEW:: IPv6#each
25
+ NEW:: IPv6#<=>
26
+ NEW:: IPv4#split
27
+ NEW:: IP#ntoa
28
+
29
+ == ipaddress 0.7.5
30
+
31
+ CHANGED:: IPAddress::IPv4#each_host to improve speed
32
+ FIXED:: IPAddress::IPv4::summarize bug (summarization should now work properly)
33
+ NEW:: IPAddress::IPv4#include_all?
34
+ NEW:: #ipv4? and #ipv6?
35
+
36
+ == ipaddress 0.7.0
37
+
38
+ NEW:: IPAddress::IPv6#include?
39
+ NEW:: IPAddress::IPv6#network_u128
40
+ NEW:: Modified IPAddress::IPv6::Mapped to accept IPv4 mapped addresses in IPv6 format
41
+ NEW:: IPAddress::IPv4#private?
42
+ NEW:: IPAddress::IPv4::parse_classful
43
+
44
+ == ipaddress 0.6.0
45
+
46
+ === API changes
47
+ * IPv4#to_s now returns the address portion only,
48
+ to retain compatibility with IPAddr. Example:
49
+
50
+ IPAddress("172.16.10.1/24").to_s
51
+ #=> "172.16.10.1" # ipaddress 0.6.0
52
+
53
+ IPAddress("172.16.10.1/24").to_s
54
+ #=> "172.16.10.1/24" # ipaddress 0.5.0
55
+
56
+ * IPv6#to_s now returns the address portion only,
57
+ to retain compatibility with IPAddr. Example:
58
+
59
+ IPAddress "2001:db8::8:800:200c:417a/64".to_s
60
+ #=> "2001:db8::8:800:200c:417a" # ipaddress 0.6.0
61
+
62
+ IPAddress "2001:db8::8:800:200c:417a/64".to_s
63
+ #=> "2001:db8::8:800:200c:417a/64" # ipaddress 0.6.0
64
+
65
+ * IPv6::Unspecified#to_s, IPv6::Loopback and
66
+ IPv6::Mapped#to_s now return the address portion only,
67
+ to retain compatibility with IPAddr.
68
+ * IPv4::summarize now returns an array even if the
69
+ result is a single subnet, to keep consistency
70
+ and avoid confusion
71
+
72
+ === New methods
73
+ * IPv4#to_string and IPv6#to_string: print the address
74
+ with the prefix portion, like the #to_s method in
75
+ ipaddress 0.5.0
76
+ * IPAddress::parse, for those who don't like the wrapper
77
+ method IPAddress()
78
+ * IPv6#to_string_uncompressed, returns a string with the
79
+ uncompressed IPv6 and the prefix
80
+ * IPv6::Mapped#to_string, returns the IPv6 Mapped address
81
+ with IPv4 notation and the prefix
82
+ * IPv6#reverse, returns the ip6.arpa DNS reverse lookup
83
+ string
84
+ * IPv4#arpa and IPv6#arpa, alias of the respective #reverse
85
+ methods
86
+ * Prefix#+, Prefix#-
87
+
88
+ === Library structure
89
+ * Moved all the IPAddress module methods from
90
+ lib/ipaddress/ipbase.rb to lib/ipaddress.rb
91
+ * Removed IPBase superclass
92
+ * IPv4 and IPv6 classes no longer inherit from IPBase
93
+ * Removed lib/ipaddress/ipbase.rb
94
+ * Removed test/ipaddress/ipbase_test.rb
95
+
96
+ === Minor fixes
97
+ * Replaced Ruby 1.9 deprecated Hash#index with Hash#key
98
+ * Removed require ruby-prof from tests which was causing
99
+ users to install ruby-prof or manually remove the line
100
+ * Removed "must" method from tests, replaced by normal
101
+ Test::Unit methods
102
+ * Removed duplicate Jeweler entry in Rakefile
103
+ * Made Integer#closest_power_of_2 more general by adding
104
+ an optional limit parameter
105
+ * Fixed summarization algorithm (thanks to nicolas fevrier)
106
+ * Fixed bug in prefix_from_ip (thanks to jdpace)
107
+
108
+ === Documentation
109
+ * Normalized README rdoc headers
110
+ * Added documentation for IPAddress::Prefix
111
+ * Added documentation for IPAddress::IPv4 and
112
+ IPAddress::IPv6
113
+ * Fixed formatting
114
+ * Fixed lots of typos
115
+
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009-2015 Marco Ceresa
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,998 @@
1
+ == <b>IPAddress 1.0 is currently under development and will be released soon! Stay tuned!</b>
2
+
3
+ ---
4
+
5
+ = IPAddress
6
+
7
+ IPAddress is a Ruby library designed to make the use of IPv4 and IPv6
8
+ addresses simple, powerful and enjoyable. It provides a complete set of
9
+ methods to handle IP addresses for any need, from simple scripting to
10
+ full network design.
11
+
12
+ IPAddress is written with a full OO interface, and its code is easy to
13
+ read, maintain and extend. The documentation is full of examples, to
14
+ let you start being productive immediately.
15
+
16
+ This document provides a brief introduction to the library and
17
+ examples of typical usage.
18
+
19
+ == Requirements
20
+
21
+ * Ruby >= 1.8.7 (not tested with previous versions)
22
+ * Ruby 1.9.2 or later is strongly recommended
23
+
24
+ IPAddress 0.8.2 has been tested on:
25
+
26
+ * ruby-1.8.7-p334 [ i386 ]
27
+ * ree-1.8.7-2011.03 [ i386 ]
28
+ * rbx-head [ ]
29
+ * jruby-1.6.1 [ linux-i386-java ]
30
+ * ruby-1.9.1-p431 [ i386 ]
31
+ * ruby-1.9.2-p180 [ i386 ]
32
+ * ruby-2.0.0-p353 [ x86_64-darwin14.0.0 ]
33
+ * ruby-2.1.3-p242 [ x86_64-darwin14.0.0 ]
34
+
35
+ If you want to collaborate feel
36
+ free to send a small report to my email address, or
37
+ {join the discussion}[http://groups.google.com/group/ruby-ipaddress].
38
+
39
+
40
+ == Installation
41
+
42
+ Install the library using rubygems
43
+
44
+ $ gem install ipaddress
45
+
46
+ You can then use it in your programs:
47
+
48
+ require 'rubygems' # optional
49
+ require 'ipaddress'
50
+
51
+ Another way would be to clone the git repository
52
+
53
+ $ git clone git://github.com/bluemonk/ipaddress.git
54
+
55
+ And then install the library
56
+
57
+ $ cd ipaddress
58
+ ipaddress$ rake install
59
+
60
+ == Documentation
61
+
62
+ The code is fully documented with RDoc. You can generate the
63
+ documentation with Rake:
64
+
65
+ ipaddress$ rake rdoc
66
+
67
+ The latest documentation can be found online at
68
+ {this address}[http://rubydoc.info/gems/ipaddress/0.8.0/frames]
69
+
70
+ == IPv4
71
+
72
+ Class `IPAddress::IPv4` is used to handle IPv4 type addresses. IPAddress
73
+ is similar to other IP Addresses libraries, like Ruby's own
74
+ IPAddr. However it works slightly different, as we will see.
75
+
76
+ === Create a new IPv4 address
77
+
78
+ The usual way to express an IP Address is using its dotted decimal
79
+ form, such as `172.16.10.1`, and a prefix, such as `24`, separated by a
80
+ slash.
81
+
82
+ 172.16.10.1/24
83
+
84
+ To create a new IPv4 object, you can use IPv4 own class
85
+
86
+ ip = IPAddress::IPv4.new "172.16.10.1/24"
87
+
88
+ or, in a easier way, using the IPAddress parse method
89
+
90
+ ip = IPAddress.parse "172.16.10.1/24"
91
+
92
+ which accepts and parses any kind of IP (uint32, IPv4, IPV6 and
93
+ IPv4 IPv6 Mapped addresses).
94
+
95
+ If you like syntactic sugar, you can use the wrapper method
96
+ `IPAddress()`, which is built around `IPAddress::parse`:
97
+
98
+ ip = IPAddress "172.16.10.1/24"
99
+
100
+ You can specify an IPv4 address in any of two ways:
101
+
102
+ IPAddress "172.16.10.1/24"
103
+ IPAddress "172.16.10.1/255.255.255.0"
104
+
105
+ In this example, prefix `/24` and netmask `255.255.255.0` are the same and
106
+ you have the flexibility to use either one of them.
107
+
108
+ If you don't explicitly specify the prefix (or the subnet mask),
109
+ IPAddress thinks you're dealing with host addresses and not with
110
+ networks. Therefore, the default prefix will be `/32`, or
111
+ `255.255.255.255`. For example:
112
+
113
+ # let's declare an host address
114
+ host = IPAddress::IPv4.new "10.1.1.1"
115
+
116
+ puts host.to_string
117
+ #=> "10.1.1.1/32"
118
+
119
+ The new created object has prefix `/32`, which is the same
120
+ as we created the following:
121
+
122
+ host = IPAddress::IPv4.new "10.1.1.1/32"
123
+
124
+ You can also pass a `uint32` to obtain an `IPAddress::IPv4` object:
125
+
126
+ # Create host object
127
+ ip = IPAddress 167837953
128
+ puts ip.to_string
129
+ #=> "10.1.1.1/32"
130
+
131
+ === Handling the IPv4 address
132
+
133
+ Once created, you can obtain the attributes for an IPv4 object:
134
+
135
+ ip = IPAddress("172.16.10.1/24")
136
+
137
+ ip.address
138
+ #=> "172.16.10.1"
139
+ ip.prefix
140
+ #=> 24
141
+
142
+ In case you need to retrieve the netmask in IPv4 format, you can use
143
+ the `IPv4#netmask` method:
144
+
145
+ ip.netmask
146
+ #=> "255.255.255.0"
147
+
148
+ A special attribute, `IPv4#octets`, is available to get the four
149
+ decimal octets from the IP address:
150
+
151
+ ip.octets
152
+ #=> [172,16,10,1]
153
+
154
+ Shortcut method `IPv4#[]`, provides access to a given octet whithin the
155
+ range:
156
+
157
+ ip[1]
158
+ #=> 16
159
+
160
+ If you need to print out the IPv4 address in a canonical form, you can
161
+ use `IPv4#to_string`:
162
+
163
+ ip.to_string
164
+ #=> "172.16.10.l/24"
165
+
166
+ === Changing netmask
167
+
168
+ You can set a new prefix (netmask) after creating an IPv4
169
+ object. For example:
170
+
171
+ ip.prefix = 25
172
+
173
+ ip.to_string
174
+ #=> "172.16.10.l/25"
175
+
176
+ If you need to use a netmask in IPv4 format, you can achive so by
177
+ using the `IPv4#netmask=` method:
178
+
179
+ ip.netmask = "255.255.255.252"
180
+
181
+ ip.to_string
182
+ #=> "172.16.10.1/30"
183
+
184
+ === Working with networks, broadcasts and addresses
185
+
186
+ Some very important topics in dealing with IP addresses are the
187
+ concepts of +network+ and +broadcast+, as well as the addresses
188
+ included in a range.
189
+
190
+ When you specify an IPv4 address such as `172.16.10.1/24`, you are
191
+ actually handling two different information:
192
+
193
+ * The IP address itself, "172.16.10.1"
194
+ * The subnet mask which indicates the network
195
+
196
+ The network number is the IP which has all zeroes in the host
197
+ portion. In our example, because the prefix is 24, we identify our
198
+ network number to have the last 8 (32-24) bits all zeroes. Thus, IP
199
+ address `172.16.10.1/24` belongs to network `172.16.10.0/24`.
200
+
201
+ This is very important because, for instance, IP `172.16.10.1/16` is
202
+ very different to the previous one, belonging to the very different
203
+ network `172.16.0.0/16`.
204
+
205
+ ==== Networks
206
+
207
+ With IPAddress it's very easy to calculate the network for an IP
208
+ address:
209
+
210
+ ip = IPAddress "172.16.10.1/24"
211
+
212
+ net = ip.network
213
+ #=> #<IPAddress::IPv4:0xb7a5ab24 @octets=[172, 16, 10, 0],
214
+ @prefix=24,
215
+ @address="172.16.10.0">
216
+ net.to_string
217
+ #=> "172.16.10.0/24"
218
+
219
+ Method IPv4#network creates a new IPv4 object from the network
220
+ number, calculated after the original object. We want to outline here
221
+ that the network address is a perfect legitimate IPv4 address, which
222
+ just happen to have all zeroes in the host portion.
223
+
224
+ You can use method `IPv4#network?` to check whether an IP address is a
225
+ network or not:
226
+
227
+ ip1 = IPAddress "172.16.10.1/24"
228
+ ip2 = IPAddress "172.16.10.4/30"
229
+
230
+ ip1.network?
231
+ #=> false
232
+ ip2.network?
233
+ #=> true
234
+
235
+ ==== Broadcast
236
+
237
+ The broadcast address is the contrary than the network number: where
238
+ the network number has all zeroes in the host portion, the broadcast
239
+ address has all one's. For example, ip `172.16.10.1/24` has broadcast
240
+ `172.16.10.255/24`, where ip `172.16.10.1/16` has broadcast
241
+ `172.16.255.255/16`.
242
+
243
+ Method `IPv4#broadcast` has the same behavior as is `#network`
244
+ counterpart: it creates a new IPv4 object to handle the broadcast
245
+ address:
246
+
247
+ ip = IPAddress "172.16.10.1/24"
248
+
249
+ bcast = ip.broadcast
250
+ #=> #<IPAddress::IPv4:0xb7a406fc @octets=[172, 16, 10, 255],
251
+ @prefix=24,
252
+ @address="172.16.10.255">
253
+ bcast.to_string
254
+ #=> "172.16.10.255/24"
255
+
256
+ ==== Addresses, ranges and iterators
257
+
258
+ So we see that the netmask essentially specifies a range for IP
259
+ addresses that are included in a network: all the addresses between
260
+ the network number and the broadcast. IPAddress has many methods to
261
+ iterate between those addresses. Let's start with `IPv4#each`, which
262
+ iterates over all addresses in a range
263
+
264
+ ip = IPAddress "172.16.10.1/24"
265
+
266
+ ip.each do |addr|
267
+ puts addr
268
+ end
269
+
270
+ It is important to note that it doesn't matter if the original IP is a
271
+ host IP or a network number (or a broadcast address): the #each method
272
+ only considers the range that the original IP specifies.
273
+
274
+ If you only want to iterate over hosts IP, use the `IPv4#each_host`
275
+ method:
276
+
277
+ ip = IPAddress "172.16.10.1/24"
278
+
279
+ ip.each_host do |host|
280
+ puts host
281
+ end
282
+
283
+ Methods `IPv4#first` and `IPv4#last` return a new object containing
284
+ respectively the first and the last host address in the range
285
+
286
+ ip = IPAddress "172.16.10.100/24"
287
+
288
+ ip.first.to_string
289
+ #=> "172.16.10.1/24"
290
+
291
+ ip.last.to_string
292
+ #=> "172.16.10.254/24"
293
+
294
+ Checking if an address is loopback is easy with the `IPv4#loopback?`
295
+ method:
296
+
297
+ ip = IPAddress "127.0.0.1"
298
+
299
+ ip.loopback?
300
+ #=> true
301
+
302
+ Checking if an address is in the multicast range can be done using the `IPv4#multicast?`
303
+ method:
304
+
305
+ ip = IPAddress "224.0.0.1/32"
306
+
307
+ ip.multicast?
308
+ #=> true
309
+
310
+ The ability to generate a range also exists by using the `IPv4#to()` method. This allows you to create a subnet agnostic range based off a fixed amount.
311
+
312
+ ip = IPAddress "172.16.10.100/24"
313
+ ip.to('172.16.10.110')
314
+ #=> ["172.16.10.100", ..., "172.16.10.110"]
315
+
316
+ === IP special formats
317
+
318
+ The IPAddress library provides a complete set of methods to access an
319
+ IPv4 address in special formats, such as binary, 32 bits unsigned int,
320
+ data and hexadecimal.
321
+
322
+ Let's take the following IPv4 as an example:
323
+
324
+ ip = IPAddress "172.16.10.1/24"
325
+
326
+ ip.address
327
+ #=> "172.16.10.1"
328
+
329
+ The first thing to highlight here is that all these conversion methods
330
+ only take into consideration the address portion of an IPv4 object and
331
+ not the prefix (netmask).
332
+
333
+ So, to express the address in binary format, use the `IPv4#bits` method:
334
+
335
+ ip.bits
336
+ #=> "10101100000100000000101000000001"
337
+
338
+ To calculate the 32 bits unsigned int format of the ip address, use
339
+ the `IPv4#to_u32` method
340
+
341
+ ip.to_u32
342
+ #=> 2886732289
343
+
344
+ This method is the equivalent of the Unix call `pton()`, expressing an
345
+ IP address in the so called +network byte order+ notation. However, if
346
+ you want to transmit your IP over a network socket, you might need to
347
+ transform it in data format using the `IPv4#data` method:
348
+
349
+ ip.data
350
+ #=> "\254\020\n\001"
351
+
352
+ Also, you can transform an IPv4 address into a format which is
353
+ suitable to use in IPv4-IPv6 mapped addresses:
354
+
355
+ ip.to_ipv6
356
+ #=> "ac10:0a01"
357
+
358
+ Finally, much like `IPv4#to_ipv6` you can use to `IPv4#to_h` method to return a non-semicolon delineated string (useful with pcap/byte level usage):
359
+
360
+ ip.to_h
361
+ #=> "ac100a01"
362
+
363
+ === Classful networks
364
+
365
+ IPAddress allows you to create and manipulate objects using the old
366
+ and deprecated (but apparently still popular) classful networks concept.
367
+
368
+ Classful networks and addresses don't have a prefix: their subnet mask
369
+ is univocally identified by their address, and therefore divided in classes.
370
+ As per RFC 791, these classes are:
371
+
372
+ * Class A, from 0.0.0.0 to 127.255.255.255
373
+ * Class B, from 128.0.0.0 to 191.255.255.255
374
+ * Class C, from 192.0.0.0 to 255.255.255.255
375
+
376
+ Since classful networks here are only considered to calculate the default
377
+ prefix number, classes D and E are not considered.
378
+
379
+ To create a classful IP and prefix from an IP address, use the
380
+ IPv4::parse_classful method:
381
+
382
+ # classful ip
383
+ ip = IPAddress::IPv4::parse_classful "10.1.1.1"
384
+
385
+ ip.prefix
386
+ #=> 8
387
+
388
+ The method automatically created a new IPv4 object and assigned it
389
+ the correct prefix.
390
+
391
+ You can easily check which CLASSFUL network an IPv4 object belongs:
392
+
393
+ ip = IPAddress("10.0.0.1/24")
394
+ ip.a?
395
+ #=> true
396
+
397
+ ip = IPAddress("172.16.10.1/24")
398
+ ip.b?
399
+ #=> true
400
+
401
+ ip = IPAddress("192.168.1.1/30")
402
+ ip.c?
403
+ #=> true
404
+
405
+ Remember that these methods are only checking the address portion of an IP, and are
406
+ independent from its prefix, as classful networks have no concept of prefix.
407
+
408
+ For more information on CLASSFUL networks visit the
409
+ {Wikipedia page}[http://en.wikipedia.org/wiki/Classful_network]
410
+
411
+ === Network design with IPAddress
412
+
413
+ IPAddress includes a lot of useful methods to manipulate IPv4 and IPv6
414
+ networks and do some basic network design.
415
+
416
+ ==== Subnetting
417
+
418
+ The process of subnetting is the division of a network into smaller
419
+ (in terms of hosts capacity) networks, called subnets, so that they
420
+ all share a common root, which is the starting network.
421
+
422
+ For example, if you have network "172.16.10.0/24", we can subnet it
423
+ into 4 smaller subnets. The new prefix will be /26, because 4 is 2^2
424
+ and therefore we add 2 bits to the network prefix (24+2=26).
425
+
426
+ Subnetting is easy with IPAddress. You actually have two options:
427
+
428
+ * IPv4#subnet: specify a new prefix
429
+ * IPv4#split: tell IPAddress how many subnets you want to create.
430
+
431
+ Let's examine `IPv4#subnet` first. Say you have network "172.16.10.0/24"
432
+ and you want to subnet it into /26 networks. With IPAddress it's very
433
+ easy:
434
+
435
+ network = IPAddress "172.16.10.0/24"
436
+
437
+ subnets = network.subnet(26)
438
+
439
+ subnets.map{|i| i.to_string}
440
+ #=> ["172.16.10.0/26",
441
+ "172.16.10.64/26",
442
+ "172.16.10.128/26",
443
+ "172.16.10.192/26"]
444
+
445
+ As you can see, an Array has been created, containing 4 new IPv4 objects
446
+ representing the new subnets.
447
+
448
+ Another way to create subnets is to tell IPAddress how many subnets you'd
449
+ like to have, and letting the library calculate the new prefix for you.
450
+
451
+ Let's see how it works, using `IPv4#split` method. Say you want 4 new subnets:
452
+
453
+ network = IPAddress("172.16.10.0/24")
454
+
455
+ subnets = network.split(4)
456
+
457
+ subnets.map{|i| i.to_string}
458
+ #=> ["172.16.10.0/26",
459
+ "172.16.10.64/26",
460
+ "172.16.10.128/26",
461
+ "172.16.10.192/26"]
462
+
463
+ Hey, that's the same result as before! This actually makes sense, as the
464
+ two operations are complementary. When you use `IPv4#subnet` with the new
465
+ prefix, IPAddress will always create a number of subnets that is a power
466
+ of two. This is equivalent to use IPv4#split with a power of 2.
467
+
468
+ Where `IPv4#split` really shines is with the so called "uneven subnetting".
469
+ You are not limited to split a network into a power-of-two numbers of
470
+ subnets: IPAddress lets you create any number of subnets, and it will
471
+ try to organize the new created network in the best possible way, making
472
+ an efficient allocation of the space.
473
+
474
+ An example here is worth a thousand words. Let's use the same network
475
+ as the previous examples:
476
+
477
+ network = IPAddress("172.16.10.0/24")
478
+
479
+ How do we split this network into 3 subnets? Very easy:
480
+
481
+ subnets = network.split(3)
482
+
483
+ subnets.map{|i| i.to_string}
484
+ #=> ["172.16.10.0/26",
485
+ "172.16.10.64/26",
486
+ "172.16.10.128/25"]
487
+
488
+ As you can see, IPAddress tried to perform a good allocation by filling up
489
+ all the address space from the original network. There is no point in splitting
490
+ a network into 3 subnets like `172.16.10.0/26`, `172.16.10.64/26` and
491
+ `172.16.10.128/26`, as you would end up having `172.16.10.192/26` wasted (plus,
492
+ I suppose I wouldn't need a Ruby library to perform un-efficient IP
493
+ allocation, as I do that myself very well ;) ).
494
+
495
+ We can go even further and split into 11 subnets:
496
+
497
+ network.split(11)
498
+ #=> ["172.16.10.0/28", "172.16.10.16/28", "172.16.10.32/28",
499
+ "172.16.10.48/28", "172.16.10.64/28", "172.16.10.80/28",
500
+ "172.16.10.96/28", "172.16.10.112/28", "172.16.10.128/27",
501
+ "172.16.10.160/27", "172.16.10.192/26"]
502
+
503
+ As you can see, most of the networks are `/28`, with a few `/27` and one
504
+ `/26` to fill up the remaining space.
505
+
506
+ ==== Summarization
507
+
508
+ Summarization (or aggregation) is the process when two or more
509
+ networks are taken together to check if a supernet, including
510
+ all and only these networks, exists. If it exists then this supernet
511
+ is called the summarized (or aggregated) network.
512
+ It is very important to understand that summarization can only
513
+ occur if there are no holes in the aggregated network, or, in
514
+ other words, if the given networks fill completely the address space
515
+ of the supernet. So the two rules are:
516
+
517
+ 1) The aggregate network must contain +all+ the IP addresses of the
518
+ original networks;
519
+
520
+ 2) The aggregate network must contain +only+ the IP addresses of the
521
+ original networks;
522
+
523
+ A few examples will help clarify the above. Let's consider for
524
+ instance the following two networks:
525
+
526
+ ip1 = IPAddress("172.16.10.0/24")
527
+ ip2 = IPAddress("172.16.11.0/24")
528
+
529
+ These two networks can be expressed using only one IP address
530
+ network if we change the prefix. Let Ruby do the work:
531
+
532
+ IPAddress::IPv4::summarize(ip1,ip2).map(&:to_string)
533
+ #=> "172.16.10.0/23"
534
+
535
+ We note how the network `172.16.10.0/23` includes all the
536
+ addresses specified in the above networks, and (more important) includes
537
+ ONLY those addresses.
538
+
539
+ If we summarized +ip1+ and +ip2+ with the following network:
540
+
541
+ "172.16.0.0/16"
542
+
543
+ we would have satisfied rule #1 above, but not rule #2. So
544
+
545
+ "172.16.0.0/16"
546
+
547
+ is not an aggregate network for +ip1+ and +ip2+.
548
+
549
+ If it's not possible to compute a single aggregated network for
550
+ all the original networks, the method returns an array with all the
551
+ aggregate networks found. For example, the following four networks can be
552
+ aggregated in a single `/22`:
553
+
554
+ ip1 = IPAddress("10.0.0.1/24")
555
+ ip2 = IPAddress("10.0.1.1/24")
556
+ ip3 = IPAddress("10.0.2.1/24")
557
+ ip4 = IPAddress("10.0.3.1/24")
558
+
559
+ IPAddress::IPv4::summarize(ip1,ip2,ip3,ip4).map{|i| i.to_string}
560
+ #=> ["10.0.0.0/22"]
561
+
562
+ But the following networks can't be summarized in a single
563
+ network:
564
+
565
+ ip1 = IPAddress("10.0.1.1/24")
566
+ ip2 = IPAddress("10.0.2.1/24")
567
+ ip3 = IPAddress("10.0.3.1/24")
568
+ ip4 = IPAddress("10.0.4.1/24")
569
+
570
+ IPAddress::IPv4::summarize(ip1,ip2,ip3,ip4).map{|i| i.to_string}
571
+ #=> ["10.0.1.0/24","10.0.2.0/23","10.0.4.0/24"]
572
+
573
+ In this case, the two summarizables networks have been aggregated into
574
+ a single `/23`, while the other two networks have been left untouched.
575
+
576
+ ==== Supernetting
577
+
578
+ Supernetting is a different operation than aggregation, as it only
579
+ works on a single network and returns a new single IPv4 object,
580
+ representing the supernet.
581
+
582
+ Supernetting is similar to subnetting, except that you getting as a
583
+ result a network with a smaller prefix (bigger host space). For
584
+ example, given the network
585
+
586
+ ip = IPAddress("172.16.10.0/24")
587
+
588
+ you can supernet it with a new /23 prefix
589
+
590
+ ip.supernet(23).to_string
591
+ #=> "172.16.10.0/23"
592
+
593
+ However if you supernet it with a `/22` prefix, the network address will
594
+ change:
595
+
596
+ ip.supernet(22).to_string
597
+ #=> "172.16.8.0/22"
598
+
599
+ This is because `172.16.10.0/22` is not a network anymore, but an host
600
+ address.
601
+
602
+ == IPv6
603
+
604
+ IPAddress is not only fantastic for IPv4 addresses, it's also great to
605
+ handle IPv6 addresses family! Let's discover together how to use it in
606
+ our projects.
607
+
608
+ === IPv6 addresses
609
+
610
+ IPv6 addresses are 128 bits long, in contrast with IPv4 addresses
611
+ which are only 32 bits long. An IPv6 address is generally written as
612
+ eight groups of four hexadecimal digits, each group representing 16
613
+ bits or two octet. For example, the following is a valid IPv6
614
+ address:
615
+
616
+ 2001:0db8:0000:0000:0008:0800:200c:417a
617
+
618
+ Letters in an IPv6 address are usually written downcase, as per
619
+ RFC. You can create a new IPv6 object using uppercase letters, but
620
+ they will be converted.
621
+
622
+ ==== Compression
623
+
624
+ Since IPv6 addresses are very long to write, there are some
625
+ simplifications and compressions that you can use to shorten them.
626
+
627
+ * Leading zeroes: all the leading zeroes within a group can be
628
+ omitted: "0008" would become "8"
629
+
630
+ * A string of consecutive zeroes can be replaced by the string
631
+ "::". This can be only applied once.
632
+
633
+ Using compression, the IPv6 address written above can be shorten into
634
+ the following, equivalent, address
635
+
636
+ 2001:db8::8:800:200c:417a
637
+
638
+ This short version is often used in human representation.
639
+
640
+ ==== Network Mask
641
+
642
+ As we used to do with IPv4 addresses, an IPv6 address can be written
643
+ using the prefix notation to specify the subnet mask:
644
+
645
+ 2001:db8::8:800:200c:417a/64
646
+
647
+ The /64 part means that the first 64 bits of the address are
648
+ representing the network portion, and the last 64 bits are the host
649
+ portion.
650
+
651
+ === Using IPAddress with IPv6 addresses
652
+
653
+ All the IPv6 representations we've just seen are perfectly fine when
654
+ you want to create a new IPv6 address:
655
+
656
+ ip6 = IPAddress "2001:0db8:0000:0000:0008:0800:200C:417A"
657
+
658
+ ip6 = IPAddress "2001:db8:0:0:8:800:200C:417A"
659
+
660
+ ip6 = IPAddress "2001:db8:8:800:200C:417A"
661
+
662
+ All three are giving out the same IPv6 object. The default subnet mask
663
+ for an IPv6 is 128, as IPv6 addresses don't have classes like IPv4
664
+ addresses. If you want a different mask, you can go ahead and explicit
665
+ it:
666
+
667
+ ip6 = IPAddress "2001:db8::8:800:200c:417a/64"
668
+
669
+ Access the address portion and the prefix by using the respective
670
+ methods:
671
+
672
+ ip6 = IPAddress "2001:db8::8:800:200c:417a/64"
673
+
674
+ ip6.address
675
+ #=> "2001:0db8:0000:0000:0008:0800:200c:417a"
676
+
677
+ ip6.prefix
678
+ #=> 64
679
+
680
+ A compressed version of the IPv6 address can be obtained with the
681
+ `IPv6#compressed` method:
682
+
683
+ ip6 = IPAddress "2001:0db8:0000:0000:0008:200c:417a:00ab/64"
684
+
685
+ ip6.compressed
686
+ #=> "2001:db8::8:800:200c:417a"
687
+
688
+ === Handling the IPv6 address
689
+
690
+ Accessing the groups that form an IPv6 address is very easy with the
691
+ `IPv6#groups` method:
692
+
693
+ ip6 = IPAddress "2001:db8::8:800:200c:417a/64"
694
+
695
+ ip6.groups
696
+ #=> [8193, 3512, 0, 0, 8, 2048, 8204, 16762]
697
+
698
+ As with IPv4 addresses, each individual group can be accessed using
699
+ the `IPv6#[]` shortcut method:
700
+
701
+ ip6[0]
702
+ #=> 8193
703
+ ip6[1]
704
+ #=> 3512
705
+ ip6[2]
706
+ #=> 0
707
+ ip6[3]
708
+ #=> 0
709
+
710
+ Note that each 16 bits group is expressed in its decimal form. You can
711
+ also obtain the groups into hexadecimal format using the `IPv6#hexs`
712
+ method:
713
+
714
+ ip6.hexs
715
+ #=> => ["2001", "0db8", "0000", "0000", "0008", "0800", "200c", "417a"]
716
+
717
+ A few other methods are available to transform an IPv6 address into
718
+ decimal representation, with `IPv6.to_i`
719
+
720
+ ip6.to_i
721
+ #=> 42540766411282592856906245548098208122
722
+
723
+ or to hexadecimal representation
724
+
725
+ ip6.to_hex
726
+ #=> "20010db80000000000080800200c417a"
727
+
728
+ To print out an IPv6 address in human readable form, use the `IPv6#to_s`, `IPv6#to_string`
729
+ and `IPv6#to_string_uncompressed` methods
730
+
731
+ ip6 = IPAddress "2001:db8::8:800:200c:417a/64"
732
+
733
+ ip6.to_string
734
+ #=> "2001:db8::8:800:200c:417a/96"
735
+
736
+ ip6.to_string_uncompressed
737
+ #=> "2001:0db8:0000:0000:0008:0800:200c:417a/96"
738
+
739
+ As you can see, `IPv6.to_string` prints out the compressed form, while
740
+ `IPv6.to_string_uncompressed` uses the expanded version.
741
+
742
+ ==== Compressing and uncompressing
743
+
744
+ If you have a string representing an IPv6 address, you can easily
745
+ compress it and uncompress it using the two class methods IPv6::expand
746
+ and IPv6::compress.
747
+
748
+ For example, let's say you have the following uncompressed IPv6
749
+ address:
750
+
751
+ ip6str = "2001:0DB8:0000:CD30:0000:0000:0000:0000"
752
+
753
+ Here is the compressed version:
754
+
755
+ IPAddress::IPv6.compress ip6str
756
+ #=> "2001:db8:0:cd30::"
757
+
758
+ The other way works as well:
759
+
760
+ ip6str = "2001:db8:0:cd30::"
761
+
762
+ IPAddress::IPv6.expand ip6str
763
+ #=> "2001:0DB8:0000:CD30:0000:0000:0000:0000"
764
+
765
+ These methods can be used when you don't want to create a new object
766
+ just for expanding or compressing an address (although a new object is
767
+ actually created internally).
768
+
769
+ === New IPv6 address from other formats
770
+
771
+ You can create a new IPv6 address from different formats than just a
772
+ string representing the colon-hex groups.
773
+
774
+ For instance, if you have a data stream, you can use `IPv6::parse_data`,
775
+ like in the following example:
776
+
777
+ data = " \001\r\270\000\000\000\000\000\b\b\000 \fAz"
778
+
779
+ ip6 = IPAddress::IPv6::parse_data data
780
+ ip6.prefix = 64
781
+
782
+ ip6.to_string
783
+ #=> "2001:db8::8:800:200c:417a/64"
784
+
785
+ A new IPv6 address can also be created from an unsigned 128 bits
786
+ integer:
787
+
788
+ u128 = 42540766411282592856906245548098208122
789
+
790
+ ip6 = IPAddress::IPv6::parse_u128 u128
791
+ ip6.prefix = 64
792
+
793
+ ip6.to_string
794
+ #=>"2001:db8::8:800:200c:417a/64"
795
+
796
+ Finally, a new IPv6 address can be created from an hex string:
797
+
798
+ hex = "20010db80000000000080800200c417a"
799
+
800
+ ip6 = IPAddress::IPv6::parse_hex hex
801
+ ip6.prefix = 64
802
+
803
+ ip6.to_string
804
+ #=> "2001:db8::8:800:200c:417a/64"
805
+
806
+ === Special IPv6 addresses
807
+
808
+ Some IPv6 have a special meaning and are expressed in a special form,
809
+ quite different than an usual IPv6 address. IPAddress has built-in
810
+ support for unspecified, loopback and mapped IPv6 addresses.
811
+
812
+ ==== Unspecified address
813
+
814
+ The address with all zero bits is called the +unspecified+ address
815
+ (corresponding to `0.0.0.0` in IPv4). It should be something like this:
816
+
817
+ 0000:0000:0000:0000:0000:0000:0000:0000
818
+
819
+ but, with the use of compression, it is usually written as just two
820
+ colons:
821
+
822
+ ::
823
+
824
+ or, specifying the netmask:
825
+
826
+ ::/128
827
+
828
+ With IPAddress, create a new unspecified IPv6 address using its own
829
+ subclass:
830
+
831
+ ip = IPAddress::IPv6::Unspecified.new
832
+
833
+ ip.to_string
834
+ #=> "::/128"
835
+
836
+ You can easily check if an IPv6 object is an unspecified address by
837
+ using the IPv6#unspecified? method
838
+
839
+ ip.unspecified?
840
+ #=> true
841
+
842
+ An unspecified IPv6 address can also be created with the wrapper
843
+ method, like we've seen before
844
+
845
+ ip = IPAddress "::"
846
+
847
+ ip.unspecified?
848
+ #=> true
849
+
850
+ This address must never be assigned to an interface and is to be used
851
+ only in software before the application has learned its host's source
852
+ address appropriate for a pending connection. Routers must not forward
853
+ packets with the unspecified address.
854
+
855
+ ==== Loopback address
856
+
857
+ The loopback address is a unicast localhost address. If an
858
+ application in a host sends packets to this address, the IPv6 stack
859
+ will loop these packets back on the same virtual interface.
860
+
861
+ Loopback addresses are expressed in the following form:
862
+
863
+ ::1
864
+
865
+ or, with their appropriate prefix,
866
+
867
+ ::1/128
868
+
869
+ As for the unspecified addresses, IPv6 loopbacks can be created with
870
+ IPAddress calling their own class:
871
+
872
+ ip = IPAddress::IPv6::Loopback.new
873
+
874
+ ip.to_string
875
+ #=> "::1/128"
876
+
877
+ or by using the wrapper:
878
+
879
+ ip = IPAddress "::1"
880
+
881
+ ip.to_string
882
+ #=> "::1/128"
883
+
884
+ Checking if an address is loopback is easy with the `IPv6#loopback?`
885
+ method:
886
+
887
+ ip.loopback?
888
+ #=> true
889
+
890
+ The IPv6 loopback address corresponds to `127.0.0.1` in IPv4.
891
+
892
+ ==== Mapped address
893
+
894
+ It is usually identified as a IPv4 mapped IPv6 address, a particular
895
+ IPv6 address which aids the transition from IPv4 to IPv6. The
896
+ structure of the address is
897
+
898
+ ::ffff:w.y.x.z
899
+
900
+ where `w.x.y.z` is a normal IPv4 address. For example, the following is
901
+ a mapped IPv6 address:
902
+
903
+ ::ffff:192.168.100.1
904
+
905
+ IPAddress is very powerful in handling mapped IPv6 addresses, as the
906
+ IPv4 portion is stored internally as a normal IPv4 object. Let's have
907
+ a look at some examples. To create a new mapped address, just use the
908
+ class builder itself
909
+
910
+ ip6 = IPAddress::IPv6::Mapped.new "::ffff:172.16.10.1/128"
911
+
912
+ or just use the wrapper method
913
+
914
+ ip6 = IPAddress "::ffff:172.16.10.1/128"
915
+
916
+ Let's check it's really a mapped address:
917
+
918
+ ip6.mapped?
919
+ #=> true
920
+
921
+ ip6.to_string
922
+ #=> "::ffff:172.16.10.1/128"
923
+
924
+ Now with the `#ipv4` attribute, we can easily access the IPv4 portion
925
+ of the mapped IPv6 address:
926
+
927
+ ip6.ipv4.address
928
+ #=> "172.16.10.1"
929
+
930
+ Internally, the IPv4 address is stored as two 16 bits
931
+ groups. Therefore all the usual methods for an IPv6 address are
932
+ working perfectly fine:
933
+
934
+ ip6.to_hex
935
+ #=> "00000000000000000000ffffac100a01"
936
+
937
+ ip6.address
938
+ #=> "0000:0000:0000:0000:0000:ffff:ac10:0a01"
939
+
940
+ A mapped IPv6 can also be created just by specify the address in the
941
+ following format:
942
+
943
+ ip6 = IPAddress "::172.16.10.1"
944
+
945
+ That is, two colons and the IPv4 address. However, as by RFC, the `ffff`
946
+ group will be automatically added at the beginning
947
+
948
+ ip6.to_string
949
+ => "::ffff:172.16.10.1/128"
950
+
951
+ making it a mapped IPv6 compatible address.
952
+
953
+ == Why not using IPAddr?
954
+
955
+ IPAddr is the IP addresses library that comes with Ruby standard
956
+ lib. We found this library, although very well written, not very
957
+ suitable for all our needs, and not very flexible.
958
+
959
+ Some quick examples of things you can't do with IPAddr:
960
+
961
+ * store both the address and the prefix information
962
+ * quickly find the broadcast address of a network
963
+ * iterate over hosts
964
+ * perform subnetting or network aggregation
965
+
966
+ Many methods and procedures are so old that they have been
967
+ declared deprecated by the IETF, and some others have bugs in their
968
+ implementation.
969
+
970
+ Moreover, IPAddress is more robust and is already around 50% faster than IPAddr,
971
+ in addition to provide an organic API with logical separation and OO structure.
972
+
973
+ We hope that IPAddress will address all these issues and meet all your
974
+ needs in network programming.
975
+
976
+
977
+ == Community
978
+
979
+ Want to join the community?
980
+
981
+ * {IPAddress google group}[http://groups.google.com/group/ruby-ipaddress]
982
+
983
+ We've created a group to discuss about
984
+ IPAddress future development, features and provide some kind of support.
985
+ Feel free to join us and tell us what you think!
986
+
987
+ == Thanks to
988
+
989
+ Thanks to Luca Russo (vargolo) and Simone Carletti
990
+ (weppos) for all the support and technical review. Thanks to Marco Beri,
991
+ Bryan T. Richardson, Nicolas Fevrier, jdpace, Daniele Alessandri, jrdioko,
992
+ Ghislain Charrier, Pawel Krzesniak, Mark Sullivan, Leif Gensert,
993
+ Erik Ahlström, Peter Vandenberk and Steve Rawlinson for their support,
994
+ feedback and bug reports.
995
+
996
+ == Copyright
997
+
998
+ Copyright (c) 2009-2015 Marco Ceresa and Mike Mackintosh. See LICENSE for details.