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,895 @@
1
+ require 'ipaddress/prefix'
2
+
3
+ module IPAddress;
4
+ #
5
+ # =Name
6
+ #
7
+ # IPAddress::IPv6 - IP version 6 address manipulation library
8
+ #
9
+ # =Synopsis
10
+ #
11
+ # require 'ipaddress'
12
+ #
13
+ # =Description
14
+ #
15
+ # Class IPAddress::IPv6 is used to handle IPv6 type addresses.
16
+ #
17
+ # == IPv6 addresses
18
+ #
19
+ # IPv6 addresses are 128 bits long, in contrast with IPv4 addresses
20
+ # which are only 32 bits long. An IPv6 address is generally written as
21
+ # eight groups of four hexadecimal digits, each group representing 16
22
+ # bits or two octect. For example, the following is a valid IPv6
23
+ # address:
24
+ #
25
+ # 2001:0db8:0000:0000:0008:0800:200c:417a
26
+ #
27
+ # Letters in an IPv6 address are usually written downcase, as per
28
+ # RFC. You can create a new IPv6 object using uppercase letters, but
29
+ # they will be converted.
30
+ #
31
+ # === Compression
32
+ #
33
+ # Since IPv6 addresses are very long to write, there are some
34
+ # semplifications and compressions that you can use to shorten them.
35
+ #
36
+ # * Leading zeroes: all the leading zeroes within a group can be
37
+ # omitted: "0008" would become "8"
38
+ #
39
+ # * A string of consecutive zeroes can be replaced by the string
40
+ # "::". This can be only applied once.
41
+ #
42
+ # Using compression, the IPv6 address written above can be shorten into
43
+ # the following, equivalent, address
44
+ #
45
+ # 2001:db8::8:800:200c:417a
46
+ #
47
+ # This short version is often used in human representation.
48
+ #
49
+ # === Network Mask
50
+ #
51
+ # As we used to do with IPv4 addresses, an IPv6 address can be written
52
+ # using the prefix notation to specify the subnet mask:
53
+ #
54
+ # 2001:db8::8:800:200c:417a/64
55
+ #
56
+ # The /64 part means that the first 64 bits of the address are
57
+ # representing the network portion, and the last 64 bits are the host
58
+ # portion.
59
+ #
60
+ #
61
+ class IPv6
62
+
63
+ include IPAddress
64
+ include Enumerable
65
+ include Comparable
66
+
67
+
68
+ #
69
+ # Format string to pretty print IPv6 addresses
70
+ #
71
+ IN6FORMAT = ("%.4x:"*8).chop
72
+
73
+ #
74
+ # Creates a new IPv6 address object.
75
+ #
76
+ # An IPv6 address can be expressed in any of the following forms:
77
+ #
78
+ # * "2001:0db8:0000:0000:0008:0800:200C:417A": IPv6 address with no compression
79
+ # * "2001:db8:0:0:8:800:200C:417A": IPv6 address with leading zeros compression
80
+ # * "2001:db8::8:800:200C:417A": IPv6 address with full compression
81
+ #
82
+ # In all these 3 cases, a new IPv6 address object will be created, using the default
83
+ # subnet mask /128
84
+ #
85
+ # You can also specify the subnet mask as with IPv4 addresses:
86
+ #
87
+ # ip6 = IPAddress "2001:db8::8:800:200c:417a/64"
88
+ #
89
+ def initialize(str)
90
+ ip, netmask = str.split("/")
91
+
92
+ if str =~ /:.+\./
93
+ raise ArgumentError, "Please use #{self.class}::Mapped for IPv4 mapped addresses"
94
+ end
95
+
96
+ if IPAddress.valid_ipv6?(ip)
97
+ @groups = self.class.groups(ip)
98
+ @address = IN6FORMAT % @groups
99
+ @compressed = compress_address
100
+ else
101
+ raise ArgumentError, "Invalid IP #{ip.inspect}"
102
+ end
103
+
104
+ @prefix = Prefix128.new(netmask ? netmask : 128)
105
+
106
+ end # def initialize
107
+
108
+ #
109
+ # Returns the IPv6 address in uncompressed form:
110
+ #
111
+ # ip6 = IPAddress "2001:db8::8:800:200c:417a/64"
112
+ #
113
+ # ip6.address
114
+ # #=> "2001:0db8:0000:0000:0008:0800:200c:417a"
115
+ #
116
+ def address
117
+ @address
118
+ end
119
+
120
+ #
121
+ # Returns an array with the 16 bits groups in decimal
122
+ # format:
123
+ #
124
+ # ip6 = IPAddress "2001:db8::8:800:200c:417a/64"
125
+ #
126
+ # ip6.groups
127
+ # #=> [8193, 3512, 0, 0, 8, 2048, 8204, 16762]
128
+ #
129
+ def groups
130
+ @groups
131
+ end
132
+
133
+ #
134
+ # Returns an instance of the prefix object
135
+ #
136
+ # ip6 = IPAddress "2001:db8::8:800:200c:417a/64"
137
+ #
138
+ # ip6.prefix
139
+ # #=> 64
140
+ #
141
+ def prefix
142
+ @prefix
143
+ end
144
+
145
+ #
146
+ # Set a new prefix number for the object
147
+ #
148
+ # This is useful if you want to change the prefix
149
+ # to an object created with IPv6::parse_u128 or
150
+ # if the object was created using the default prefix
151
+ # of 128 bits.
152
+ #
153
+ # ip6 = IPAddress("2001:db8::8:800:200c:417a")
154
+ #
155
+ # puts ip6.to_string
156
+ # #=> "2001:db8::8:800:200c:417a/128"
157
+ #
158
+ # ip6.prefix = 64
159
+ # puts ip6.to_string
160
+ # #=> "2001:db8::8:800:200c:417a/64"
161
+ #
162
+ def prefix=(num)
163
+ @prefix = Prefix128.new(num)
164
+ end
165
+
166
+ #
167
+ # Unlike its counterpart IPv6#to_string method, IPv6#to_string_uncompressed
168
+ # returns the whole IPv6 address and prefix in an uncompressed form
169
+ #
170
+ # ip6 = IPAddress "2001:db8::8:800:200c:417a/64"
171
+ #
172
+ # ip6.to_string_uncompressed
173
+ # #=> "2001:0db8:0000:0000:0008:0800:200c:417a/64"
174
+ #
175
+ def to_string_uncompressed
176
+ "#@address/#@prefix"
177
+ end
178
+
179
+ #
180
+ # Returns the IPv6 address in a human readable form,
181
+ # using the compressed address.
182
+ #
183
+ # ip6 = IPAddress "2001:0db8:0000:0000:0008:0800:200c:417a/64"
184
+ #
185
+ # ip6.to_string
186
+ # #=> "2001:db8::8:800:200c:417a/64"
187
+ #
188
+ def to_string
189
+ "#@compressed/#@prefix"
190
+ end
191
+
192
+ #
193
+ # Returns the IPv6 address in a human readable form,
194
+ # using the compressed address.
195
+ #
196
+ # ip6 = IPAddress "2001:db8::8:800:200c:417a/64"
197
+ #
198
+ # ip6.to_s
199
+ # #=> "2001:db8::8:800:200c:417a"
200
+ #
201
+ def to_s
202
+ @compressed
203
+ end
204
+
205
+ #
206
+ # Returns a decimal format (unsigned 128 bit) of the
207
+ # IPv6 address
208
+ #
209
+ # ip6 = IPAddress "2001:db8::8:800:200c:417a/64"
210
+ #
211
+ # ip6.to_i
212
+ # #=> 42540766411282592856906245548098208122
213
+ #
214
+ def to_i
215
+ to_hex.hex
216
+ end
217
+ alias_method :to_u128, :to_i
218
+
219
+ #
220
+ # True if the IPv6 address is a network
221
+ #
222
+ # ip6 = IPAddress "2001:db8::8:800:200c:417a/64"
223
+ #
224
+ # ip6.network?
225
+ # #=> false
226
+ #
227
+ # ip6 = IPAddress "2001:db8:8:800::/64"
228
+ #
229
+ # ip6.network?
230
+ # #=> true
231
+ #
232
+ def network?
233
+ to_u128 | @prefix.to_u128 == @prefix.to_u128
234
+ end
235
+
236
+ #
237
+ # Returns the 16-bits value specified by index
238
+ #
239
+ # ip = IPAddress("2001:db8::8:800:200c:417a/64")
240
+ #
241
+ # ip[0]
242
+ # #=> 8193
243
+ # ip[1]
244
+ # #=> 3512
245
+ # ip[2]
246
+ # #=> 0
247
+ # ip[3]
248
+ # #=> 0
249
+ #
250
+ def [](index)
251
+ @groups[index]
252
+ end
253
+ alias_method :group, :[]
254
+
255
+ #
256
+ # Updated the octet specified at index
257
+ #
258
+ def []=(index, value)
259
+ @groups[index] = value
260
+ initialize("#{IN6FORMAT % @groups}/#{prefix}")
261
+ end
262
+ alias_method :group=, :[]=
263
+
264
+ #
265
+ # Returns a Base16 number representing the IPv6
266
+ # address
267
+ #
268
+ # ip6 = IPAddress "2001:db8::8:800:200c:417a/64"
269
+ #
270
+ # ip6.to_hex
271
+ # #=> "20010db80000000000080800200c417a"
272
+ #
273
+ def to_hex
274
+ hexs.join("")
275
+ end
276
+
277
+ # Returns the address portion of an IPv6 object
278
+ # in a network byte order format.
279
+ #
280
+ # ip6 = IPAddress "2001:db8::8:800:200c:417a/64"
281
+ #
282
+ # ip6.data
283
+ # #=> " \001\r\270\000\000\000\000\000\b\b\000 \fAz"
284
+ #
285
+ # It is usually used to include an IP address
286
+ # in a data packet to be sent over a socket
287
+ #
288
+ # a = Socket.open(params) # socket details here
289
+ # ip6 = IPAddress "2001:db8::8:800:200c:417a/64"
290
+ # binary_data = ["Address: "].pack("a*") + ip.data
291
+ #
292
+ # # Send binary data
293
+ # a.puts binary_data
294
+ #
295
+ def data
296
+ @groups.pack("n8")
297
+ end
298
+
299
+ #
300
+ # Returns an array of the 16 bits groups in hexdecimal
301
+ # format:
302
+ #
303
+ # ip6 = IPAddress "2001:db8::8:800:200c:417a/64"
304
+ #
305
+ # ip6.hexs
306
+ # #=> ["2001", "0db8", "0000", "0000", "0008", "0800", "200c", "417a"]
307
+ #
308
+ # Not to be confused with the similar IPv6#to_hex method.
309
+ #
310
+ def hexs
311
+ @address.split(":")
312
+ end
313
+
314
+ #
315
+ # Returns the IPv6 address in a DNS reverse lookup
316
+ # string, as per RFC3172 and RFC2874.
317
+ #
318
+ # ip6 = IPAddress "3ffe:505:2::f"
319
+ #
320
+ # ip6.reverse
321
+ # #=> "f.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.0.5.0.5.0.e.f.f.3.ip6.arpa"
322
+ #
323
+ def reverse
324
+ to_hex.reverse.gsub(/./){|c| c+"."} + "ip6.arpa"
325
+ end
326
+ alias_method :arpa, :reverse
327
+
328
+ #
329
+ # Returns the network number in Unsigned 128bits format
330
+ #
331
+ # ip6 = IPAddress "2001:db8::8:800:200c:417a/64"
332
+ #
333
+ # ip6.network_u128
334
+ # #=> 42540766411282592856903984951653826560
335
+ #
336
+ def network_u128
337
+ to_u128 & @prefix.to_u128
338
+ end
339
+
340
+ #
341
+ # Returns the broadcast address in Unsigned 128bits format
342
+ #
343
+ # ip6 = IPAddress "2001:db8::8:800:200c:417a/64"
344
+ #
345
+ # ip6.broadcast_u128
346
+ # #=> 42540766411282592875350729025363378175
347
+ #
348
+ # Please note that there is no Broadcast concept in IPv6
349
+ # addresses as in IPv4 addresses, and this method is just
350
+ # an helper to other functions.
351
+ #
352
+ def broadcast_u128
353
+ network_u128 + size - 1
354
+ end
355
+
356
+ #
357
+ # Returns the number of IP addresses included
358
+ # in the network. It also counts the network
359
+ # address and the broadcast address.
360
+ #
361
+ # ip6 = IPAddress("2001:db8::8:800:200c:417a/64")
362
+ #
363
+ # ip6.size
364
+ # #=> 18446744073709551616
365
+ #
366
+ def size
367
+ 2 ** @prefix.host_prefix
368
+ end
369
+
370
+ #
371
+ # Checks whether a subnet includes the given IP address.
372
+ #
373
+ # Example:
374
+ #
375
+ # ip6 = IPAddress "2001:db8::8:800:200c:417a/64"
376
+ # addr = IPAddress "2001:db8::8:800:200c:1/128"
377
+ #
378
+ # ip6.include? addr
379
+ # #=> true
380
+ #
381
+ # ip6.include? IPAddress("2001:db8:1::8:800:200c:417a/76")
382
+ # #=> false
383
+ #
384
+ def include?(oth)
385
+ @prefix <= oth.prefix and network_u128 == self.class.new(oth.address+"/#@prefix").network_u128
386
+ end
387
+
388
+ #
389
+ # Compressed form of the IPv6 address
390
+ #
391
+ # ip6 = IPAddress "2001:db8::8:800:200c:417a/64"
392
+ #
393
+ # ip6.compressed
394
+ # #=> "2001:db8::8:800:200c:417a"
395
+ #
396
+ def compressed
397
+ @compressed
398
+ end
399
+
400
+ #
401
+ # Returns true if the address is an unspecified address
402
+ #
403
+ # See IPAddress::IPv6::Unspecified for more information
404
+ #
405
+ def unspecified?
406
+ @prefix == 128 and @compressed == "::"
407
+ end
408
+
409
+ #
410
+ # Returns true if the address is a loopback address
411
+ #
412
+ # See IPAddress::IPv6::Loopback for more information
413
+ #
414
+ def loopback?
415
+ @prefix == 128 and @compressed == "::1"
416
+ end
417
+
418
+ #
419
+ # Returns true if the address is a mapped address
420
+ #
421
+ # See IPAddress::IPv6::Mapped for more information
422
+ #
423
+ def mapped?
424
+ to_u128 >> 32 == 0xffff
425
+ end
426
+
427
+ #
428
+ # Iterates over all the IP addresses for the given
429
+ # network (or IP address).
430
+ #
431
+ # The object yielded is a new IPv6 object created
432
+ # from the iteration.
433
+ #
434
+ # ip6 = IPAddress("2001:db8::4/125")
435
+ #
436
+ # ip6.each do |i|
437
+ # p i.compressed
438
+ # end
439
+ # #=> "2001:db8::"
440
+ # #=> "2001:db8::1"
441
+ # #=> "2001:db8::2"
442
+ # #=> "2001:db8::3"
443
+ # #=> "2001:db8::4"
444
+ # #=> "2001:db8::5"
445
+ # #=> "2001:db8::6"
446
+ # #=> "2001:db8::7"
447
+ #
448
+ # WARNING: if the host portion is very large, this method
449
+ # can be very slow and possibly hang your system!
450
+ #
451
+ def each
452
+ (network_u128..broadcast_u128).each do |i|
453
+ yield self.class.parse_u128(i, @prefix)
454
+ end
455
+ end
456
+
457
+ #
458
+ # Spaceship operator to compare IPv6 objects
459
+ #
460
+ # Comparing IPv6 addresses is useful to ordinate
461
+ # them into lists that match our intuitive
462
+ # perception of ordered IP addresses.
463
+ #
464
+ # The first comparison criteria is the u128 value.
465
+ # For example, 2001:db8:1::1 will be considered
466
+ # to be less than 2001:db8:2::1, because, in a ordered list,
467
+ # we expect 2001:db8:1::1 to come before 2001:db8:2::1.
468
+ #
469
+ # The second criteria, in case two IPv6 objects
470
+ # have identical addresses, is the prefix. An higher
471
+ # prefix will be considered greater than a lower
472
+ # prefix. This is because we expect to see
473
+ # 2001:db8:1::1/64 come before 2001:db8:1::1/65
474
+ #
475
+ # Example:
476
+ #
477
+ # ip1 = IPAddress "2001:db8:1::1/64"
478
+ # ip2 = IPAddress "2001:db8:2::1/64"
479
+ # ip3 = IPAddress "2001:db8:1::1/65"
480
+ #
481
+ # ip1 < ip2
482
+ # #=> true
483
+ # ip1 < ip3
484
+ # #=> false
485
+ #
486
+ # [ip1,ip2,ip3].sort.map{|i| i.to_string}
487
+ # #=> ["2001:db8:1::1/64","2001:db8:1::1/65","2001:db8:2::1/64"]
488
+ #
489
+ def <=>(oth)
490
+ return prefix <=> oth.prefix if to_u128 == oth.to_u128
491
+ to_u128 <=> oth.to_u128
492
+ end
493
+
494
+ #
495
+ # Returns the address portion of an IP in binary format,
496
+ # as a string containing a sequence of 0 and 1
497
+ #
498
+ # ip6 = IPAddress("2001:db8::8:800:200c:417a")
499
+ #
500
+ # ip6.bits
501
+ # #=> "0010000000000001000011011011100000 [...] "
502
+ #
503
+ def bits
504
+ data.unpack("B*").first
505
+ end
506
+
507
+ #
508
+ # Expands an IPv6 address in the canocical form
509
+ #
510
+ # IPAddress::IPv6.expand "2001:0DB8:0:CD30::"
511
+ # #=> "2001:0DB8:0000:CD30:0000:0000:0000:0000"
512
+ #
513
+ def self.expand(str)
514
+ self.new(str).address
515
+ end
516
+
517
+ #
518
+ # Compress an IPv6 address in its compressed form
519
+ #
520
+ # IPAddress::IPv6.compress "2001:0DB8:0000:CD30:0000:0000:0000:0000"
521
+ # #=> "2001:db8:0:cd30::"
522
+ #
523
+ def self.compress(str)
524
+ self.new(str).compressed
525
+ end
526
+
527
+ #
528
+ # Literal version of the IPv6 address
529
+ #
530
+ # ip6 = IPAddress "2001:db8::8:800:200c:417a/64"
531
+ #
532
+ # ip6.literal
533
+ # #=> "2001-0db8-0000-0000-0008-0800-200c-417a.ipv6-literal.net"
534
+ #
535
+ def literal
536
+ @address.gsub(":","-") + ".ipv6-literal.net"
537
+ end
538
+
539
+ #
540
+ # Returns a new IPv6 object with the network number
541
+ # for the given IP.
542
+ #
543
+ # ip = IPAddress "2001:db8:1:1:1:1:1:1/32"
544
+ #
545
+ # ip.network.to_string
546
+ # #=> "2001:db8::/32"
547
+ #
548
+ def network
549
+ self.class.parse_u128(network_u128, @prefix)
550
+ end
551
+
552
+ #
553
+ # Extract 16 bits groups from a string
554
+ #
555
+ def self.groups(str)
556
+ l, r = if str =~ /^(.*)::(.*)$/
557
+ [$1,$2].map {|i| i.split ":"}
558
+ else
559
+ [str.split(":"),[]]
560
+ end
561
+ (l + Array.new(8-l.size-r.size, '0') + r).map {|i| i.hex}
562
+ end
563
+
564
+ #
565
+ # Creates a new IPv6 object from binary data,
566
+ # like the one you get from a network stream.
567
+ #
568
+ # For example, on a network stream the IP
569
+ #
570
+ # "2001:db8::8:800:200c:417a"
571
+ #
572
+ # is represented with the binary data
573
+ #
574
+ # " \001\r\270\000\000\000\000\000\b\b\000 \fAz"
575
+ #
576
+ # With that data you can create a new IPv6 object:
577
+ #
578
+ # ip6 = IPAddress::IPv6::parse_data " \001\r\270\000\000\000\000\000\b\b\000 \fAz"
579
+ # ip6.prefix = 64
580
+ #
581
+ # ip6.to_s
582
+ # #=> "2001:db8::8:800:200c:417a/64"
583
+ #
584
+ def self.parse_data(str)
585
+ self.new(IN6FORMAT % str.unpack("n8"))
586
+ end
587
+
588
+ #
589
+ # Creates a new IPv6 object from an
590
+ # unsigned 128 bits integer.
591
+ #
592
+ # ip6 = IPAddress::IPv6::parse_u128(42540766411282592856906245548098208122)
593
+ # ip6.prefix = 64
594
+ #
595
+ # ip6.to_string
596
+ # #=> "2001:db8::8:800:200c:417a/64"
597
+ #
598
+ # The +prefix+ parameter is optional:
599
+ #
600
+ # ip6 = IPAddress::IPv6::parse_u128(42540766411282592856906245548098208122, 64)
601
+ #
602
+ # ip6.to_string
603
+ # #=> "2001:db8::8:800:200c:417a/64"
604
+ #
605
+ def self.parse_u128(u128, prefix=128)
606
+ str = IN6FORMAT % (0..7).map{|i| (u128>>(112-16*i))&0xffff}
607
+ self.new(str + "/#{prefix}")
608
+ end
609
+
610
+ #
611
+ # Creates a new IPv6 object from a number expressed in
612
+ # hexdecimal format:
613
+ #
614
+ # ip6 = IPAddress::IPv6::parse_hex("20010db80000000000080800200c417a")
615
+ # ip6.prefix = 64
616
+ #
617
+ # ip6.to_string
618
+ # #=> "2001:db8::8:800:200c:417a/64"
619
+ #
620
+ # The +prefix+ parameter is optional:
621
+ #
622
+ # ip6 = IPAddress::IPv6::parse_hex("20010db80000000000080800200c417a", 64)
623
+ #
624
+ # ip6.to_string
625
+ # #=> "2001:db8::8:800:200c:417a/64"
626
+ #
627
+ def self.parse_hex(hex, prefix=128)
628
+ self.parse_u128(hex.hex, prefix)
629
+ end
630
+
631
+ private
632
+
633
+ def compress_address
634
+ str = @groups.map{|i| i.to_s 16}.join ":"
635
+ loop do
636
+ break if str.sub!(/\A0:0:0:0:0:0:0:0\Z/, '::')
637
+ break if str.sub!(/\b0:0:0:0:0:0:0\b/, ':')
638
+ break if str.sub!(/\b0:0:0:0:0:0\b/, ':')
639
+ break if str.sub!(/\b0:0:0:0:0\b/, ':')
640
+ break if str.sub!(/\b0:0:0:0\b/, ':')
641
+ break if str.sub!(/\b0:0:0\b/, ':')
642
+ break if str.sub!(/\b0:0\b/, ':')
643
+ break
644
+ end
645
+ str.sub(/:{3,}/, '::')
646
+ end
647
+
648
+ end # class IPv6
649
+
650
+ #
651
+ # The address with all zero bits is called the +unspecified+ address
652
+ # (corresponding to 0.0.0.0 in IPv4). It should be something like this:
653
+ #
654
+ # 0000:0000:0000:0000:0000:0000:0000:0000
655
+ #
656
+ # but, with the use of compression, it is usually written as just two
657
+ # colons:
658
+ #
659
+ # ::
660
+ #
661
+ # or, specifying the netmask:
662
+ #
663
+ # ::/128
664
+ #
665
+ # With IPAddress, create a new unspecified IPv6 address using its own
666
+ # subclass:
667
+ #
668
+ # ip = IPAddress::IPv6::Unspecified.new
669
+ #
670
+ # ip.to_s
671
+ # #=> => "::/128"
672
+ #
673
+ # You can easily check if an IPv6 object is an unspecified address by
674
+ # using the IPv6#unspecified? method
675
+ #
676
+ # ip.unspecified?
677
+ # #=> true
678
+ #
679
+ # An unspecified IPv6 address can also be created with the wrapper
680
+ # method, like we've seen before
681
+ #
682
+ # ip = IPAddress "::"
683
+ #
684
+ # ip.unspecified?
685
+ # #=> true
686
+ #
687
+ # This address must never be assigned to an interface and is to be used
688
+ # only in software before the application has learned its host's source
689
+ # address appropriate for a pending connection. Routers must not forward
690
+ # packets with the unspecified address.
691
+ #
692
+ class IPAddress::IPv6::Unspecified < IPAddress::IPv6
693
+ #
694
+ # Creates a new IPv6 unspecified address
695
+ #
696
+ # ip = IPAddress::IPv6::Unspecified.new
697
+ #
698
+ # ip.to_s
699
+ # #=> => "::/128"
700
+ #
701
+ def initialize
702
+ @address = ("0000:"*8).chop
703
+ @groups = Array.new(8,0)
704
+ @prefix = Prefix128.new(128)
705
+ @compressed = compress_address
706
+ end
707
+ end # class IPv6::Unspecified
708
+
709
+ #
710
+ # The loopback address is a unicast localhost address. If an
711
+ # application in a host sends packets to this address, the IPv6 stack
712
+ # will loop these packets back on the same virtual interface.
713
+ #
714
+ # Loopback addresses are expressed in the following form:
715
+ #
716
+ # ::1
717
+ #
718
+ # or, with their appropriate prefix,
719
+ #
720
+ # ::1/128
721
+ #
722
+ # As for the unspecified addresses, IPv6 loopbacks can be created with
723
+ # IPAddress calling their own class:
724
+ #
725
+ # ip = IPAddress::IPv6::Loopback.new
726
+ #
727
+ # ip.to_string
728
+ # #=> "::1/128"
729
+ #
730
+ # or by using the wrapper:
731
+ #
732
+ # ip = IPAddress "::1"
733
+ #
734
+ # ip.to_string
735
+ # #=> "::1/128"
736
+ #
737
+ # Checking if an address is loopback is easy with the IPv6#loopback?
738
+ # method:
739
+ #
740
+ # ip.loopback?
741
+ # #=> true
742
+ #
743
+ # The IPv6 loopback address corresponds to 127.0.0.1 in IPv4.
744
+ #
745
+ class IPAddress::IPv6::Loopback < IPAddress::IPv6
746
+ #
747
+ # Creates a new IPv6 unspecified address
748
+ #
749
+ # ip = IPAddress::IPv6::Loopback.new
750
+ #
751
+ # ip.to_string
752
+ # #=> "::1/128"
753
+ #
754
+ def initialize
755
+ @address = ("0000:"*7)+"0001"
756
+ @groups = Array.new(7,0).push(1)
757
+ @prefix = Prefix128.new(128)
758
+ @compressed = compress_address
759
+ end
760
+ end # class IPv6::Loopback
761
+
762
+ #
763
+ # It is usually identified as a IPv4 mapped IPv6 address, a particular
764
+ # IPv6 address which aids the transition from IPv4 to IPv6. The
765
+ # structure of the address is
766
+ #
767
+ # ::ffff:w.y.x.z
768
+ #
769
+ # where w.x.y.z is a normal IPv4 address. For example, the following is
770
+ # a mapped IPv6 address:
771
+ #
772
+ # ::ffff:192.168.100.1
773
+ #
774
+ # IPAddress is very powerful in handling mapped IPv6 addresses, as the
775
+ # IPv4 portion is stored internally as a normal IPv4 object. Let's have
776
+ # a look at some examples. To create a new mapped address, just use the
777
+ # class builder itself
778
+ #
779
+ # ip6 = IPAddress::IPv6::Mapped.new "::ffff:172.16.10.1/128"
780
+ #
781
+ # or just use the wrapper method
782
+ #
783
+ # ip6 = IPAddress "::ffff:172.16.10.1/128"
784
+ #
785
+ # Let's check it's really a mapped address:
786
+ #
787
+ # ip6.mapped?
788
+ # #=> true
789
+ #
790
+ # ip6.to_string
791
+ # #=> "::FFFF:172.16.10.1/128"
792
+ #
793
+ # Now with the +ipv4+ attribute, we can easily access the IPv4 portion
794
+ # of the mapped IPv6 address:
795
+ #
796
+ # ip6.ipv4.address
797
+ # #=> "172.16.10.1"
798
+ #
799
+ # Internally, the IPv4 address is stored as two 16 bits
800
+ # groups. Therefore all the usual methods for an IPv6 address are
801
+ # working perfectly fine:
802
+ #
803
+ # ip6.to_hex
804
+ # #=> "00000000000000000000ffffac100a01"
805
+ #
806
+ # ip6.address
807
+ # #=> "0000:0000:0000:0000:0000:ffff:ac10:0a01"
808
+ #
809
+ # A mapped IPv6 can also be created just by specify the address in the
810
+ # following format:
811
+ #
812
+ # ip6 = IPAddress "::172.16.10.1"
813
+ #
814
+ # That is, two colons and the IPv4 address. However, as by RFC, the ffff
815
+ # group will be automatically added at the beginning
816
+ #
817
+ # ip6.to_string
818
+ # => "::ffff:172.16.10.1/128"
819
+ #
820
+ # making it a mapped IPv6 compatible address.
821
+ #
822
+ class IPAddress::IPv6::Mapped < IPAddress::IPv6
823
+
824
+ # Access the internal IPv4 address
825
+ attr_reader :ipv4
826
+
827
+ #
828
+ # Creates a new IPv6 IPv4-mapped address
829
+ #
830
+ # ip6 = IPAddress::IPv6::Mapped.new "::ffff:172.16.10.1/128"
831
+ #
832
+ # ipv6.ipv4.class
833
+ # #=> IPAddress::IPv4
834
+ #
835
+ # An IPv6 IPv4-mapped address can also be created using the
836
+ # IPv6 only format of the address:
837
+ #
838
+ # ip6 = IPAddress::IPv6::Mapped.new "::0d01:4403"
839
+ #
840
+ # ip6.to_string
841
+ # #=> "::ffff:13.1.68.3"
842
+ #
843
+ def initialize(str)
844
+ string, netmask = str.split("/")
845
+ if string =~ /\./ # IPv4 in dotted decimal form
846
+ @ipv4 = IPAddress::IPv4.extract(string)
847
+ else # IPv4 in hex form
848
+ groups = IPAddress::IPv6.groups(string)
849
+ @ipv4 = IPAddress::IPv4.parse_u32((groups[-2]<< 16)+groups[-1])
850
+ end
851
+ super("::ffff:#{@ipv4.to_ipv6}/#{netmask}")
852
+ end
853
+
854
+ #
855
+ # Similar to IPv6#to_s, but prints out the IPv4 address
856
+ # in dotted decimal format
857
+ #
858
+ # ip6 = IPAddress "::ffff:172.16.10.1/128"
859
+ #
860
+ # ip6.to_s
861
+ # #=> "::ffff:172.16.10.1"
862
+ #
863
+ def to_s
864
+ "::ffff:#{@ipv4.address}"
865
+ end
866
+
867
+ #
868
+ # Similar to IPv6#to_string, but prints out the IPv4 address
869
+ # in dotted decimal format
870
+ #
871
+ #
872
+ # ip6 = IPAddress "::ffff:172.16.10.1/128"
873
+ #
874
+ # ip6.to_string
875
+ # #=> "::ffff:172.16.10.1/128"
876
+ #
877
+ def to_string
878
+ "::ffff:#{@ipv4.address}/#@prefix"
879
+ end
880
+
881
+ #
882
+ # Checks if the IPv6 address is IPv4 mapped
883
+ #
884
+ # ip6 = IPAddress "::ffff:172.16.10.1/128"
885
+ #
886
+ # ip6.mapped?
887
+ # #=> true
888
+ #
889
+ def mapped?
890
+ true
891
+ end
892
+ end # class IPv6::Mapped
893
+
894
+ end # module IPAddress
895
+