ory-client 0.0.1.alpha30 → 0.0.1.alpha38

Sign up to get free protection for your applications and to get access to all the features.
Files changed (505) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +6 -4
  3. data/README.md +10 -12
  4. data/docs/CreateSubscriptionPayload.md +22 -0
  5. data/docs/NullPlan.md +15 -0
  6. data/docs/Project.md +1 -3
  7. data/docs/ProjectRevision.md +1 -1
  8. data/docs/Subscription.md +36 -0
  9. data/docs/UpdateSubscriptionPayload.md +20 -0
  10. data/docs/V0alpha0Api.md +8 -16
  11. data/docs/V0alpha2Api.md +14 -28
  12. data/lib/ory-client/api/metadata_api.rb +1 -1
  13. data/lib/ory-client/api/v0alpha0_api.rb +1 -1
  14. data/lib/ory-client/api/v0alpha2_api.rb +1 -1
  15. data/lib/ory-client/api_client.rb +1 -1
  16. data/lib/ory-client/api_error.rb +1 -1
  17. data/lib/ory-client/configuration.rb +3 -3
  18. data/lib/ory-client/models/active_project.rb +1 -1
  19. data/lib/ory-client/models/admin_create_identity_body.rb +1 -1
  20. data/lib/ory-client/models/admin_create_self_service_recovery_link_body.rb +1 -1
  21. data/lib/ory-client/models/admin_update_identity_body.rb +1 -1
  22. data/lib/ory-client/models/api_token.rb +1 -1
  23. data/lib/ory-client/models/authenticator_assurance_level.rb +1 -1
  24. data/lib/ory-client/models/cname_settings.rb +1 -1
  25. data/lib/ory-client/models/create_custom_hostname_body.rb +1 -1
  26. data/lib/ory-client/models/{null_string.rb → create_subscription_payload.rb} +36 -18
  27. data/lib/ory-client/models/error_authenticator_assurance_level_not_satisfied.rb +1 -1
  28. data/lib/ory-client/models/generic_error.rb +1 -1
  29. data/lib/ory-client/models/health_not_ready_status.rb +1 -1
  30. data/lib/ory-client/models/health_status.rb +1 -1
  31. data/lib/ory-client/models/identity.rb +1 -1
  32. data/lib/ory-client/models/identity_credentials.rb +1 -1
  33. data/lib/ory-client/models/identity_credentials_type.rb +1 -1
  34. data/lib/ory-client/models/identity_preset.rb +1 -1
  35. data/lib/ory-client/models/identity_schema.rb +1 -1
  36. data/lib/ory-client/models/identity_schema_location.rb +1 -1
  37. data/lib/ory-client/models/identity_schema_validation_result.rb +1 -1
  38. data/lib/ory-client/models/identity_state.rb +1 -1
  39. data/lib/ory-client/models/inline_response200.rb +1 -1
  40. data/lib/ory-client/models/inline_response2001.rb +1 -1
  41. data/lib/ory-client/models/inline_response503.rb +1 -1
  42. data/lib/ory-client/models/is_owner_for_project_by_slug.rb +1 -1
  43. data/lib/ory-client/models/is_owner_for_project_by_slug_payload.rb +1 -1
  44. data/lib/ory-client/models/json_error.rb +1 -1
  45. data/lib/ory-client/models/needs_privileged_session_error.rb +1 -1
  46. data/lib/ory-client/models/null_plan.rb +40 -0
  47. data/lib/ory-client/models/project.rb +3 -12
  48. data/lib/ory-client/models/project_host.rb +1 -1
  49. data/lib/ory-client/models/project_lookup_secret_config.rb +1 -1
  50. data/lib/ory-client/models/project_oidc_config.rb +1 -1
  51. data/lib/ory-client/models/project_password_config.rb +1 -1
  52. data/lib/ory-client/models/project_patch.rb +1 -1
  53. data/lib/ory-client/models/project_recovery_config.rb +1 -1
  54. data/lib/ory-client/models/project_revision.rb +2 -2
  55. data/lib/ory-client/models/project_slug.rb +1 -1
  56. data/lib/ory-client/models/project_totp_config.rb +1 -1
  57. data/lib/ory-client/models/project_verification_config.rb +1 -1
  58. data/lib/ory-client/models/project_web_authn_config.rb +1 -1
  59. data/lib/ory-client/models/recovery_address.rb +1 -1
  60. data/lib/ory-client/models/redirection_config.rb +1 -1
  61. data/lib/ory-client/models/redirection_field.rb +1 -1
  62. data/lib/ory-client/models/schema_patch.rb +1 -1
  63. data/lib/ory-client/models/self_service_browser_location_change_required_error.rb +1 -1
  64. data/lib/ory-client/models/self_service_error.rb +1 -1
  65. data/lib/ory-client/models/self_service_flow_expired_error.rb +1 -1
  66. data/lib/ory-client/models/self_service_login_flow.rb +1 -1
  67. data/lib/ory-client/models/self_service_logout_url.rb +1 -1
  68. data/lib/ory-client/models/self_service_recovery_flow.rb +1 -1
  69. data/lib/ory-client/models/self_service_recovery_flow_state.rb +1 -1
  70. data/lib/ory-client/models/self_service_recovery_link.rb +1 -1
  71. data/lib/ory-client/models/self_service_registration_flow.rb +1 -1
  72. data/lib/ory-client/models/self_service_settings_flow.rb +1 -1
  73. data/lib/ory-client/models/self_service_settings_flow_state.rb +1 -1
  74. data/lib/ory-client/models/self_service_verification_flow.rb +1 -1
  75. data/lib/ory-client/models/self_service_verification_flow_state.rb +1 -1
  76. data/lib/ory-client/models/session.rb +1 -1
  77. data/lib/ory-client/models/session_authentication_method.rb +1 -1
  78. data/lib/ory-client/models/session_device.rb +1 -1
  79. data/lib/ory-client/models/settings_profile_form_config.rb +1 -1
  80. data/lib/ory-client/models/stripe_customer_response.rb +1 -1
  81. data/lib/ory-client/models/submit_self_service_login_flow_body.rb +1 -1
  82. data/lib/ory-client/models/submit_self_service_login_flow_with_lookup_secret_method_body.rb +1 -1
  83. data/lib/ory-client/models/submit_self_service_login_flow_with_oidc_method_body.rb +1 -1
  84. data/lib/ory-client/models/submit_self_service_login_flow_with_password_method_body.rb +1 -1
  85. data/lib/ory-client/models/submit_self_service_login_flow_with_totp_method_body.rb +1 -1
  86. data/lib/ory-client/models/submit_self_service_login_flow_with_web_authn_method_body.rb +1 -1
  87. data/lib/ory-client/models/submit_self_service_logout_flow_without_browser_body.rb +1 -1
  88. data/lib/ory-client/models/submit_self_service_recovery_flow_body.rb +1 -1
  89. data/lib/ory-client/models/submit_self_service_recovery_flow_with_link_method_body.rb +1 -1
  90. data/lib/ory-client/models/submit_self_service_registration_flow_body.rb +1 -1
  91. data/lib/ory-client/models/submit_self_service_registration_flow_with_oidc_method_body.rb +1 -1
  92. data/lib/ory-client/models/submit_self_service_registration_flow_with_password_method_body.rb +1 -1
  93. data/lib/ory-client/models/submit_self_service_settings_flow_body.rb +1 -1
  94. data/lib/ory-client/models/submit_self_service_settings_flow_with_lookup_method_body.rb +1 -1
  95. data/lib/ory-client/models/submit_self_service_settings_flow_with_oidc_method_body.rb +1 -1
  96. data/lib/ory-client/models/submit_self_service_settings_flow_with_password_method_body.rb +1 -1
  97. data/lib/ory-client/models/submit_self_service_settings_flow_with_profile_method_body.rb +1 -1
  98. data/lib/ory-client/models/submit_self_service_settings_flow_with_totp_method_body.rb +1 -1
  99. data/lib/ory-client/models/submit_self_service_settings_flow_with_web_authn_method_body.rb +1 -1
  100. data/lib/ory-client/models/submit_self_service_verification_flow_body.rb +1 -1
  101. data/lib/ory-client/models/submit_self_service_verification_flow_with_link_method_body.rb +1 -1
  102. data/lib/ory-client/models/{provision_project_payload.rb → subscription.rb} +167 -15
  103. data/lib/ory-client/models/successful_self_service_login_without_browser.rb +1 -1
  104. data/lib/ory-client/models/successful_self_service_registration_without_browser.rb +1 -1
  105. data/lib/ory-client/models/ui_container.rb +1 -1
  106. data/lib/ory-client/models/ui_node.rb +1 -1
  107. data/lib/ory-client/models/ui_node_anchor_attributes.rb +1 -1
  108. data/lib/ory-client/models/ui_node_attributes.rb +1 -1
  109. data/lib/ory-client/models/ui_node_image_attributes.rb +1 -1
  110. data/lib/ory-client/models/ui_node_input_attributes.rb +1 -1
  111. data/lib/ory-client/models/ui_node_meta.rb +1 -1
  112. data/lib/ory-client/models/ui_node_script_attributes.rb +1 -1
  113. data/lib/ory-client/models/ui_node_text_attributes.rb +1 -1
  114. data/lib/ory-client/models/ui_text.rb +1 -1
  115. data/lib/ory-client/models/update_custom_hostname_body.rb +1 -1
  116. data/lib/ory-client/models/{null_uuid.rb → update_subscription_payload.rb} +22 -18
  117. data/lib/ory-client/models/verifiable_identity_address.rb +1 -1
  118. data/lib/ory-client/models/version.rb +1 -1
  119. data/lib/ory-client/version.rb +2 -2
  120. data/lib/ory-client.rb +5 -4
  121. data/ory-client.gemspec +1 -1
  122. data/spec/api/metadata_api_spec.rb +1 -1
  123. data/spec/api/v0alpha0_api_spec.rb +1 -1
  124. data/spec/api/v0alpha2_api_spec.rb +1 -1
  125. data/spec/api_client_spec.rb +1 -1
  126. data/spec/configuration_spec.rb +1 -1
  127. data/spec/models/active_project_spec.rb +1 -1
  128. data/spec/models/admin_create_identity_body_spec.rb +1 -1
  129. data/spec/models/admin_create_self_service_recovery_link_body_spec.rb +1 -1
  130. data/spec/models/admin_update_identity_body_spec.rb +1 -1
  131. data/spec/models/api_token_spec.rb +1 -1
  132. data/spec/models/authenticator_assurance_level_spec.rb +1 -1
  133. data/spec/models/cname_settings_spec.rb +1 -1
  134. data/spec/models/create_custom_hostname_body_spec.rb +1 -1
  135. data/spec/models/{null_uuid_spec.rb → create_subscription_payload_spec.rb} +15 -9
  136. data/spec/models/error_authenticator_assurance_level_not_satisfied_spec.rb +1 -1
  137. data/spec/models/generic_error_spec.rb +1 -1
  138. data/spec/models/health_not_ready_status_spec.rb +1 -1
  139. data/spec/models/health_status_spec.rb +1 -1
  140. data/spec/models/identity_credentials_spec.rb +1 -1
  141. data/spec/models/identity_credentials_type_spec.rb +1 -1
  142. data/spec/models/identity_preset_spec.rb +1 -1
  143. data/spec/models/identity_schema_location_spec.rb +1 -1
  144. data/spec/models/identity_schema_spec.rb +1 -1
  145. data/spec/models/identity_schema_validation_result_spec.rb +1 -1
  146. data/spec/models/identity_spec.rb +1 -1
  147. data/spec/models/identity_state_spec.rb +1 -1
  148. data/spec/models/inline_response2001_spec.rb +1 -1
  149. data/spec/models/inline_response200_spec.rb +1 -1
  150. data/spec/models/inline_response503_spec.rb +1 -1
  151. data/spec/models/is_owner_for_project_by_slug_payload_spec.rb +1 -1
  152. data/spec/models/is_owner_for_project_by_slug_spec.rb +1 -1
  153. data/spec/models/json_error_spec.rb +1 -1
  154. data/spec/models/needs_privileged_session_error_spec.rb +1 -1
  155. data/spec/models/null_plan_spec.rb +28 -0
  156. data/spec/models/project_host_spec.rb +1 -1
  157. data/spec/models/project_lookup_secret_config_spec.rb +1 -1
  158. data/spec/models/project_oidc_config_spec.rb +1 -1
  159. data/spec/models/project_password_config_spec.rb +1 -1
  160. data/spec/models/project_patch_spec.rb +1 -1
  161. data/spec/models/project_recovery_config_spec.rb +1 -1
  162. data/spec/models/project_revision_spec.rb +1 -1
  163. data/spec/models/project_slug_spec.rb +1 -1
  164. data/spec/models/project_spec.rb +1 -7
  165. data/spec/models/project_totp_config_spec.rb +1 -1
  166. data/spec/models/project_verification_config_spec.rb +1 -1
  167. data/spec/models/project_web_authn_config_spec.rb +1 -1
  168. data/spec/models/recovery_address_spec.rb +1 -1
  169. data/spec/models/redirection_config_spec.rb +1 -1
  170. data/spec/models/redirection_field_spec.rb +1 -1
  171. data/spec/models/schema_patch_spec.rb +1 -1
  172. data/spec/models/self_service_browser_location_change_required_error_spec.rb +1 -1
  173. data/spec/models/self_service_error_spec.rb +1 -1
  174. data/spec/models/self_service_flow_expired_error_spec.rb +1 -1
  175. data/spec/models/self_service_login_flow_spec.rb +1 -1
  176. data/spec/models/self_service_logout_url_spec.rb +1 -1
  177. data/spec/models/self_service_recovery_flow_spec.rb +1 -1
  178. data/spec/models/self_service_recovery_flow_state_spec.rb +1 -1
  179. data/spec/models/self_service_recovery_link_spec.rb +1 -1
  180. data/spec/models/self_service_registration_flow_spec.rb +1 -1
  181. data/spec/models/self_service_settings_flow_spec.rb +1 -1
  182. data/spec/models/self_service_settings_flow_state_spec.rb +1 -1
  183. data/spec/models/self_service_verification_flow_spec.rb +1 -1
  184. data/spec/models/self_service_verification_flow_state_spec.rb +1 -1
  185. data/spec/models/session_authentication_method_spec.rb +1 -1
  186. data/spec/models/session_device_spec.rb +1 -1
  187. data/spec/models/session_spec.rb +1 -1
  188. data/spec/models/settings_profile_form_config_spec.rb +1 -1
  189. data/spec/models/stripe_customer_response_spec.rb +1 -1
  190. data/spec/models/submit_self_service_login_flow_body_spec.rb +1 -1
  191. data/spec/models/submit_self_service_login_flow_with_lookup_secret_method_body_spec.rb +1 -1
  192. data/spec/models/submit_self_service_login_flow_with_oidc_method_body_spec.rb +1 -1
  193. data/spec/models/submit_self_service_login_flow_with_password_method_body_spec.rb +1 -1
  194. data/spec/models/submit_self_service_login_flow_with_totp_method_body_spec.rb +1 -1
  195. data/spec/models/submit_self_service_login_flow_with_web_authn_method_body_spec.rb +1 -1
  196. data/spec/models/submit_self_service_logout_flow_without_browser_body_spec.rb +1 -1
  197. data/spec/models/submit_self_service_recovery_flow_body_spec.rb +1 -1
  198. data/spec/models/submit_self_service_recovery_flow_with_link_method_body_spec.rb +1 -1
  199. data/spec/models/submit_self_service_registration_flow_body_spec.rb +1 -1
  200. data/spec/models/submit_self_service_registration_flow_with_oidc_method_body_spec.rb +1 -1
  201. data/spec/models/submit_self_service_registration_flow_with_password_method_body_spec.rb +1 -1
  202. data/spec/models/submit_self_service_settings_flow_body_spec.rb +1 -1
  203. data/spec/models/submit_self_service_settings_flow_with_lookup_method_body_spec.rb +1 -1
  204. data/spec/models/submit_self_service_settings_flow_with_oidc_method_body_spec.rb +1 -1
  205. data/spec/models/submit_self_service_settings_flow_with_password_method_body_spec.rb +1 -1
  206. data/spec/models/submit_self_service_settings_flow_with_profile_method_body_spec.rb +1 -1
  207. data/spec/models/submit_self_service_settings_flow_with_totp_method_body_spec.rb +1 -1
  208. data/spec/models/submit_self_service_settings_flow_with_web_authn_method_body_spec.rb +1 -1
  209. data/spec/models/submit_self_service_verification_flow_body_spec.rb +1 -1
  210. data/spec/models/submit_self_service_verification_flow_with_link_method_body_spec.rb +1 -1
  211. data/spec/models/subscription_spec.rb +92 -0
  212. data/spec/models/successful_self_service_login_without_browser_spec.rb +1 -1
  213. data/spec/models/successful_self_service_registration_without_browser_spec.rb +1 -1
  214. data/spec/models/ui_container_spec.rb +1 -1
  215. data/spec/models/ui_node_anchor_attributes_spec.rb +1 -1
  216. data/spec/models/ui_node_attributes_spec.rb +1 -1
  217. data/spec/models/ui_node_image_attributes_spec.rb +1 -1
  218. data/spec/models/ui_node_input_attributes_spec.rb +1 -1
  219. data/spec/models/ui_node_meta_spec.rb +1 -1
  220. data/spec/models/ui_node_script_attributes_spec.rb +1 -1
  221. data/spec/models/ui_node_spec.rb +1 -1
  222. data/spec/models/ui_node_text_attributes_spec.rb +1 -1
  223. data/spec/models/ui_text_spec.rb +1 -1
  224. data/spec/models/update_custom_hostname_body_spec.rb +1 -1
  225. data/spec/models/{null_string_spec.rb → update_subscription_payload_spec.rb} +9 -9
  226. data/spec/models/verifiable_identity_address_spec.rb +1 -1
  227. data/spec/models/version_spec.rb +1 -1
  228. data/spec/spec_helper.rb +1 -1
  229. data/vendor/bundle/ruby/2.5.0/cache/diff-lcs-1.5.0.gem +0 -0
  230. data/vendor/bundle/ruby/2.5.0/cache/parser-3.1.0.0.gem +0 -0
  231. data/vendor/bundle/ruby/2.5.0/cache/psych-4.0.3.gem +0 -0
  232. data/vendor/bundle/ruby/2.5.0/cache/stringio-3.0.1.gem +0 -0
  233. data/vendor/bundle/ruby/2.5.0/extensions/x86_64-linux/2.5.0/byebug-11.1.3/gem_make.out +2 -2
  234. data/vendor/bundle/ruby/2.5.0/extensions/x86_64-linux/2.5.0/ffi-1.15.4/gem_make.out +2 -2
  235. data/vendor/bundle/ruby/2.5.0/extensions/x86_64-linux/2.5.0/jaro_winkler-1.5.4/gem_make.out +2 -2
  236. data/vendor/bundle/ruby/2.5.0/extensions/x86_64-linux/2.5.0/{psych-4.0.2 → psych-4.0.3}/gem.build_complete +0 -0
  237. data/vendor/bundle/ruby/2.5.0/extensions/x86_64-linux/2.5.0/{psych-4.0.2 → psych-4.0.3}/gem_make.out +6 -6
  238. data/vendor/bundle/ruby/2.5.0/extensions/x86_64-linux/2.5.0/{psych-4.0.2 → psych-4.0.3}/mkmf.log +0 -0
  239. data/vendor/bundle/ruby/2.5.0/extensions/x86_64-linux/2.5.0/{psych-4.0.2 → psych-4.0.3}/psych.so +0 -0
  240. data/vendor/bundle/ruby/2.5.0/{gems/psych-4.0.2/ext/psych/.sitearchdir.time → extensions/x86_64-linux/2.5.0/stringio-3.0.1/gem.build_complete} +0 -0
  241. data/vendor/bundle/ruby/2.5.0/extensions/x86_64-linux/2.5.0/stringio-3.0.1/gem_make.out +16 -0
  242. data/vendor/bundle/ruby/2.5.0/extensions/x86_64-linux/2.5.0/stringio-3.0.1/mkmf.log +66 -0
  243. data/vendor/bundle/ruby/2.5.0/extensions/x86_64-linux/2.5.0/stringio-3.0.1/stringio.so +0 -0
  244. data/vendor/bundle/ruby/2.5.0/gems/byebug-11.1.3/ext/byebug/Makefile +2 -2
  245. data/vendor/bundle/ruby/2.5.0/gems/{diff-lcs-1.4.4 → diff-lcs-1.5.0}/.rspec +0 -0
  246. data/vendor/bundle/ruby/2.5.0/gems/{diff-lcs-1.4.4 → diff-lcs-1.5.0}/Code-of-Conduct.md +0 -0
  247. data/vendor/bundle/ruby/2.5.0/gems/{diff-lcs-1.4.4 → diff-lcs-1.5.0}/Contributing.md +1 -0
  248. data/vendor/bundle/ruby/2.5.0/gems/{diff-lcs-1.4.4 → diff-lcs-1.5.0}/History.md +201 -120
  249. data/vendor/bundle/ruby/2.5.0/gems/{diff-lcs-1.4.4 → diff-lcs-1.5.0}/License.md +0 -0
  250. data/vendor/bundle/ruby/2.5.0/gems/{diff-lcs-1.4.4 → diff-lcs-1.5.0}/Manifest.txt +15 -1
  251. data/vendor/bundle/ruby/2.5.0/gems/{diff-lcs-1.4.4 → diff-lcs-1.5.0}/README.rdoc +0 -0
  252. data/vendor/bundle/ruby/2.5.0/gems/{diff-lcs-1.4.4 → diff-lcs-1.5.0}/Rakefile +48 -1
  253. data/vendor/bundle/ruby/2.5.0/gems/{diff-lcs-1.4.4 → diff-lcs-1.5.0}/bin/htmldiff +0 -0
  254. data/vendor/bundle/ruby/2.5.0/gems/{diff-lcs-1.4.4 → diff-lcs-1.5.0}/bin/ldiff +0 -0
  255. data/vendor/bundle/ruby/2.5.0/gems/{diff-lcs-1.4.4 → diff-lcs-1.5.0}/docs/COPYING.txt +0 -0
  256. data/vendor/bundle/ruby/2.5.0/gems/{diff-lcs-1.4.4 → diff-lcs-1.5.0}/docs/artistic.txt +0 -0
  257. data/vendor/bundle/ruby/2.5.0/gems/{diff-lcs-1.4.4 → diff-lcs-1.5.0}/lib/diff/lcs/array.rb +0 -0
  258. data/vendor/bundle/ruby/2.5.0/gems/{diff-lcs-1.4.4 → diff-lcs-1.5.0}/lib/diff/lcs/backports.rb +0 -0
  259. data/vendor/bundle/ruby/2.5.0/gems/{diff-lcs-1.4.4 → diff-lcs-1.5.0}/lib/diff/lcs/block.rb +0 -0
  260. data/vendor/bundle/ruby/2.5.0/gems/{diff-lcs-1.4.4 → diff-lcs-1.5.0}/lib/diff/lcs/callbacks.rb +0 -0
  261. data/vendor/bundle/ruby/2.5.0/gems/{diff-lcs-1.4.4 → diff-lcs-1.5.0}/lib/diff/lcs/change.rb +0 -0
  262. data/vendor/bundle/ruby/2.5.0/gems/{diff-lcs-1.4.4 → diff-lcs-1.5.0}/lib/diff/lcs/htmldiff.rb +0 -0
  263. data/vendor/bundle/ruby/2.5.0/gems/{diff-lcs-1.4.4 → diff-lcs-1.5.0}/lib/diff/lcs/hunk.rb +0 -0
  264. data/vendor/bundle/ruby/2.5.0/gems/{diff-lcs-1.4.4 → diff-lcs-1.5.0}/lib/diff/lcs/internals.rb +7 -3
  265. data/vendor/bundle/ruby/2.5.0/gems/{diff-lcs-1.4.4 → diff-lcs-1.5.0}/lib/diff/lcs/ldiff.rb +0 -0
  266. data/vendor/bundle/ruby/2.5.0/gems/{diff-lcs-1.4.4 → diff-lcs-1.5.0}/lib/diff/lcs/string.rb +0 -0
  267. data/vendor/bundle/ruby/2.5.0/gems/{diff-lcs-1.4.4 → diff-lcs-1.5.0}/lib/diff/lcs.rb +25 -25
  268. data/vendor/bundle/ruby/2.5.0/gems/{diff-lcs-1.4.4 → diff-lcs-1.5.0}/lib/diff-lcs.rb +0 -0
  269. data/vendor/bundle/ruby/2.5.0/gems/{diff-lcs-1.4.4 → diff-lcs-1.5.0}/spec/change_spec.rb +0 -0
  270. data/vendor/bundle/ruby/2.5.0/gems/{diff-lcs-1.4.4 → diff-lcs-1.5.0}/spec/diff_spec.rb +0 -0
  271. data/vendor/bundle/ruby/2.5.0/gems/{diff-lcs-1.4.4 → diff-lcs-1.5.0}/spec/fixtures/aX +0 -0
  272. data/vendor/bundle/ruby/2.5.0/gems/{diff-lcs-1.4.4 → diff-lcs-1.5.0}/spec/fixtures/bXaX +0 -0
  273. data/vendor/bundle/ruby/2.5.0/gems/{diff-lcs-1.4.4 → diff-lcs-1.5.0}/spec/fixtures/ds1.csv +0 -0
  274. data/vendor/bundle/ruby/2.5.0/gems/{diff-lcs-1.4.4 → diff-lcs-1.5.0}/spec/fixtures/ds2.csv +0 -0
  275. data/vendor/bundle/ruby/2.5.0/gems/{diff-lcs-1.4.4 → diff-lcs-1.5.0}/spec/fixtures/ldiff/output.diff +0 -0
  276. data/vendor/bundle/ruby/2.5.0/gems/{diff-lcs-1.4.4 → diff-lcs-1.5.0}/spec/fixtures/ldiff/output.diff-c +0 -0
  277. data/vendor/bundle/ruby/2.5.0/gems/{diff-lcs-1.4.4 → diff-lcs-1.5.0}/spec/fixtures/ldiff/output.diff-e +0 -0
  278. data/vendor/bundle/ruby/2.5.0/gems/{diff-lcs-1.4.4 → diff-lcs-1.5.0}/spec/fixtures/ldiff/output.diff-f +0 -0
  279. data/vendor/bundle/ruby/2.5.0/gems/{diff-lcs-1.4.4 → diff-lcs-1.5.0}/spec/fixtures/ldiff/output.diff-u +0 -0
  280. data/vendor/bundle/ruby/2.5.0/gems/diff-lcs-1.5.0/spec/fixtures/ldiff/output.diff.chef +4 -0
  281. data/vendor/bundle/ruby/2.5.0/gems/diff-lcs-1.5.0/spec/fixtures/ldiff/output.diff.chef-c +15 -0
  282. data/vendor/bundle/ruby/2.5.0/gems/diff-lcs-1.5.0/spec/fixtures/ldiff/output.diff.chef-e +3 -0
  283. data/vendor/bundle/ruby/2.5.0/gems/diff-lcs-1.5.0/spec/fixtures/ldiff/output.diff.chef-f +3 -0
  284. data/vendor/bundle/ruby/2.5.0/gems/diff-lcs-1.5.0/spec/fixtures/ldiff/output.diff.chef-u +9 -0
  285. data/vendor/bundle/ruby/2.5.0/gems/diff-lcs-1.5.0/spec/fixtures/ldiff/output.diff.chef2 +7 -0
  286. data/vendor/bundle/ruby/2.5.0/gems/diff-lcs-1.5.0/spec/fixtures/ldiff/output.diff.chef2-c +20 -0
  287. data/vendor/bundle/ruby/2.5.0/gems/diff-lcs-1.5.0/spec/fixtures/ldiff/output.diff.chef2-d +7 -0
  288. data/vendor/bundle/ruby/2.5.0/gems/diff-lcs-1.5.0/spec/fixtures/ldiff/output.diff.chef2-e +7 -0
  289. data/vendor/bundle/ruby/2.5.0/gems/diff-lcs-1.5.0/spec/fixtures/ldiff/output.diff.chef2-f +7 -0
  290. data/vendor/bundle/ruby/2.5.0/gems/diff-lcs-1.5.0/spec/fixtures/ldiff/output.diff.chef2-u +16 -0
  291. data/vendor/bundle/ruby/2.5.0/gems/diff-lcs-1.5.0/spec/fixtures/new-chef +4 -0
  292. data/vendor/bundle/ruby/2.5.0/gems/diff-lcs-1.5.0/spec/fixtures/new-chef2 +17 -0
  293. data/vendor/bundle/ruby/2.5.0/gems/diff-lcs-1.5.0/spec/fixtures/old-chef +4 -0
  294. data/vendor/bundle/ruby/2.5.0/gems/diff-lcs-1.5.0/spec/fixtures/old-chef2 +14 -0
  295. data/vendor/bundle/ruby/2.5.0/gems/{diff-lcs-1.4.4 → diff-lcs-1.5.0}/spec/hunk_spec.rb +0 -0
  296. data/vendor/bundle/ruby/2.5.0/gems/{diff-lcs-1.4.4 → diff-lcs-1.5.0}/spec/issues_spec.rb +0 -0
  297. data/vendor/bundle/ruby/2.5.0/gems/{diff-lcs-1.4.4 → diff-lcs-1.5.0}/spec/lcs_spec.rb +0 -0
  298. data/vendor/bundle/ruby/2.5.0/gems/{diff-lcs-1.4.4 → diff-lcs-1.5.0}/spec/ldiff_spec.rb +0 -0
  299. data/vendor/bundle/ruby/2.5.0/gems/{diff-lcs-1.4.4 → diff-lcs-1.5.0}/spec/patch_spec.rb +0 -0
  300. data/vendor/bundle/ruby/2.5.0/gems/{diff-lcs-1.4.4 → diff-lcs-1.5.0}/spec/sdiff_spec.rb +0 -0
  301. data/vendor/bundle/ruby/2.5.0/gems/{diff-lcs-1.4.4 → diff-lcs-1.5.0}/spec/spec_helper.rb +5 -6
  302. data/vendor/bundle/ruby/2.5.0/gems/{diff-lcs-1.4.4 → diff-lcs-1.5.0}/spec/traverse_balanced_spec.rb +0 -0
  303. data/vendor/bundle/ruby/2.5.0/gems/{diff-lcs-1.4.4 → diff-lcs-1.5.0}/spec/traverse_sequences_spec.rb +2 -4
  304. data/vendor/bundle/ruby/2.5.0/gems/ffi-1.15.4/ext/ffi_c/Makefile +2 -2
  305. data/vendor/bundle/ruby/2.5.0/gems/jaro_winkler-1.5.4/ext/jaro_winkler/Makefile +2 -2
  306. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/LICENSE.txt +0 -0
  307. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/bin/ruby-parse +0 -0
  308. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/bin/ruby-rewrite +0 -0
  309. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/gauntlet_parser.rb +0 -0
  310. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/all.rb +0 -0
  311. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/ast/node.rb +0 -0
  312. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/ast/processor.rb +0 -0
  313. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/base.rb +0 -0
  314. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/builders/default.rb +29 -5
  315. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/clobbering_error.rb +0 -0
  316. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/color.rb +0 -0
  317. data/vendor/bundle/ruby/2.5.0/gems/parser-3.1.0.0/lib/parser/context.rb +49 -0
  318. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/current.rb +7 -7
  319. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/current_arg_stack.rb +0 -0
  320. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/deprecation.rb +0 -0
  321. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/diagnostic/engine.rb +0 -0
  322. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/diagnostic.rb +0 -0
  323. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/lexer/dedenter.rb +1 -1
  324. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/lexer/explanation.rb +1 -1
  325. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/lexer/literal.rb +0 -0
  326. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/lexer/stack_state.rb +0 -0
  327. data/vendor/bundle/ruby/2.5.0/gems/parser-3.1.0.0/lib/parser/lexer.rb +25015 -0
  328. data/vendor/bundle/ruby/2.5.0/gems/parser-3.1.0.0/lib/parser/macruby.rb +6177 -0
  329. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/max_numparam_stack.rb +5 -5
  330. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/messages.rb +2 -0
  331. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/meta.rb +0 -0
  332. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/rewriter.rb +0 -0
  333. data/vendor/bundle/ruby/2.5.0/gems/parser-3.1.0.0/lib/parser/ruby18.rb +5708 -0
  334. data/vendor/bundle/ruby/2.5.0/gems/parser-3.1.0.0/lib/parser/ruby19.rb +6126 -0
  335. data/vendor/bundle/ruby/2.5.0/gems/parser-3.1.0.0/lib/parser/ruby20.rb +6563 -0
  336. data/vendor/bundle/ruby/2.5.0/gems/parser-3.1.0.0/lib/parser/ruby21.rb +6611 -0
  337. data/vendor/bundle/ruby/2.5.0/gems/parser-3.1.0.0/lib/parser/ruby22.rb +6655 -0
  338. data/vendor/bundle/ruby/2.5.0/gems/parser-3.1.0.0/lib/parser/ruby23.rb +6669 -0
  339. data/vendor/bundle/ruby/2.5.0/gems/parser-3.1.0.0/lib/parser/ruby24.rb +6736 -0
  340. data/vendor/bundle/ruby/2.5.0/gems/parser-3.1.0.0/lib/parser/ruby25.rb +6694 -0
  341. data/vendor/bundle/ruby/2.5.0/gems/parser-3.1.0.0/lib/parser/ruby26.rb +6721 -0
  342. data/vendor/bundle/ruby/2.5.0/gems/parser-3.1.0.0/lib/parser/ruby27.rb +7914 -0
  343. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/ruby28.rb +0 -0
  344. data/vendor/bundle/ruby/2.5.0/gems/parser-3.1.0.0/lib/parser/ruby30.rb +8096 -0
  345. data/vendor/bundle/ruby/2.5.0/gems/parser-3.1.0.0/lib/parser/ruby31.rb +8354 -0
  346. data/vendor/bundle/ruby/2.5.0/gems/parser-3.1.0.0/lib/parser/rubymotion.rb +6125 -0
  347. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/runner/ruby_parse.rb +0 -0
  348. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/runner/ruby_rewrite.rb +0 -0
  349. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/runner.rb +0 -0
  350. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/source/buffer.rb +0 -0
  351. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/source/comment/associator.rb +0 -0
  352. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/source/comment.rb +0 -0
  353. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/source/map/collection.rb +0 -0
  354. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/source/map/condition.rb +0 -0
  355. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/source/map/constant.rb +0 -0
  356. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/source/map/definition.rb +0 -0
  357. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/source/map/for.rb +0 -0
  358. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/source/map/heredoc.rb +0 -0
  359. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/source/map/index.rb +0 -0
  360. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/source/map/keyword.rb +0 -0
  361. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/source/map/method_definition.rb +0 -0
  362. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/source/map/objc_kwarg.rb +0 -0
  363. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/source/map/operator.rb +0 -0
  364. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/source/map/rescue_body.rb +0 -0
  365. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/source/map/send.rb +0 -0
  366. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/source/map/ternary.rb +0 -0
  367. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/source/map/variable.rb +0 -0
  368. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/source/map.rb +0 -0
  369. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/source/range.rb +0 -0
  370. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/source/rewriter/action.rb +0 -0
  371. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/source/rewriter.rb +0 -0
  372. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/source/tree_rewriter/action.rb +0 -0
  373. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/source/tree_rewriter.rb +0 -0
  374. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/static_environment.rb +9 -0
  375. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/syntax_error.rb +0 -0
  376. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/tree_rewriter.rb +0 -0
  377. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/variables_stack.rb +0 -0
  378. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser/version.rb +1 -1
  379. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/lib/parser.rb +0 -0
  380. data/vendor/bundle/ruby/2.5.0/gems/{parser-3.0.3.0 → parser-3.1.0.0}/parser.gemspec +0 -0
  381. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/.gitignore +0 -0
  382. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/Gemfile +0 -0
  383. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/LICENSE +0 -0
  384. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/Mavenfile +0 -0
  385. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/README.md +0 -0
  386. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/Rakefile +0 -0
  387. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/bin/console +0 -0
  388. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/bin/setup +0 -0
  389. data/vendor/bundle/ruby/2.5.0/gems/psych-4.0.3/ext/psych/.sitearchdir.time +0 -0
  390. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/ext/psych/Makefile +2 -2
  391. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/ext/psych/api.o +0 -0
  392. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/ext/psych/depend +0 -0
  393. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/ext/psych/dumper.o +0 -0
  394. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/ext/psych/emitter.o +0 -0
  395. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/ext/psych/extconf.rb +0 -0
  396. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/ext/psych/loader.o +0 -0
  397. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/ext/psych/parser.o +0 -0
  398. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/ext/psych/psych.c +0 -0
  399. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/ext/psych/psych.h +0 -0
  400. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/ext/psych/psych.o +0 -0
  401. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2/lib → psych-4.0.3/ext/psych}/psych.so +0 -0
  402. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/ext/psych/psych_emitter.c +0 -0
  403. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/ext/psych/psych_emitter.h +0 -0
  404. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/ext/psych/psych_emitter.o +0 -0
  405. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/ext/psych/psych_parser.c +0 -0
  406. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/ext/psych/psych_parser.h +0 -0
  407. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/ext/psych/psych_parser.o +0 -0
  408. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/ext/psych/psych_to_ruby.c +0 -0
  409. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/ext/psych/psych_to_ruby.h +0 -0
  410. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/ext/psych/psych_to_ruby.o +0 -0
  411. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/ext/psych/psych_yaml_tree.c +0 -0
  412. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/ext/psych/psych_yaml_tree.h +0 -0
  413. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/ext/psych/psych_yaml_tree.o +0 -0
  414. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/ext/psych/reader.o +0 -0
  415. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/ext/psych/scanner.o +0 -0
  416. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/ext/psych/writer.o +0 -0
  417. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/ext/psych/yaml/LICENSE +0 -0
  418. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/ext/psych/yaml/api.c +0 -0
  419. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/ext/psych/yaml/config.h +0 -0
  420. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/ext/psych/yaml/dumper.c +0 -0
  421. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/ext/psych/yaml/emitter.c +0 -0
  422. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/ext/psych/yaml/loader.c +0 -0
  423. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/ext/psych/yaml/parser.c +0 -0
  424. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/ext/psych/yaml/reader.c +0 -0
  425. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/ext/psych/yaml/scanner.c +0 -0
  426. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/ext/psych/yaml/writer.c +0 -0
  427. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/ext/psych/yaml/yaml.h +0 -0
  428. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/ext/psych/yaml/yaml_private.h +0 -0
  429. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/lib/psych/class_loader.rb +2 -2
  430. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/lib/psych/coder.rb +0 -0
  431. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/lib/psych/core_ext.rb +1 -1
  432. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/lib/psych/exception.rb +0 -0
  433. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/lib/psych/handler.rb +0 -0
  434. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/lib/psych/handlers/document_stream.rb +1 -1
  435. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/lib/psych/handlers/recorder.rb +1 -1
  436. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/lib/psych/json/ruby_events.rb +0 -0
  437. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/lib/psych/json/stream.rb +2 -2
  438. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/lib/psych/json/tree_builder.rb +1 -1
  439. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/lib/psych/json/yaml_events.rb +0 -0
  440. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/lib/psych/nodes/alias.rb +0 -0
  441. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/lib/psych/nodes/document.rb +0 -0
  442. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/lib/psych/nodes/mapping.rb +0 -0
  443. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/lib/psych/nodes/node.rb +2 -2
  444. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/lib/psych/nodes/scalar.rb +0 -0
  445. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/lib/psych/nodes/sequence.rb +0 -0
  446. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/lib/psych/nodes/stream.rb +0 -0
  447. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/lib/psych/nodes.rb +7 -7
  448. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/lib/psych/omap.rb +0 -0
  449. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/lib/psych/parser.rb +0 -0
  450. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/lib/psych/scalar_scanner.rb +0 -0
  451. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/lib/psych/set.rb +0 -0
  452. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/lib/psych/stream.rb +0 -0
  453. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/lib/psych/streaming.rb +0 -0
  454. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/lib/psych/syntax_error.rb +1 -1
  455. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/lib/psych/tree_builder.rb +1 -1
  456. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/lib/psych/versions.rb +1 -1
  457. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/lib/psych/visitors/depth_first.rb +0 -0
  458. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/lib/psych/visitors/emitter.rb +0 -0
  459. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/lib/psych/visitors/json_tree.rb +1 -1
  460. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/lib/psych/visitors/to_ruby.rb +3 -3
  461. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/lib/psych/visitors/visitor.rb +0 -0
  462. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/lib/psych/visitors/yaml_tree.rb +3 -3
  463. data/vendor/bundle/ruby/2.5.0/gems/psych-4.0.3/lib/psych/visitors.rb +7 -0
  464. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/lib/psych/y.rb +0 -0
  465. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/lib/psych.rb +17 -17
  466. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2/ext/psych → psych-4.0.3/lib}/psych.so +0 -0
  467. data/vendor/bundle/ruby/2.5.0/gems/{psych-4.0.2 → psych-4.0.3}/psych.gemspec +2 -0
  468. data/vendor/bundle/ruby/2.5.0/gems/stringio-3.0.1/README.md +44 -0
  469. data/vendor/bundle/ruby/2.5.0/gems/stringio-3.0.1/ext/stringio/.sitearchdir.time +0 -0
  470. data/vendor/bundle/ruby/2.5.0/gems/stringio-3.0.1/ext/stringio/Makefile +264 -0
  471. data/vendor/bundle/ruby/2.5.0/gems/stringio-3.0.1/ext/stringio/extconf.rb +4 -0
  472. data/vendor/bundle/ruby/2.5.0/gems/stringio-3.0.1/ext/stringio/stringio.c +1866 -0
  473. data/vendor/bundle/ruby/2.5.0/gems/stringio-3.0.1/ext/stringio/stringio.o +0 -0
  474. data/vendor/bundle/ruby/2.5.0/gems/stringio-3.0.1/ext/stringio/stringio.so +0 -0
  475. data/vendor/bundle/ruby/2.5.0/gems/stringio-3.0.1/lib/stringio.so +0 -0
  476. data/vendor/bundle/ruby/2.5.0/specifications/{diff-lcs-1.4.4.gemspec → diff-lcs-1.5.0.gemspec} +9 -9
  477. data/vendor/bundle/ruby/2.5.0/specifications/{parser-3.0.3.0.gemspec → parser-3.1.0.0.gemspec} +4 -4
  478. data/vendor/bundle/ruby/2.5.0/specifications/{psych-4.0.2.gemspec → psych-4.0.3.gemspec} +15 -3
  479. data/vendor/bundle/ruby/2.5.0/specifications/stringio-3.0.1.gemspec +24 -0
  480. metadata +264 -232
  481. data/docs/NullString.md +0 -20
  482. data/docs/NullUUID.md +0 -20
  483. data/docs/ProvisionProjectPayload.md +0 -18
  484. data/spec/models/provision_project_payload_spec.rb +0 -34
  485. data/vendor/bundle/ruby/2.5.0/cache/diff-lcs-1.4.4.gem +0 -0
  486. data/vendor/bundle/ruby/2.5.0/cache/parser-3.0.3.0.gem +0 -0
  487. data/vendor/bundle/ruby/2.5.0/cache/psych-4.0.2.gem +0 -0
  488. data/vendor/bundle/ruby/2.5.0/gems/diff-lcs-1.4.4/autotest/discover.rb +0 -3
  489. data/vendor/bundle/ruby/2.5.0/gems/parser-3.0.3.0/lib/parser/context.rb +0 -68
  490. data/vendor/bundle/ruby/2.5.0/gems/parser-3.0.3.0/lib/parser/lexer.rb +0 -24709
  491. data/vendor/bundle/ruby/2.5.0/gems/parser-3.0.3.0/lib/parser/macruby.rb +0 -6149
  492. data/vendor/bundle/ruby/2.5.0/gems/parser-3.0.3.0/lib/parser/ruby18.rb +0 -5667
  493. data/vendor/bundle/ruby/2.5.0/gems/parser-3.0.3.0/lib/parser/ruby19.rb +0 -6092
  494. data/vendor/bundle/ruby/2.5.0/gems/parser-3.0.3.0/lib/parser/ruby20.rb +0 -6527
  495. data/vendor/bundle/ruby/2.5.0/gems/parser-3.0.3.0/lib/parser/ruby21.rb +0 -6578
  496. data/vendor/bundle/ruby/2.5.0/gems/parser-3.0.3.0/lib/parser/ruby22.rb +0 -6613
  497. data/vendor/bundle/ruby/2.5.0/gems/parser-3.0.3.0/lib/parser/ruby23.rb +0 -6624
  498. data/vendor/bundle/ruby/2.5.0/gems/parser-3.0.3.0/lib/parser/ruby24.rb +0 -6694
  499. data/vendor/bundle/ruby/2.5.0/gems/parser-3.0.3.0/lib/parser/ruby25.rb +0 -6662
  500. data/vendor/bundle/ruby/2.5.0/gems/parser-3.0.3.0/lib/parser/ruby26.rb +0 -6676
  501. data/vendor/bundle/ruby/2.5.0/gems/parser-3.0.3.0/lib/parser/ruby27.rb +0 -7866
  502. data/vendor/bundle/ruby/2.5.0/gems/parser-3.0.3.0/lib/parser/ruby30.rb +0 -8064
  503. data/vendor/bundle/ruby/2.5.0/gems/parser-3.0.3.0/lib/parser/ruby31.rb +0 -8283
  504. data/vendor/bundle/ruby/2.5.0/gems/parser-3.0.3.0/lib/parser/rubymotion.rb +0 -6086
  505. data/vendor/bundle/ruby/2.5.0/gems/psych-4.0.2/lib/psych/visitors.rb +0 -7
@@ -0,0 +1,1866 @@
1
+ /* -*- mode: c; indent-tabs-mode: t -*- */
2
+ /**********************************************************************
3
+
4
+ stringio.c -
5
+
6
+ $Author$
7
+ $RoughId: stringio.c,v 1.13 2002/03/14 03:24:18 nobu Exp $
8
+ created at: Tue Feb 19 04:10:38 JST 2002
9
+
10
+ All the files in this distribution are covered under the Ruby's
11
+ license (see the file COPYING).
12
+
13
+ **********************************************************************/
14
+
15
+ #define STRINGIO_VERSION "3.0.1"
16
+
17
+ #include "ruby.h"
18
+ #include "ruby/io.h"
19
+ #include "ruby/encoding.h"
20
+ #if defined(HAVE_FCNTL_H) || defined(_WIN32)
21
+ #include <fcntl.h>
22
+ #elif defined(HAVE_SYS_FCNTL_H)
23
+ #include <sys/fcntl.h>
24
+ #endif
25
+
26
+ #ifndef RB_INTEGER_TYPE_P
27
+ # define RB_INTEGER_TYPE_P(c) (FIXNUM_P(c) || RB_TYPE_P(c, T_BIGNUM))
28
+ #endif
29
+
30
+ #ifndef RB_PASS_CALLED_KEYWORDS
31
+ # define rb_funcallv_kw(recv, mid, arg, argv, kw_splat) rb_funcallv(recv, mid, arg, argv)
32
+ # define rb_class_new_instance_kw(argc, argv, klass, kw_splat) rb_class_new_instance(argc, argv, klass)
33
+ #endif
34
+
35
+ #ifndef HAVE_RB_IO_EXTRACT_MODEENC
36
+ #define rb_io_extract_modeenc strio_extract_modeenc
37
+ static void
38
+ strio_extract_modeenc(VALUE *vmode_p, VALUE *vperm_p, VALUE opthash,
39
+ int *oflags_p, int *fmode_p, struct rb_io_enc_t *convconfig_p)
40
+ {
41
+ VALUE mode = *vmode_p;
42
+ VALUE intmode;
43
+ int fmode;
44
+ int has_enc = 0, has_vmode = 0;
45
+
46
+ convconfig_p->enc = convconfig_p->enc2 = 0;
47
+
48
+ vmode_handle:
49
+ if (NIL_P(mode)) {
50
+ fmode = FMODE_READABLE;
51
+ }
52
+ else if (!NIL_P(intmode = rb_check_to_integer(mode, "to_int"))) {
53
+ int flags = NUM2INT(intmode);
54
+ fmode = rb_io_oflags_fmode(flags);
55
+ }
56
+ else {
57
+ const char *m = StringValueCStr(mode), *n, *e;
58
+ fmode = rb_io_modestr_fmode(m);
59
+ n = strchr(m, ':');
60
+ if (n) {
61
+ long len;
62
+ char encname[ENCODING_MAXNAMELEN+1];
63
+ has_enc = 1;
64
+ if (fmode & FMODE_SETENC_BY_BOM) {
65
+ n = strchr(n, '|');
66
+ }
67
+ e = strchr(++n, ':');
68
+ len = e ? e - n : (long)strlen(n);
69
+ if (len > 0 && len <= ENCODING_MAXNAMELEN) {
70
+ if (e) {
71
+ memcpy(encname, n, len);
72
+ encname[len] = '\0';
73
+ n = encname;
74
+ }
75
+ convconfig_p->enc = rb_enc_find(n);
76
+ }
77
+ if (e && (len = strlen(++e)) > 0 && len <= ENCODING_MAXNAMELEN) {
78
+ convconfig_p->enc2 = rb_enc_find(e);
79
+ }
80
+ }
81
+ }
82
+
83
+ if (!NIL_P(opthash)) {
84
+ rb_encoding *extenc = 0, *intenc = 0;
85
+ VALUE v;
86
+ if (!has_vmode) {
87
+ ID id_mode;
88
+ CONST_ID(id_mode, "mode");
89
+ v = rb_hash_aref(opthash, ID2SYM(id_mode));
90
+ if (!NIL_P(v)) {
91
+ if (!NIL_P(mode)) {
92
+ rb_raise(rb_eArgError, "mode specified twice");
93
+ }
94
+ has_vmode = 1;
95
+ mode = v;
96
+ goto vmode_handle;
97
+ }
98
+ }
99
+
100
+ if (rb_io_extract_encoding_option(opthash, &extenc, &intenc, &fmode)) {
101
+ if (has_enc) {
102
+ rb_raise(rb_eArgError, "encoding specified twice");
103
+ }
104
+ }
105
+ }
106
+ *fmode_p = fmode;
107
+ }
108
+ #endif
109
+
110
+ struct StringIO {
111
+ VALUE string;
112
+ rb_encoding *enc;
113
+ long pos;
114
+ long lineno;
115
+ int flags;
116
+ int count;
117
+ };
118
+
119
+ static VALUE strio_init(int, VALUE *, struct StringIO *, VALUE);
120
+ static VALUE strio_unget_bytes(struct StringIO *, const char *, long);
121
+ static long strio_write(VALUE self, VALUE str);
122
+
123
+ #define IS_STRIO(obj) (rb_typeddata_is_kind_of((obj), &strio_data_type))
124
+ #define error_inval(msg) (rb_syserr_fail(EINVAL, msg))
125
+ #define get_enc(ptr) ((ptr)->enc ? (ptr)->enc : rb_enc_get((ptr)->string))
126
+
127
+ static struct StringIO *
128
+ strio_alloc(void)
129
+ {
130
+ struct StringIO *ptr = ALLOC(struct StringIO);
131
+ ptr->string = Qnil;
132
+ ptr->pos = 0;
133
+ ptr->lineno = 0;
134
+ ptr->flags = 0;
135
+ ptr->count = 1;
136
+ return ptr;
137
+ }
138
+
139
+ static void
140
+ strio_mark(void *p)
141
+ {
142
+ struct StringIO *ptr = p;
143
+
144
+ rb_gc_mark(ptr->string);
145
+ }
146
+
147
+ static void
148
+ strio_free(void *p)
149
+ {
150
+ struct StringIO *ptr = p;
151
+ if (--ptr->count <= 0) {
152
+ xfree(ptr);
153
+ }
154
+ }
155
+
156
+ static size_t
157
+ strio_memsize(const void *p)
158
+ {
159
+ return sizeof(struct StringIO);
160
+ }
161
+
162
+ static const rb_data_type_t strio_data_type = {
163
+ "strio",
164
+ {
165
+ strio_mark,
166
+ strio_free,
167
+ strio_memsize,
168
+ },
169
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
170
+ };
171
+
172
+ #define check_strio(self) ((struct StringIO*)rb_check_typeddata((self), &strio_data_type))
173
+
174
+ static struct StringIO*
175
+ get_strio(VALUE self)
176
+ {
177
+ struct StringIO *ptr = check_strio(rb_io_taint_check(self));
178
+
179
+ if (!ptr) {
180
+ rb_raise(rb_eIOError, "uninitialized stream");
181
+ }
182
+ return ptr;
183
+ }
184
+
185
+ static VALUE
186
+ enc_subseq(VALUE str, long pos, long len, rb_encoding *enc)
187
+ {
188
+ str = rb_str_subseq(str, pos, len);
189
+ rb_enc_associate(str, enc);
190
+ return str;
191
+ }
192
+
193
+ static VALUE
194
+ strio_substr(struct StringIO *ptr, long pos, long len, rb_encoding *enc)
195
+ {
196
+ VALUE str = ptr->string;
197
+ long rlen = RSTRING_LEN(str) - pos;
198
+
199
+ if (len > rlen) len = rlen;
200
+ if (len < 0) len = 0;
201
+ if (len == 0) return rb_enc_str_new(0, 0, enc);
202
+ return enc_subseq(str, pos, len, enc);
203
+ }
204
+
205
+ #define StringIO(obj) get_strio(obj)
206
+
207
+ #define STRIO_READABLE FL_USER4
208
+ #define STRIO_WRITABLE FL_USER5
209
+ #define STRIO_READWRITE (STRIO_READABLE|STRIO_WRITABLE)
210
+ typedef char strio_flags_check[(STRIO_READABLE/FMODE_READABLE == STRIO_WRITABLE/FMODE_WRITABLE) * 2 - 1];
211
+ #define STRIO_MODE_SET_P(strio, mode) \
212
+ ((RBASIC(strio)->flags & STRIO_##mode) && \
213
+ ((struct StringIO*)DATA_PTR(strio))->flags & FMODE_##mode)
214
+ #define CLOSED(strio) (!STRIO_MODE_SET_P(strio, READWRITE))
215
+ #define READABLE(strio) STRIO_MODE_SET_P(strio, READABLE)
216
+ #define WRITABLE(strio) STRIO_MODE_SET_P(strio, WRITABLE)
217
+
218
+ static VALUE sym_exception;
219
+
220
+ static struct StringIO*
221
+ readable(VALUE strio)
222
+ {
223
+ struct StringIO *ptr = StringIO(strio);
224
+ if (!READABLE(strio)) {
225
+ rb_raise(rb_eIOError, "not opened for reading");
226
+ }
227
+ return ptr;
228
+ }
229
+
230
+ static struct StringIO*
231
+ writable(VALUE strio)
232
+ {
233
+ struct StringIO *ptr = StringIO(strio);
234
+ if (!WRITABLE(strio)) {
235
+ rb_raise(rb_eIOError, "not opened for writing");
236
+ }
237
+ return ptr;
238
+ }
239
+
240
+ static void
241
+ check_modifiable(struct StringIO *ptr)
242
+ {
243
+ if (OBJ_FROZEN(ptr->string)) {
244
+ rb_raise(rb_eIOError, "not modifiable string");
245
+ }
246
+ }
247
+
248
+ static VALUE
249
+ strio_s_allocate(VALUE klass)
250
+ {
251
+ return TypedData_Wrap_Struct(klass, &strio_data_type, 0);
252
+ }
253
+
254
+ /*
255
+ * call-seq: StringIO.new(string=""[, mode])
256
+ *
257
+ * Creates new StringIO instance from with _string_ and _mode_.
258
+ */
259
+ static VALUE
260
+ strio_initialize(int argc, VALUE *argv, VALUE self)
261
+ {
262
+ struct StringIO *ptr = check_strio(self);
263
+
264
+ if (!ptr) {
265
+ DATA_PTR(self) = ptr = strio_alloc();
266
+ }
267
+ rb_call_super(0, 0);
268
+ return strio_init(argc, argv, ptr, self);
269
+ }
270
+
271
+ static int
272
+ detect_bom(VALUE str, int *bomlen)
273
+ {
274
+ const char *p;
275
+ long len;
276
+
277
+ RSTRING_GETMEM(str, p, len);
278
+ if (len < 1) return 0;
279
+ switch ((unsigned char)p[0]) {
280
+ case 0xEF:
281
+ if (len < 2) break;
282
+ if ((unsigned char)p[1] == 0xBB && len > 2) {
283
+ if ((unsigned char)p[2] == 0xBF) {
284
+ *bomlen = 3;
285
+ return rb_utf8_encindex();
286
+ }
287
+ }
288
+ break;
289
+
290
+ case 0xFE:
291
+ if (len < 2) break;
292
+ if ((unsigned char)p[1] == 0xFF) {
293
+ *bomlen = 2;
294
+ return rb_enc_find_index("UTF-16BE");
295
+ }
296
+ break;
297
+
298
+ case 0xFF:
299
+ if (len < 2) break;
300
+ if ((unsigned char)p[1] == 0xFE) {
301
+ if (len >= 4 && (unsigned char)p[2] == 0 && (unsigned char)p[3] == 0) {
302
+ *bomlen = 4;
303
+ return rb_enc_find_index("UTF-32LE");
304
+ }
305
+ *bomlen = 2;
306
+ return rb_enc_find_index("UTF-16LE");
307
+ }
308
+ break;
309
+
310
+ case 0:
311
+ if (len < 4) break;
312
+ if ((unsigned char)p[1] == 0 && (unsigned char)p[2] == 0xFE && (unsigned char)p[3] == 0xFF) {
313
+ *bomlen = 4;
314
+ return rb_enc_find_index("UTF-32BE");
315
+ }
316
+ break;
317
+ }
318
+ return 0;
319
+ }
320
+
321
+ static rb_encoding *
322
+ set_encoding_by_bom(struct StringIO *ptr)
323
+ {
324
+ int bomlen, idx = detect_bom(ptr->string, &bomlen);
325
+ rb_encoding *extenc = NULL;
326
+
327
+ if (idx) {
328
+ extenc = rb_enc_from_index(idx);
329
+ ptr->pos = bomlen;
330
+ if (ptr->flags & FMODE_WRITABLE) {
331
+ rb_enc_associate_index(ptr->string, idx);
332
+ }
333
+ }
334
+ ptr->enc = extenc;
335
+ return extenc;
336
+ }
337
+
338
+ static VALUE
339
+ strio_init(int argc, VALUE *argv, struct StringIO *ptr, VALUE self)
340
+ {
341
+ VALUE string, vmode, opt;
342
+ int oflags;
343
+ struct rb_io_enc_t convconfig;
344
+
345
+ argc = rb_scan_args(argc, argv, "02:", &string, &vmode, &opt);
346
+ rb_io_extract_modeenc(&vmode, 0, opt, &oflags, &ptr->flags, &convconfig);
347
+ if (argc) {
348
+ StringValue(string);
349
+ }
350
+ else {
351
+ string = rb_enc_str_new("", 0, rb_default_external_encoding());
352
+ }
353
+ if (OBJ_FROZEN_RAW(string)) {
354
+ if (ptr->flags & FMODE_WRITABLE) {
355
+ rb_syserr_fail(EACCES, 0);
356
+ }
357
+ }
358
+ else {
359
+ if (NIL_P(vmode)) {
360
+ ptr->flags |= FMODE_WRITABLE;
361
+ }
362
+ }
363
+ if (ptr->flags & FMODE_TRUNC) {
364
+ rb_str_resize(string, 0);
365
+ }
366
+ ptr->string = string;
367
+ if (argc == 1) {
368
+ ptr->enc = rb_enc_get(string);
369
+ }
370
+ else {
371
+ ptr->enc = convconfig.enc;
372
+ }
373
+ ptr->pos = 0;
374
+ ptr->lineno = 0;
375
+ if (ptr->flags & FMODE_SETENC_BY_BOM) set_encoding_by_bom(ptr);
376
+ RBASIC(self)->flags |= (ptr->flags & FMODE_READWRITE) * (STRIO_READABLE / FMODE_READABLE);
377
+ return self;
378
+ }
379
+
380
+ static VALUE
381
+ strio_finalize(VALUE self)
382
+ {
383
+ struct StringIO *ptr = StringIO(self);
384
+ ptr->string = Qnil;
385
+ ptr->flags &= ~FMODE_READWRITE;
386
+ return self;
387
+ }
388
+
389
+ /*
390
+ * call-seq: StringIO.open(string=""[, mode]) {|strio| ...}
391
+ *
392
+ * Equivalent to StringIO.new except that when it is called with a block, it
393
+ * yields with the new instance and closes it, and returns the result which
394
+ * returned from the block.
395
+ */
396
+ static VALUE
397
+ strio_s_open(int argc, VALUE *argv, VALUE klass)
398
+ {
399
+ VALUE obj = rb_class_new_instance_kw(argc, argv, klass, RB_PASS_CALLED_KEYWORDS);
400
+ if (!rb_block_given_p()) return obj;
401
+ return rb_ensure(rb_yield, obj, strio_finalize, obj);
402
+ }
403
+
404
+ /* :nodoc: */
405
+ static VALUE
406
+ strio_s_new(int argc, VALUE *argv, VALUE klass)
407
+ {
408
+ if (rb_block_given_p()) {
409
+ VALUE cname = rb_obj_as_string(klass);
410
+
411
+ rb_warn("%"PRIsVALUE"::new() does not take block; use %"PRIsVALUE"::open() instead",
412
+ cname, cname);
413
+ }
414
+ return rb_class_new_instance_kw(argc, argv, klass, RB_PASS_CALLED_KEYWORDS);
415
+ }
416
+
417
+ /*
418
+ * Returns +false+. Just for compatibility to IO.
419
+ */
420
+ static VALUE
421
+ strio_false(VALUE self)
422
+ {
423
+ StringIO(self);
424
+ return Qfalse;
425
+ }
426
+
427
+ /*
428
+ * Returns +nil+. Just for compatibility to IO.
429
+ */
430
+ static VALUE
431
+ strio_nil(VALUE self)
432
+ {
433
+ StringIO(self);
434
+ return Qnil;
435
+ }
436
+
437
+ /*
438
+ * Returns an object itself. Just for compatibility to IO.
439
+ */
440
+ static VALUE
441
+ strio_self(VALUE self)
442
+ {
443
+ StringIO(self);
444
+ return self;
445
+ }
446
+
447
+ /*
448
+ * Returns 0. Just for compatibility to IO.
449
+ */
450
+ static VALUE
451
+ strio_0(VALUE self)
452
+ {
453
+ StringIO(self);
454
+ return INT2FIX(0);
455
+ }
456
+
457
+ /*
458
+ * Returns the argument unchanged. Just for compatibility to IO.
459
+ */
460
+ static VALUE
461
+ strio_first(VALUE self, VALUE arg)
462
+ {
463
+ StringIO(self);
464
+ return arg;
465
+ }
466
+
467
+ /*
468
+ * Raises NotImplementedError.
469
+ */
470
+ static VALUE
471
+ strio_unimpl(int argc, VALUE *argv, VALUE self)
472
+ {
473
+ StringIO(self);
474
+ rb_notimplement();
475
+
476
+ UNREACHABLE;
477
+ }
478
+
479
+ /*
480
+ * call-seq: strio.string -> string
481
+ *
482
+ * Returns underlying String object, the subject of IO.
483
+ */
484
+ static VALUE
485
+ strio_get_string(VALUE self)
486
+ {
487
+ return StringIO(self)->string;
488
+ }
489
+
490
+ /*
491
+ * call-seq:
492
+ * strio.string = string -> string
493
+ *
494
+ * Changes underlying String object, the subject of IO.
495
+ */
496
+ static VALUE
497
+ strio_set_string(VALUE self, VALUE string)
498
+ {
499
+ struct StringIO *ptr = StringIO(self);
500
+
501
+ rb_io_taint_check(self);
502
+ ptr->flags &= ~FMODE_READWRITE;
503
+ StringValue(string);
504
+ ptr->flags = OBJ_FROZEN(string) ? FMODE_READABLE : FMODE_READWRITE;
505
+ ptr->pos = 0;
506
+ ptr->lineno = 0;
507
+ return ptr->string = string;
508
+ }
509
+
510
+ /*
511
+ * call-seq:
512
+ * strio.close -> nil
513
+ *
514
+ * Closes a StringIO. The stream is unavailable for any further data
515
+ * operations; an +IOError+ is raised if such an attempt is made.
516
+ */
517
+ static VALUE
518
+ strio_close(VALUE self)
519
+ {
520
+ StringIO(self);
521
+ RBASIC(self)->flags &= ~STRIO_READWRITE;
522
+ return Qnil;
523
+ }
524
+
525
+ /*
526
+ * call-seq:
527
+ * strio.close_read -> nil
528
+ *
529
+ * Closes the read end of a StringIO. Will raise an +IOError+ if the
530
+ * receiver is not readable.
531
+ */
532
+ static VALUE
533
+ strio_close_read(VALUE self)
534
+ {
535
+ struct StringIO *ptr = StringIO(self);
536
+ if (!(ptr->flags & FMODE_READABLE)) {
537
+ rb_raise(rb_eIOError, "closing non-duplex IO for reading");
538
+ }
539
+ RBASIC(self)->flags &= ~STRIO_READABLE;
540
+ return Qnil;
541
+ }
542
+
543
+ /*
544
+ * call-seq:
545
+ * strio.close_write -> nil
546
+ *
547
+ * Closes the write end of a StringIO. Will raise an +IOError+ if the
548
+ * receiver is not writeable.
549
+ */
550
+ static VALUE
551
+ strio_close_write(VALUE self)
552
+ {
553
+ struct StringIO *ptr = StringIO(self);
554
+ if (!(ptr->flags & FMODE_WRITABLE)) {
555
+ rb_raise(rb_eIOError, "closing non-duplex IO for writing");
556
+ }
557
+ RBASIC(self)->flags &= ~STRIO_WRITABLE;
558
+ return Qnil;
559
+ }
560
+
561
+ /*
562
+ * call-seq:
563
+ * strio.closed? -> true or false
564
+ *
565
+ * Returns +true+ if the stream is completely closed, +false+ otherwise.
566
+ */
567
+ static VALUE
568
+ strio_closed(VALUE self)
569
+ {
570
+ StringIO(self);
571
+ if (!CLOSED(self)) return Qfalse;
572
+ return Qtrue;
573
+ }
574
+
575
+ /*
576
+ * call-seq:
577
+ * strio.closed_read? -> true or false
578
+ *
579
+ * Returns +true+ if the stream is not readable, +false+ otherwise.
580
+ */
581
+ static VALUE
582
+ strio_closed_read(VALUE self)
583
+ {
584
+ StringIO(self);
585
+ if (READABLE(self)) return Qfalse;
586
+ return Qtrue;
587
+ }
588
+
589
+ /*
590
+ * call-seq:
591
+ * strio.closed_write? -> true or false
592
+ *
593
+ * Returns +true+ if the stream is not writable, +false+ otherwise.
594
+ */
595
+ static VALUE
596
+ strio_closed_write(VALUE self)
597
+ {
598
+ StringIO(self);
599
+ if (WRITABLE(self)) return Qfalse;
600
+ return Qtrue;
601
+ }
602
+
603
+ static struct StringIO *
604
+ strio_to_read(VALUE self)
605
+ {
606
+ struct StringIO *ptr = readable(self);
607
+ if (ptr->pos < RSTRING_LEN(ptr->string)) return ptr;
608
+ return NULL;
609
+ }
610
+
611
+ /*
612
+ * call-seq:
613
+ * strio.eof -> true or false
614
+ * strio.eof? -> true or false
615
+ *
616
+ * Returns true if the stream is at the end of the data (underlying string).
617
+ * The stream must be opened for reading or an +IOError+ will be raised.
618
+ */
619
+ static VALUE
620
+ strio_eof(VALUE self)
621
+ {
622
+ if (strio_to_read(self)) return Qfalse;
623
+ return Qtrue;
624
+ }
625
+
626
+ /* :nodoc: */
627
+ static VALUE
628
+ strio_copy(VALUE copy, VALUE orig)
629
+ {
630
+ struct StringIO *ptr;
631
+
632
+ orig = rb_convert_type(orig, T_DATA, "StringIO", "to_strio");
633
+ if (copy == orig) return copy;
634
+ ptr = StringIO(orig);
635
+ if (check_strio(copy)) {
636
+ strio_free(DATA_PTR(copy));
637
+ }
638
+ DATA_PTR(copy) = ptr;
639
+ RBASIC(copy)->flags &= ~STRIO_READWRITE;
640
+ RBASIC(copy)->flags |= RBASIC(orig)->flags & STRIO_READWRITE;
641
+ ++ptr->count;
642
+ return copy;
643
+ }
644
+
645
+ /*
646
+ * call-seq:
647
+ * strio.lineno -> integer
648
+ *
649
+ * Returns the current line number. The stream must be
650
+ * opened for reading. +lineno+ counts the number of times +gets+ is
651
+ * called, rather than the number of newlines encountered. The two
652
+ * values will differ if +gets+ is called with a separator other than
653
+ * newline. See also the <code>$.</code> variable.
654
+ */
655
+ static VALUE
656
+ strio_get_lineno(VALUE self)
657
+ {
658
+ return LONG2NUM(StringIO(self)->lineno);
659
+ }
660
+
661
+ /*
662
+ * call-seq:
663
+ * strio.lineno = integer -> integer
664
+ *
665
+ * Manually sets the current line number to the given value.
666
+ * <code>$.</code> is updated only on the next read.
667
+ */
668
+ static VALUE
669
+ strio_set_lineno(VALUE self, VALUE lineno)
670
+ {
671
+ StringIO(self)->lineno = NUM2LONG(lineno);
672
+ return lineno;
673
+ }
674
+
675
+ /*
676
+ * call-seq:
677
+ * strio.binmode -> stringio
678
+ *
679
+ * Puts stream into binary mode. See IO#binmode.
680
+ *
681
+ */
682
+ static VALUE
683
+ strio_binmode(VALUE self)
684
+ {
685
+ struct StringIO *ptr = StringIO(self);
686
+ rb_encoding *enc = rb_ascii8bit_encoding();
687
+
688
+ ptr->enc = enc;
689
+ if (WRITABLE(self)) {
690
+ rb_enc_associate(ptr->string, enc);
691
+ }
692
+ return self;
693
+ }
694
+
695
+ #define strio_fcntl strio_unimpl
696
+
697
+ #define strio_flush strio_self
698
+
699
+ #define strio_fsync strio_0
700
+
701
+ /*
702
+ * call-seq:
703
+ * strio.reopen(other_StrIO) -> strio
704
+ * strio.reopen(string, mode) -> strio
705
+ *
706
+ * Reinitializes the stream with the given <i>other_StrIO</i> or _string_
707
+ * and _mode_ (see StringIO#new).
708
+ */
709
+ static VALUE
710
+ strio_reopen(int argc, VALUE *argv, VALUE self)
711
+ {
712
+ rb_io_taint_check(self);
713
+ if (argc == 1 && !RB_TYPE_P(*argv, T_STRING)) {
714
+ return strio_copy(self, *argv);
715
+ }
716
+ return strio_init(argc, argv, StringIO(self), self);
717
+ }
718
+
719
+ /*
720
+ * call-seq:
721
+ * strio.pos -> integer
722
+ * strio.tell -> integer
723
+ *
724
+ * Returns the current offset (in bytes).
725
+ */
726
+ static VALUE
727
+ strio_get_pos(VALUE self)
728
+ {
729
+ return LONG2NUM(StringIO(self)->pos);
730
+ }
731
+
732
+ /*
733
+ * call-seq:
734
+ * strio.pos = integer -> integer
735
+ *
736
+ * Seeks to the given position (in bytes).
737
+ */
738
+ static VALUE
739
+ strio_set_pos(VALUE self, VALUE pos)
740
+ {
741
+ struct StringIO *ptr = StringIO(self);
742
+ long p = NUM2LONG(pos);
743
+ if (p < 0) {
744
+ error_inval(0);
745
+ }
746
+ ptr->pos = p;
747
+ return pos;
748
+ }
749
+
750
+ /*
751
+ * call-seq:
752
+ * strio.rewind -> 0
753
+ *
754
+ * Positions the stream to the beginning of input, resetting
755
+ * +lineno+ to zero.
756
+ */
757
+ static VALUE
758
+ strio_rewind(VALUE self)
759
+ {
760
+ struct StringIO *ptr = StringIO(self);
761
+ ptr->pos = 0;
762
+ ptr->lineno = 0;
763
+ return INT2FIX(0);
764
+ }
765
+
766
+ /*
767
+ * call-seq:
768
+ * strio.seek(amount, whence=SEEK_SET) -> 0
769
+ *
770
+ * Seeks to a given offset _amount_ in the stream according to
771
+ * the value of _whence_ (see IO#seek).
772
+ */
773
+ static VALUE
774
+ strio_seek(int argc, VALUE *argv, VALUE self)
775
+ {
776
+ VALUE whence;
777
+ struct StringIO *ptr = StringIO(self);
778
+ long amount, offset;
779
+
780
+ rb_scan_args(argc, argv, "11", NULL, &whence);
781
+ amount = NUM2LONG(argv[0]);
782
+ if (CLOSED(self)) {
783
+ rb_raise(rb_eIOError, "closed stream");
784
+ }
785
+ switch (NIL_P(whence) ? 0 : NUM2LONG(whence)) {
786
+ case 0:
787
+ offset = 0;
788
+ break;
789
+ case 1:
790
+ offset = ptr->pos;
791
+ break;
792
+ case 2:
793
+ offset = RSTRING_LEN(ptr->string);
794
+ break;
795
+ default:
796
+ error_inval("invalid whence");
797
+ }
798
+ if (amount > LONG_MAX - offset || amount + offset < 0) {
799
+ error_inval(0);
800
+ }
801
+ ptr->pos = amount + offset;
802
+ return INT2FIX(0);
803
+ }
804
+
805
+ /*
806
+ * call-seq:
807
+ * strio.sync -> true
808
+ *
809
+ * Returns +true+ always.
810
+ */
811
+ static VALUE
812
+ strio_get_sync(VALUE self)
813
+ {
814
+ StringIO(self);
815
+ return Qtrue;
816
+ }
817
+
818
+ #define strio_set_sync strio_first
819
+
820
+ #define strio_tell strio_get_pos
821
+
822
+ /*
823
+ * call-seq:
824
+ * strio.each_byte {|byte| block } -> strio
825
+ * strio.each_byte -> anEnumerator
826
+ *
827
+ * See IO#each_byte.
828
+ */
829
+ static VALUE
830
+ strio_each_byte(VALUE self)
831
+ {
832
+ struct StringIO *ptr;
833
+
834
+ RETURN_ENUMERATOR(self, 0, 0);
835
+
836
+ while ((ptr = strio_to_read(self)) != NULL) {
837
+ char c = RSTRING_PTR(ptr->string)[ptr->pos++];
838
+ rb_yield(CHR2FIX(c));
839
+ }
840
+ return self;
841
+ }
842
+
843
+ /*
844
+ * call-seq:
845
+ * strio.getc -> string or nil
846
+ *
847
+ * See IO#getc.
848
+ */
849
+ static VALUE
850
+ strio_getc(VALUE self)
851
+ {
852
+ struct StringIO *ptr = readable(self);
853
+ rb_encoding *enc = get_enc(ptr);
854
+ VALUE str = ptr->string;
855
+ long pos = ptr->pos;
856
+ int len;
857
+ char *p;
858
+
859
+ if (pos >= RSTRING_LEN(str)) {
860
+ return Qnil;
861
+ }
862
+ p = RSTRING_PTR(str)+pos;
863
+ len = rb_enc_mbclen(p, RSTRING_END(str), enc);
864
+ ptr->pos += len;
865
+ return enc_subseq(str, pos, len, enc);
866
+ }
867
+
868
+ /*
869
+ * call-seq:
870
+ * strio.getbyte -> fixnum or nil
871
+ *
872
+ * See IO#getbyte.
873
+ */
874
+ static VALUE
875
+ strio_getbyte(VALUE self)
876
+ {
877
+ struct StringIO *ptr = readable(self);
878
+ int c;
879
+ if (ptr->pos >= RSTRING_LEN(ptr->string)) {
880
+ return Qnil;
881
+ }
882
+ c = RSTRING_PTR(ptr->string)[ptr->pos++];
883
+ return CHR2FIX(c);
884
+ }
885
+
886
+ static void
887
+ strio_extend(struct StringIO *ptr, long pos, long len)
888
+ {
889
+ long olen;
890
+
891
+ if (len > LONG_MAX - pos)
892
+ rb_raise(rb_eArgError, "string size too big");
893
+
894
+ check_modifiable(ptr);
895
+ olen = RSTRING_LEN(ptr->string);
896
+ if (pos + len > olen) {
897
+ rb_str_resize(ptr->string, pos + len);
898
+ if (pos > olen)
899
+ MEMZERO(RSTRING_PTR(ptr->string) + olen, char, pos - olen);
900
+ }
901
+ else {
902
+ rb_str_modify(ptr->string);
903
+ }
904
+ }
905
+
906
+ /*
907
+ * call-seq:
908
+ * strio.ungetc(string) -> nil
909
+ *
910
+ * Pushes back one character (passed as a parameter)
911
+ * such that a subsequent buffered read will return it. There is no
912
+ * limitation for multiple pushbacks including pushing back behind the
913
+ * beginning of the buffer string.
914
+ */
915
+ static VALUE
916
+ strio_ungetc(VALUE self, VALUE c)
917
+ {
918
+ struct StringIO *ptr = readable(self);
919
+ rb_encoding *enc, *enc2;
920
+
921
+ check_modifiable(ptr);
922
+ if (NIL_P(c)) return Qnil;
923
+ if (RB_INTEGER_TYPE_P(c)) {
924
+ int len, cc = NUM2INT(c);
925
+ char buf[16];
926
+
927
+ enc = rb_enc_get(ptr->string);
928
+ len = rb_enc_codelen(cc, enc);
929
+ if (len <= 0) rb_enc_uint_chr(cc, enc);
930
+ rb_enc_mbcput(cc, buf, enc);
931
+ return strio_unget_bytes(ptr, buf, len);
932
+ }
933
+ else {
934
+ SafeStringValue(c);
935
+ enc = rb_enc_get(ptr->string);
936
+ enc2 = rb_enc_get(c);
937
+ if (enc != enc2 && enc != rb_ascii8bit_encoding()) {
938
+ c = rb_str_conv_enc(c, enc2, enc);
939
+ }
940
+ strio_unget_bytes(ptr, RSTRING_PTR(c), RSTRING_LEN(c));
941
+ RB_GC_GUARD(c);
942
+ return Qnil;
943
+ }
944
+ }
945
+
946
+ /*
947
+ * call-seq:
948
+ * strio.ungetbyte(fixnum) -> nil
949
+ *
950
+ * See IO#ungetbyte
951
+ */
952
+ static VALUE
953
+ strio_ungetbyte(VALUE self, VALUE c)
954
+ {
955
+ struct StringIO *ptr = readable(self);
956
+
957
+ check_modifiable(ptr);
958
+ if (NIL_P(c)) return Qnil;
959
+ if (RB_INTEGER_TYPE_P(c)) {
960
+ /* rb_int_and() not visible from exts */
961
+ VALUE v = rb_funcall(c, '&', 1, INT2FIX(0xff));
962
+ const char cc = NUM2INT(v) & 0xFF;
963
+ strio_unget_bytes(ptr, &cc, 1);
964
+ }
965
+ else {
966
+ long cl;
967
+ SafeStringValue(c);
968
+ cl = RSTRING_LEN(c);
969
+ if (cl > 0) {
970
+ strio_unget_bytes(ptr, RSTRING_PTR(c), cl);
971
+ RB_GC_GUARD(c);
972
+ }
973
+ }
974
+ return Qnil;
975
+ }
976
+
977
+ static VALUE
978
+ strio_unget_bytes(struct StringIO *ptr, const char *cp, long cl)
979
+ {
980
+ long pos = ptr->pos, len, rest;
981
+ VALUE str = ptr->string;
982
+ char *s;
983
+
984
+ len = RSTRING_LEN(str);
985
+ rest = pos - len;
986
+ if (cl > pos) {
987
+ long ex = (rest < 0 ? cl-pos : cl+rest);
988
+ rb_str_modify_expand(str, ex);
989
+ rb_str_set_len(str, len + ex);
990
+ s = RSTRING_PTR(str);
991
+ if (rest < 0) memmove(s + cl, s + pos, -rest);
992
+ pos = 0;
993
+ }
994
+ else {
995
+ if (rest > 0) {
996
+ rb_str_modify_expand(str, rest);
997
+ rb_str_set_len(str, len + rest);
998
+ }
999
+ s = RSTRING_PTR(str);
1000
+ if (rest > cl) memset(s + len, 0, rest - cl);
1001
+ pos -= cl;
1002
+ }
1003
+ memcpy(s + pos, cp, cl);
1004
+ ptr->pos = pos;
1005
+ return Qnil;
1006
+ }
1007
+
1008
+ /*
1009
+ * call-seq:
1010
+ * strio.readchar -> string
1011
+ *
1012
+ * See IO#readchar.
1013
+ */
1014
+ static VALUE
1015
+ strio_readchar(VALUE self)
1016
+ {
1017
+ VALUE c = rb_funcallv(self, rb_intern("getc"), 0, 0);
1018
+ if (NIL_P(c)) rb_eof_error();
1019
+ return c;
1020
+ }
1021
+
1022
+ /*
1023
+ * call-seq:
1024
+ * strio.readbyte -> fixnum
1025
+ *
1026
+ * See IO#readbyte.
1027
+ */
1028
+ static VALUE
1029
+ strio_readbyte(VALUE self)
1030
+ {
1031
+ VALUE c = rb_funcallv(self, rb_intern("getbyte"), 0, 0);
1032
+ if (NIL_P(c)) rb_eof_error();
1033
+ return c;
1034
+ }
1035
+
1036
+ /*
1037
+ * call-seq:
1038
+ * strio.each_char {|char| block } -> strio
1039
+ * strio.each_char -> anEnumerator
1040
+ *
1041
+ * See IO#each_char.
1042
+ */
1043
+ static VALUE
1044
+ strio_each_char(VALUE self)
1045
+ {
1046
+ VALUE c;
1047
+
1048
+ RETURN_ENUMERATOR(self, 0, 0);
1049
+
1050
+ while (!NIL_P(c = strio_getc(self))) {
1051
+ rb_yield(c);
1052
+ }
1053
+ return self;
1054
+ }
1055
+
1056
+ /*
1057
+ * call-seq:
1058
+ * strio.each_codepoint {|c| block } -> strio
1059
+ * strio.each_codepoint -> anEnumerator
1060
+ *
1061
+ * See IO#each_codepoint.
1062
+ */
1063
+ static VALUE
1064
+ strio_each_codepoint(VALUE self)
1065
+ {
1066
+ struct StringIO *ptr;
1067
+ rb_encoding *enc;
1068
+ unsigned int c;
1069
+ int n;
1070
+
1071
+ RETURN_ENUMERATOR(self, 0, 0);
1072
+
1073
+ ptr = readable(self);
1074
+ enc = get_enc(ptr);
1075
+ while ((ptr = strio_to_read(self)) != NULL) {
1076
+ c = rb_enc_codepoint_len(RSTRING_PTR(ptr->string)+ptr->pos,
1077
+ RSTRING_END(ptr->string), &n, enc);
1078
+ ptr->pos += n;
1079
+ rb_yield(UINT2NUM(c));
1080
+ }
1081
+ return self;
1082
+ }
1083
+
1084
+ /* Boyer-Moore search: copied from regex.c */
1085
+ static void
1086
+ bm_init_skip(long *skip, const char *pat, long m)
1087
+ {
1088
+ int c;
1089
+
1090
+ for (c = 0; c < (1 << CHAR_BIT); c++) {
1091
+ skip[c] = m;
1092
+ }
1093
+ while (--m) {
1094
+ skip[(unsigned char)*pat++] = m;
1095
+ }
1096
+ }
1097
+
1098
+ static long
1099
+ bm_search(const char *little, long llen, const char *big, long blen, const long *skip)
1100
+ {
1101
+ long i, j, k;
1102
+
1103
+ i = llen - 1;
1104
+ while (i < blen) {
1105
+ k = i;
1106
+ j = llen - 1;
1107
+ while (j >= 0 && big[k] == little[j]) {
1108
+ k--;
1109
+ j--;
1110
+ }
1111
+ if (j < 0) return k + 1;
1112
+ i += skip[(unsigned char)big[i]];
1113
+ }
1114
+ return -1;
1115
+ }
1116
+
1117
+ struct getline_arg {
1118
+ VALUE rs;
1119
+ long limit;
1120
+ unsigned int chomp: 1;
1121
+ };
1122
+
1123
+ static struct getline_arg *
1124
+ prepare_getline_args(struct getline_arg *arg, int argc, VALUE *argv)
1125
+ {
1126
+ VALUE str, lim, opts;
1127
+ long limit = -1;
1128
+
1129
+ argc = rb_scan_args(argc, argv, "02:", &str, &lim, &opts);
1130
+ switch (argc) {
1131
+ case 0:
1132
+ str = rb_rs;
1133
+ break;
1134
+
1135
+ case 1:
1136
+ if (!NIL_P(str) && !RB_TYPE_P(str, T_STRING)) {
1137
+ VALUE tmp = rb_check_string_type(str);
1138
+ if (NIL_P(tmp)) {
1139
+ limit = NUM2LONG(str);
1140
+ str = rb_rs;
1141
+ }
1142
+ else {
1143
+ str = tmp;
1144
+ }
1145
+ }
1146
+ break;
1147
+
1148
+ case 2:
1149
+ if (!NIL_P(str)) StringValue(str);
1150
+ if (!NIL_P(lim)) limit = NUM2LONG(lim);
1151
+ break;
1152
+ }
1153
+ arg->rs = str;
1154
+ arg->limit = limit;
1155
+ arg->chomp = 0;
1156
+ if (!NIL_P(opts)) {
1157
+ static ID keywords[1];
1158
+ VALUE vchomp;
1159
+ if (!keywords[0]) {
1160
+ keywords[0] = rb_intern_const("chomp");
1161
+ }
1162
+ rb_get_kwargs(opts, keywords, 0, 1, &vchomp);
1163
+ arg->chomp = (vchomp != Qundef) && RTEST(vchomp);
1164
+ }
1165
+ return arg;
1166
+ }
1167
+
1168
+ static inline int
1169
+ chomp_newline_width(const char *s, const char *e)
1170
+ {
1171
+ if (e > s && *--e == '\n') {
1172
+ if (e > s && *--e == '\r') return 2;
1173
+ return 1;
1174
+ }
1175
+ return 0;
1176
+ }
1177
+
1178
+ static VALUE
1179
+ strio_getline(struct getline_arg *arg, struct StringIO *ptr)
1180
+ {
1181
+ const char *s, *e, *p;
1182
+ long n, limit = arg->limit;
1183
+ VALUE str = arg->rs;
1184
+ int w = 0;
1185
+ rb_encoding *enc = get_enc(ptr);
1186
+
1187
+ if (ptr->pos >= (n = RSTRING_LEN(ptr->string))) {
1188
+ return Qnil;
1189
+ }
1190
+ s = RSTRING_PTR(ptr->string);
1191
+ e = s + RSTRING_LEN(ptr->string);
1192
+ s += ptr->pos;
1193
+ if (limit > 0 && (size_t)limit < (size_t)(e - s)) {
1194
+ e = rb_enc_right_char_head(s, s + limit, e, get_enc(ptr));
1195
+ }
1196
+ if (NIL_P(str)) {
1197
+ if (arg->chomp) {
1198
+ w = chomp_newline_width(s, e);
1199
+ }
1200
+ str = strio_substr(ptr, ptr->pos, e - s - w, enc);
1201
+ }
1202
+ else if ((n = RSTRING_LEN(str)) == 0) {
1203
+ p = s;
1204
+ while (p[(p + 1 < e) && (*p == '\r') && 0] == '\n') {
1205
+ p += *p == '\r';
1206
+ if (++p == e) {
1207
+ return Qnil;
1208
+ }
1209
+ }
1210
+ s = p;
1211
+ while ((p = memchr(p, '\n', e - p)) && (p != e)) {
1212
+ if (*++p == '\n') {
1213
+ e = p + 1;
1214
+ w = (arg->chomp ? 1 : 0);
1215
+ break;
1216
+ }
1217
+ else if (*p == '\r' && p < e && p[1] == '\n') {
1218
+ e = p + 2;
1219
+ w = (arg->chomp ? 2 : 0);
1220
+ break;
1221
+ }
1222
+ }
1223
+ if (!w && arg->chomp) {
1224
+ w = chomp_newline_width(s, e);
1225
+ }
1226
+ str = strio_substr(ptr, s - RSTRING_PTR(ptr->string), e - s - w, enc);
1227
+ }
1228
+ else if (n == 1) {
1229
+ if ((p = memchr(s, RSTRING_PTR(str)[0], e - s)) != 0) {
1230
+ e = p + 1;
1231
+ w = (arg->chomp ? (p > s && *(p-1) == '\r') + 1 : 0);
1232
+ }
1233
+ str = strio_substr(ptr, ptr->pos, e - s - w, enc);
1234
+ }
1235
+ else {
1236
+ if (n < e - s) {
1237
+ if (e - s < 1024) {
1238
+ for (p = s; p + n <= e; ++p) {
1239
+ if (MEMCMP(p, RSTRING_PTR(str), char, n) == 0) {
1240
+ e = p + (arg->chomp ? 0 : n);
1241
+ break;
1242
+ }
1243
+ }
1244
+ }
1245
+ else {
1246
+ long skip[1 << CHAR_BIT], pos;
1247
+ p = RSTRING_PTR(str);
1248
+ bm_init_skip(skip, p, n);
1249
+ if ((pos = bm_search(p, n, s, e - s, skip)) >= 0) {
1250
+ e = s + pos + (arg->chomp ? 0 : n);
1251
+ }
1252
+ }
1253
+ }
1254
+ str = strio_substr(ptr, ptr->pos, e - s - w, enc);
1255
+ }
1256
+ ptr->pos = e - RSTRING_PTR(ptr->string);
1257
+ ptr->lineno++;
1258
+ return str;
1259
+ }
1260
+
1261
+ /*
1262
+ * call-seq:
1263
+ * strio.gets(sep=$/, chomp: false) -> string or nil
1264
+ * strio.gets(limit, chomp: false) -> string or nil
1265
+ * strio.gets(sep, limit, chomp: false) -> string or nil
1266
+ *
1267
+ * See IO#gets.
1268
+ */
1269
+ static VALUE
1270
+ strio_gets(int argc, VALUE *argv, VALUE self)
1271
+ {
1272
+ struct getline_arg arg;
1273
+ VALUE str;
1274
+
1275
+ if (prepare_getline_args(&arg, argc, argv)->limit == 0) {
1276
+ struct StringIO *ptr = readable(self);
1277
+ return rb_enc_str_new(0, 0, get_enc(ptr));
1278
+ }
1279
+
1280
+ str = strio_getline(&arg, readable(self));
1281
+ rb_lastline_set(str);
1282
+ return str;
1283
+ }
1284
+
1285
+ /*
1286
+ * call-seq:
1287
+ * strio.readline(sep=$/, chomp: false) -> string
1288
+ * strio.readline(limit, chomp: false) -> string or nil
1289
+ * strio.readline(sep, limit, chomp: false) -> string or nil
1290
+ *
1291
+ * See IO#readline.
1292
+ */
1293
+ static VALUE
1294
+ strio_readline(int argc, VALUE *argv, VALUE self)
1295
+ {
1296
+ VALUE line = rb_funcallv_kw(self, rb_intern("gets"), argc, argv, RB_PASS_CALLED_KEYWORDS);
1297
+ if (NIL_P(line)) rb_eof_error();
1298
+ return line;
1299
+ }
1300
+
1301
+ /*
1302
+ * call-seq:
1303
+ * strio.each(sep=$/, chomp: false) {|line| block } -> strio
1304
+ * strio.each(limit, chomp: false) {|line| block } -> strio
1305
+ * strio.each(sep, limit, chomp: false) {|line| block } -> strio
1306
+ * strio.each(...) -> anEnumerator
1307
+ *
1308
+ * strio.each_line(sep=$/, chomp: false) {|line| block } -> strio
1309
+ * strio.each_line(limit, chomp: false) {|line| block } -> strio
1310
+ * strio.each_line(sep, limit, chomp: false) {|line| block } -> strio
1311
+ * strio.each_line(...) -> anEnumerator
1312
+ *
1313
+ * See IO#each.
1314
+ */
1315
+ static VALUE
1316
+ strio_each(int argc, VALUE *argv, VALUE self)
1317
+ {
1318
+ VALUE line;
1319
+ struct getline_arg arg;
1320
+
1321
+ StringIO(self);
1322
+ RETURN_ENUMERATOR(self, argc, argv);
1323
+
1324
+ if (prepare_getline_args(&arg, argc, argv)->limit == 0) {
1325
+ rb_raise(rb_eArgError, "invalid limit: 0 for each_line");
1326
+ }
1327
+
1328
+ while (!NIL_P(line = strio_getline(&arg, readable(self)))) {
1329
+ rb_yield(line);
1330
+ }
1331
+ return self;
1332
+ }
1333
+
1334
+ /*
1335
+ * call-seq:
1336
+ * strio.readlines(sep=$/, chomp: false) -> array
1337
+ * strio.readlines(limit, chomp: false) -> array
1338
+ * strio.readlines(sep, limit, chomp: false) -> array
1339
+ *
1340
+ * See IO#readlines.
1341
+ */
1342
+ static VALUE
1343
+ strio_readlines(int argc, VALUE *argv, VALUE self)
1344
+ {
1345
+ VALUE ary, line;
1346
+ struct getline_arg arg;
1347
+
1348
+ StringIO(self);
1349
+ ary = rb_ary_new();
1350
+ if (prepare_getline_args(&arg, argc, argv)->limit == 0) {
1351
+ rb_raise(rb_eArgError, "invalid limit: 0 for readlines");
1352
+ }
1353
+
1354
+ while (!NIL_P(line = strio_getline(&arg, readable(self)))) {
1355
+ rb_ary_push(ary, line);
1356
+ }
1357
+ return ary;
1358
+ }
1359
+
1360
+ /*
1361
+ * call-seq:
1362
+ * strio.write(string, ...) -> integer
1363
+ * strio.syswrite(string) -> integer
1364
+ *
1365
+ * Appends the given string to the underlying buffer string.
1366
+ * The stream must be opened for writing. If the argument is not a
1367
+ * string, it will be converted to a string using <code>to_s</code>.
1368
+ * Returns the number of bytes written. See IO#write.
1369
+ */
1370
+ static VALUE
1371
+ strio_write_m(int argc, VALUE *argv, VALUE self)
1372
+ {
1373
+ long len = 0;
1374
+ while (argc-- > 0) {
1375
+ /* StringIO can't exceed long limit */
1376
+ len += strio_write(self, *argv++);
1377
+ }
1378
+ return LONG2NUM(len);
1379
+ }
1380
+
1381
+ static long
1382
+ strio_write(VALUE self, VALUE str)
1383
+ {
1384
+ struct StringIO *ptr = writable(self);
1385
+ long len, olen;
1386
+ rb_encoding *enc, *enc2;
1387
+ rb_encoding *const ascii8bit = rb_ascii8bit_encoding();
1388
+ rb_encoding *usascii = 0;
1389
+
1390
+ if (!RB_TYPE_P(str, T_STRING))
1391
+ str = rb_obj_as_string(str);
1392
+ enc = get_enc(ptr);
1393
+ enc2 = rb_enc_get(str);
1394
+ if (enc != enc2 && enc != ascii8bit && enc != (usascii = rb_usascii_encoding())) {
1395
+ VALUE converted = rb_str_conv_enc(str, enc2, enc);
1396
+ if (converted == str && enc2 != ascii8bit && enc2 != usascii) { /* conversion failed */
1397
+ rb_enc_check(rb_enc_from_encoding(enc), str);
1398
+ }
1399
+ str = converted;
1400
+ }
1401
+ len = RSTRING_LEN(str);
1402
+ if (len == 0) return 0;
1403
+ check_modifiable(ptr);
1404
+ olen = RSTRING_LEN(ptr->string);
1405
+ if (ptr->flags & FMODE_APPEND) {
1406
+ ptr->pos = olen;
1407
+ }
1408
+ if (ptr->pos == olen) {
1409
+ if (enc == ascii8bit || enc2 == ascii8bit) {
1410
+ rb_enc_str_buf_cat(ptr->string, RSTRING_PTR(str), len, enc);
1411
+ }
1412
+ else {
1413
+ rb_str_buf_append(ptr->string, str);
1414
+ }
1415
+ }
1416
+ else {
1417
+ strio_extend(ptr, ptr->pos, len);
1418
+ memmove(RSTRING_PTR(ptr->string)+ptr->pos, RSTRING_PTR(str), len);
1419
+ }
1420
+ RB_GC_GUARD(str);
1421
+ ptr->pos += len;
1422
+ return len;
1423
+ }
1424
+
1425
+ /*
1426
+ * call-seq:
1427
+ * strio << obj -> strio
1428
+ *
1429
+ * See IO#<<.
1430
+ */
1431
+ #define strio_addstr rb_io_addstr
1432
+
1433
+ /*
1434
+ * call-seq:
1435
+ * strio.print() -> nil
1436
+ * strio.print(obj, ...) -> nil
1437
+ *
1438
+ * See IO#print.
1439
+ */
1440
+ #define strio_print rb_io_print
1441
+
1442
+ /*
1443
+ * call-seq:
1444
+ * strio.printf(format_string [, obj, ...] ) -> nil
1445
+ *
1446
+ * See IO#printf.
1447
+ */
1448
+ #define strio_printf rb_io_printf
1449
+
1450
+ /*
1451
+ * call-seq:
1452
+ * strio.putc(obj) -> obj
1453
+ *
1454
+ * See IO#putc.
1455
+ */
1456
+ static VALUE
1457
+ strio_putc(VALUE self, VALUE ch)
1458
+ {
1459
+ struct StringIO *ptr = writable(self);
1460
+ VALUE str;
1461
+
1462
+ check_modifiable(ptr);
1463
+ if (RB_TYPE_P(ch, T_STRING)) {
1464
+ str = rb_str_substr(ch, 0, 1);
1465
+ }
1466
+ else {
1467
+ char c = NUM2CHR(ch);
1468
+ str = rb_str_new(&c, 1);
1469
+ }
1470
+ strio_write(self, str);
1471
+ return ch;
1472
+ }
1473
+
1474
+ /*
1475
+ * call-seq:
1476
+ * strio.puts(obj, ...) -> nil
1477
+ *
1478
+ * See IO#puts.
1479
+ */
1480
+ #define strio_puts rb_io_puts
1481
+
1482
+ /*
1483
+ * call-seq:
1484
+ * strio.read([length [, outbuf]]) -> string, outbuf, or nil
1485
+ *
1486
+ * See IO#read.
1487
+ */
1488
+ static VALUE
1489
+ strio_read(int argc, VALUE *argv, VALUE self)
1490
+ {
1491
+ struct StringIO *ptr = readable(self);
1492
+ VALUE str = Qnil;
1493
+ long len;
1494
+ int binary = 0;
1495
+
1496
+ switch (argc) {
1497
+ case 2:
1498
+ str = argv[1];
1499
+ if (!NIL_P(str)) {
1500
+ StringValue(str);
1501
+ rb_str_modify(str);
1502
+ }
1503
+ /* fall through */
1504
+ case 1:
1505
+ if (!NIL_P(argv[0])) {
1506
+ len = NUM2LONG(argv[0]);
1507
+ if (len < 0) {
1508
+ rb_raise(rb_eArgError, "negative length %ld given", len);
1509
+ }
1510
+ if (len > 0 && ptr->pos >= RSTRING_LEN(ptr->string)) {
1511
+ if (!NIL_P(str)) rb_str_resize(str, 0);
1512
+ return Qnil;
1513
+ }
1514
+ binary = 1;
1515
+ break;
1516
+ }
1517
+ /* fall through */
1518
+ case 0:
1519
+ len = RSTRING_LEN(ptr->string);
1520
+ if (len <= ptr->pos) {
1521
+ rb_encoding *enc = get_enc(ptr);
1522
+ if (NIL_P(str)) {
1523
+ str = rb_str_new(0, 0);
1524
+ }
1525
+ else {
1526
+ rb_str_resize(str, 0);
1527
+ }
1528
+ rb_enc_associate(str, enc);
1529
+ return str;
1530
+ }
1531
+ else {
1532
+ len -= ptr->pos;
1533
+ }
1534
+ break;
1535
+ default:
1536
+ rb_error_arity(argc, 0, 2);
1537
+ }
1538
+ if (NIL_P(str)) {
1539
+ rb_encoding *enc = binary ? rb_ascii8bit_encoding() : get_enc(ptr);
1540
+ str = strio_substr(ptr, ptr->pos, len, enc);
1541
+ }
1542
+ else {
1543
+ long rest = RSTRING_LEN(ptr->string) - ptr->pos;
1544
+ if (len > rest) len = rest;
1545
+ rb_str_resize(str, len);
1546
+ MEMCPY(RSTRING_PTR(str), RSTRING_PTR(ptr->string) + ptr->pos, char, len);
1547
+ if (binary)
1548
+ rb_enc_associate(str, rb_ascii8bit_encoding());
1549
+ else
1550
+ rb_enc_copy(str, ptr->string);
1551
+ }
1552
+ ptr->pos += RSTRING_LEN(str);
1553
+ return str;
1554
+ }
1555
+
1556
+ /*
1557
+ * call-seq:
1558
+ * strio.sysread(integer[, outbuf]) -> string
1559
+ * strio.readpartial(integer[, outbuf]) -> string
1560
+ *
1561
+ * Similar to #read, but raises +EOFError+ at end of string instead of
1562
+ * returning +nil+, as well as IO#sysread does.
1563
+ */
1564
+ static VALUE
1565
+ strio_sysread(int argc, VALUE *argv, VALUE self)
1566
+ {
1567
+ VALUE val = rb_funcallv_kw(self, rb_intern("read"), argc, argv, RB_PASS_CALLED_KEYWORDS);
1568
+ if (NIL_P(val)) {
1569
+ rb_eof_error();
1570
+ }
1571
+ return val;
1572
+ }
1573
+
1574
+ /*
1575
+ * call-seq:
1576
+ * strio.read_nonblock(integer[, outbuf [, opts]]) -> string
1577
+ *
1578
+ * Similar to #read, but raises +EOFError+ at end of string unless the
1579
+ * +exception: false+ option is passed in.
1580
+ */
1581
+ static VALUE
1582
+ strio_read_nonblock(int argc, VALUE *argv, VALUE self)
1583
+ {
1584
+ VALUE opts = Qnil, val;
1585
+
1586
+ rb_scan_args(argc, argv, "11:", NULL, NULL, &opts);
1587
+
1588
+ if (!NIL_P(opts)) {
1589
+ argc--;
1590
+ }
1591
+
1592
+ val = strio_read(argc, argv, self);
1593
+ if (NIL_P(val)) {
1594
+ if (!NIL_P(opts) &&
1595
+ rb_hash_lookup2(opts, sym_exception, Qundef) == Qfalse)
1596
+ return Qnil;
1597
+ else
1598
+ rb_eof_error();
1599
+ }
1600
+
1601
+ return val;
1602
+ }
1603
+
1604
+ #define strio_syswrite rb_io_write
1605
+
1606
+ static VALUE
1607
+ strio_syswrite_nonblock(int argc, VALUE *argv, VALUE self)
1608
+ {
1609
+ VALUE str;
1610
+
1611
+ rb_scan_args(argc, argv, "10:", &str, NULL);
1612
+ return strio_syswrite(self, str);
1613
+ }
1614
+
1615
+ #define strio_isatty strio_false
1616
+
1617
+ #define strio_pid strio_nil
1618
+
1619
+ #define strio_fileno strio_nil
1620
+
1621
+ /*
1622
+ * call-seq:
1623
+ * strio.length -> integer
1624
+ * strio.size -> integer
1625
+ *
1626
+ * Returns the size of the buffer string.
1627
+ */
1628
+ static VALUE
1629
+ strio_size(VALUE self)
1630
+ {
1631
+ VALUE string = StringIO(self)->string;
1632
+ if (NIL_P(string)) {
1633
+ rb_raise(rb_eIOError, "not opened");
1634
+ }
1635
+ return ULONG2NUM(RSTRING_LEN(string));
1636
+ }
1637
+
1638
+ /*
1639
+ * call-seq:
1640
+ * strio.truncate(integer) -> 0
1641
+ *
1642
+ * Truncates the buffer string to at most _integer_ bytes. The stream
1643
+ * must be opened for writing.
1644
+ */
1645
+ static VALUE
1646
+ strio_truncate(VALUE self, VALUE len)
1647
+ {
1648
+ VALUE string = writable(self)->string;
1649
+ long l = NUM2LONG(len);
1650
+ long plen = RSTRING_LEN(string);
1651
+ if (l < 0) {
1652
+ error_inval("negative length");
1653
+ }
1654
+ rb_str_resize(string, l);
1655
+ if (plen < l) {
1656
+ MEMZERO(RSTRING_PTR(string) + plen, char, l - plen);
1657
+ }
1658
+ return len;
1659
+ }
1660
+
1661
+ /*
1662
+ * call-seq:
1663
+ * strio.external_encoding => encoding
1664
+ *
1665
+ * Returns the Encoding object that represents the encoding of the file.
1666
+ * If the stream is write mode and no encoding is specified, returns
1667
+ * +nil+.
1668
+ */
1669
+
1670
+ static VALUE
1671
+ strio_external_encoding(VALUE self)
1672
+ {
1673
+ struct StringIO *ptr = StringIO(self);
1674
+ return rb_enc_from_encoding(get_enc(ptr));
1675
+ }
1676
+
1677
+ /*
1678
+ * call-seq:
1679
+ * strio.internal_encoding => encoding
1680
+ *
1681
+ * Returns the Encoding of the internal string if conversion is
1682
+ * specified. Otherwise returns +nil+.
1683
+ */
1684
+
1685
+ static VALUE
1686
+ strio_internal_encoding(VALUE self)
1687
+ {
1688
+ return Qnil;
1689
+ }
1690
+
1691
+ /*
1692
+ * call-seq:
1693
+ * strio.set_encoding(ext_enc, [int_enc[, opt]]) => strio
1694
+ *
1695
+ * Specify the encoding of the StringIO as <i>ext_enc</i>.
1696
+ * Use the default external encoding if <i>ext_enc</i> is nil.
1697
+ * 2nd argument <i>int_enc</i> and optional hash <i>opt</i> argument
1698
+ * are ignored; they are for API compatibility to IO.
1699
+ */
1700
+
1701
+ static VALUE
1702
+ strio_set_encoding(int argc, VALUE *argv, VALUE self)
1703
+ {
1704
+ rb_encoding* enc;
1705
+ struct StringIO *ptr = StringIO(self);
1706
+ VALUE ext_enc, int_enc, opt;
1707
+
1708
+ argc = rb_scan_args(argc, argv, "11:", &ext_enc, &int_enc, &opt);
1709
+
1710
+ if (NIL_P(ext_enc)) {
1711
+ enc = rb_default_external_encoding();
1712
+ }
1713
+ else {
1714
+ enc = rb_to_encoding(ext_enc);
1715
+ }
1716
+ ptr->enc = enc;
1717
+ if (WRITABLE(self)) {
1718
+ rb_enc_associate(ptr->string, enc);
1719
+ }
1720
+
1721
+ return self;
1722
+ }
1723
+
1724
+ static VALUE
1725
+ strio_set_encoding_by_bom(VALUE self)
1726
+ {
1727
+ struct StringIO *ptr = StringIO(self);
1728
+
1729
+ if (!set_encoding_by_bom(ptr)) return Qnil;
1730
+ return rb_enc_from_encoding(ptr->enc);
1731
+ }
1732
+
1733
+ /*
1734
+ * Pseudo I/O on String object, with interface corresponding to IO.
1735
+ *
1736
+ * Commonly used to simulate <code>$stdio</code> or <code>$stderr</code>
1737
+ *
1738
+ * === Examples
1739
+ *
1740
+ * require 'stringio'
1741
+ *
1742
+ * # Writing stream emulation
1743
+ * io = StringIO.new
1744
+ * io.puts "Hello World"
1745
+ * io.string #=> "Hello World\n"
1746
+ *
1747
+ * # Reading stream emulation
1748
+ * io = StringIO.new "first\nsecond\nlast\n"
1749
+ * io.getc #=> "f"
1750
+ * io.gets #=> "irst\n"
1751
+ * io.read #=> "second\nlast\n"
1752
+ */
1753
+ void
1754
+ Init_stringio(void)
1755
+ {
1756
+ #undef rb_intern
1757
+
1758
+ #ifdef HAVE_RB_EXT_RACTOR_SAFE
1759
+ rb_ext_ractor_safe(true);
1760
+ #endif
1761
+
1762
+ VALUE StringIO = rb_define_class("StringIO", rb_cObject);
1763
+
1764
+ rb_define_const(StringIO, "VERSION", rb_str_new_cstr(STRINGIO_VERSION));
1765
+
1766
+ rb_include_module(StringIO, rb_mEnumerable);
1767
+ rb_define_alloc_func(StringIO, strio_s_allocate);
1768
+ rb_define_singleton_method(StringIO, "new", strio_s_new, -1);
1769
+ rb_define_singleton_method(StringIO, "open", strio_s_open, -1);
1770
+ rb_define_method(StringIO, "initialize", strio_initialize, -1);
1771
+ rb_define_method(StringIO, "initialize_copy", strio_copy, 1);
1772
+ rb_define_method(StringIO, "reopen", strio_reopen, -1);
1773
+
1774
+ rb_define_method(StringIO, "string", strio_get_string, 0);
1775
+ rb_define_method(StringIO, "string=", strio_set_string, 1);
1776
+ rb_define_method(StringIO, "lineno", strio_get_lineno, 0);
1777
+ rb_define_method(StringIO, "lineno=", strio_set_lineno, 1);
1778
+
1779
+
1780
+ /* call-seq: strio.binmode -> true */
1781
+ rb_define_method(StringIO, "binmode", strio_binmode, 0);
1782
+ rb_define_method(StringIO, "close", strio_close, 0);
1783
+ rb_define_method(StringIO, "close_read", strio_close_read, 0);
1784
+ rb_define_method(StringIO, "close_write", strio_close_write, 0);
1785
+ rb_define_method(StringIO, "closed?", strio_closed, 0);
1786
+ rb_define_method(StringIO, "closed_read?", strio_closed_read, 0);
1787
+ rb_define_method(StringIO, "closed_write?", strio_closed_write, 0);
1788
+ rb_define_method(StringIO, "eof", strio_eof, 0);
1789
+ rb_define_method(StringIO, "eof?", strio_eof, 0);
1790
+ /* call-seq: strio.fcntl */
1791
+ rb_define_method(StringIO, "fcntl", strio_fcntl, -1);
1792
+ /* call-seq: strio.flush -> strio */
1793
+ rb_define_method(StringIO, "flush", strio_flush, 0);
1794
+ /* call-seq: strio.fsync -> 0 */
1795
+ rb_define_method(StringIO, "fsync", strio_fsync, 0);
1796
+ rb_define_method(StringIO, "pos", strio_get_pos, 0);
1797
+ rb_define_method(StringIO, "pos=", strio_set_pos, 1);
1798
+ rb_define_method(StringIO, "rewind", strio_rewind, 0);
1799
+ rb_define_method(StringIO, "seek", strio_seek, -1);
1800
+ rb_define_method(StringIO, "sync", strio_get_sync, 0);
1801
+ /* call-seq: strio.sync = boolean -> boolean */
1802
+ rb_define_method(StringIO, "sync=", strio_set_sync, 1);
1803
+ rb_define_method(StringIO, "tell", strio_tell, 0);
1804
+
1805
+ rb_define_method(StringIO, "each", strio_each, -1);
1806
+ rb_define_method(StringIO, "each_line", strio_each, -1);
1807
+ rb_define_method(StringIO, "each_byte", strio_each_byte, 0);
1808
+ rb_define_method(StringIO, "each_char", strio_each_char, 0);
1809
+ rb_define_method(StringIO, "each_codepoint", strio_each_codepoint, 0);
1810
+ rb_define_method(StringIO, "getc", strio_getc, 0);
1811
+ rb_define_method(StringIO, "ungetc", strio_ungetc, 1);
1812
+ rb_define_method(StringIO, "ungetbyte", strio_ungetbyte, 1);
1813
+ rb_define_method(StringIO, "getbyte", strio_getbyte, 0);
1814
+ rb_define_method(StringIO, "gets", strio_gets, -1);
1815
+ rb_define_method(StringIO, "readlines", strio_readlines, -1);
1816
+ rb_define_method(StringIO, "read", strio_read, -1);
1817
+
1818
+ rb_define_method(StringIO, "write", strio_write_m, -1);
1819
+ rb_define_method(StringIO, "putc", strio_putc, 1);
1820
+
1821
+ /*
1822
+ * call-seq:
1823
+ * strio.isatty -> nil
1824
+ * strio.tty? -> nil
1825
+ *
1826
+ */
1827
+ rb_define_method(StringIO, "isatty", strio_isatty, 0);
1828
+ rb_define_method(StringIO, "tty?", strio_isatty, 0);
1829
+
1830
+ /* call-seq: strio.pid -> nil */
1831
+ rb_define_method(StringIO, "pid", strio_pid, 0);
1832
+
1833
+ /* call-seq: strio.fileno -> nil */
1834
+ rb_define_method(StringIO, "fileno", strio_fileno, 0);
1835
+ rb_define_method(StringIO, "size", strio_size, 0);
1836
+ rb_define_method(StringIO, "length", strio_size, 0);
1837
+ rb_define_method(StringIO, "truncate", strio_truncate, 1);
1838
+
1839
+ rb_define_method(StringIO, "external_encoding", strio_external_encoding, 0);
1840
+ rb_define_method(StringIO, "internal_encoding", strio_internal_encoding, 0);
1841
+ rb_define_method(StringIO, "set_encoding", strio_set_encoding, -1);
1842
+ rb_define_method(StringIO, "set_encoding_by_bom", strio_set_encoding_by_bom, 0);
1843
+
1844
+ {
1845
+ VALUE mReadable = rb_define_module_under(rb_cIO, "generic_readable");
1846
+ rb_define_method(mReadable, "readchar", strio_readchar, 0);
1847
+ rb_define_method(mReadable, "readbyte", strio_readbyte, 0);
1848
+ rb_define_method(mReadable, "readline", strio_readline, -1);
1849
+ rb_define_method(mReadable, "sysread", strio_sysread, -1);
1850
+ rb_define_method(mReadable, "readpartial", strio_sysread, -1);
1851
+ rb_define_method(mReadable, "read_nonblock", strio_read_nonblock, -1);
1852
+ rb_include_module(StringIO, mReadable);
1853
+ }
1854
+ {
1855
+ VALUE mWritable = rb_define_module_under(rb_cIO, "generic_writable");
1856
+ rb_define_method(mWritable, "<<", strio_addstr, 1);
1857
+ rb_define_method(mWritable, "print", strio_print, -1);
1858
+ rb_define_method(mWritable, "printf", strio_printf, -1);
1859
+ rb_define_method(mWritable, "puts", strio_puts, -1);
1860
+ rb_define_method(mWritable, "syswrite", strio_syswrite, 1);
1861
+ rb_define_method(mWritable, "write_nonblock", strio_syswrite_nonblock, -1);
1862
+ rb_include_module(StringIO, mWritable);
1863
+ }
1864
+
1865
+ sym_exception = ID2SYM(rb_intern("exception"));
1866
+ }