active_cached_resource 0.0.1.pre

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (340) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +3 -0
  3. data/.rubocop.yml +22 -0
  4. data/.standard.yml +2 -0
  5. data/CHANGELOG.md +5 -0
  6. data/README.md +45 -0
  7. data/Rakefile +21 -0
  8. data/example/consumer/.dockerignore +41 -0
  9. data/example/consumer/.gitattributes +9 -0
  10. data/example/consumer/.gitignore +36 -0
  11. data/example/consumer/.kamal/hooks/docker-setup.sample +3 -0
  12. data/example/consumer/.kamal/hooks/post-deploy.sample +14 -0
  13. data/example/consumer/.kamal/hooks/post-proxy-reboot.sample +3 -0
  14. data/example/consumer/.kamal/hooks/pre-build.sample +51 -0
  15. data/example/consumer/.kamal/hooks/pre-connect.sample +47 -0
  16. data/example/consumer/.kamal/hooks/pre-deploy.sample +109 -0
  17. data/example/consumer/.kamal/hooks/pre-proxy-reboot.sample +3 -0
  18. data/example/consumer/.kamal/secrets +17 -0
  19. data/example/consumer/Dockerfile +65 -0
  20. data/example/consumer/Gemfile +17 -0
  21. data/example/consumer/Rakefile +6 -0
  22. data/example/consumer/app/controllers/application_controller.rb +2 -0
  23. data/example/consumer/app/controllers/concerns/.keep +0 -0
  24. data/example/consumer/app/jobs/application_job.rb +7 -0
  25. data/example/consumer/app/mailers/application_mailer.rb +4 -0
  26. data/example/consumer/app/models/application_record.rb +3 -0
  27. data/example/consumer/app/models/concerns/.keep +0 -0
  28. data/example/consumer/app/models/person.rb +9 -0
  29. data/example/consumer/app/views/layouts/mailer.html.erb +13 -0
  30. data/example/consumer/app/views/layouts/mailer.text.erb +1 -0
  31. data/example/consumer/bin/brakeman +7 -0
  32. data/example/consumer/bin/bundle +109 -0
  33. data/example/consumer/bin/dev +2 -0
  34. data/example/consumer/bin/docker-entrypoint +14 -0
  35. data/example/consumer/bin/jobs +6 -0
  36. data/example/consumer/bin/kamal +27 -0
  37. data/example/consumer/bin/rails +4 -0
  38. data/example/consumer/bin/rake +4 -0
  39. data/example/consumer/bin/rubocop +8 -0
  40. data/example/consumer/bin/setup +34 -0
  41. data/example/consumer/bin/thrust +5 -0
  42. data/example/consumer/config/application.rb +20 -0
  43. data/example/consumer/config/boot.rb +3 -0
  44. data/example/consumer/config/cache.yml +16 -0
  45. data/example/consumer/config/credentials.yml.enc +1 -0
  46. data/example/consumer/config/database.yml +14 -0
  47. data/example/consumer/config/deploy.yml +116 -0
  48. data/example/consumer/config/environment.rb +5 -0
  49. data/example/consumer/config/environments/development.rb +64 -0
  50. data/example/consumer/config/environments/production.rb +85 -0
  51. data/example/consumer/config/environments/test.rb +50 -0
  52. data/example/consumer/config/initializers/cors.rb +16 -0
  53. data/example/consumer/config/initializers/filter_parameter_logging.rb +8 -0
  54. data/example/consumer/config/initializers/inflections.rb +16 -0
  55. data/example/consumer/config/locales/en.yml +31 -0
  56. data/example/consumer/config/puma.rb +41 -0
  57. data/example/consumer/config/queue.yml +18 -0
  58. data/example/consumer/config/recurring.yml +10 -0
  59. data/example/consumer/config/routes.rb +10 -0
  60. data/example/consumer/config.ru +6 -0
  61. data/example/consumer/db/cache_schema.rb +14 -0
  62. data/example/consumer/db/queue_schema.rb +129 -0
  63. data/example/consumer/db/seeds.rb +0 -0
  64. data/example/consumer/lib/tasks/.keep +0 -0
  65. data/example/consumer/log/.keep +0 -0
  66. data/example/consumer/public/robots.txt +1 -0
  67. data/example/consumer/script/.keep +0 -0
  68. data/example/consumer/storage/.keep +0 -0
  69. data/example/consumer/tmp/.keep +0 -0
  70. data/example/consumer/tmp/cache/.keep +0 -0
  71. data/example/consumer/tmp/pids/.keep +0 -0
  72. data/example/consumer/tmp/storage/.keep +0 -0
  73. data/example/consumer/vendor/.keep +0 -0
  74. data/example/provider/.dockerignore +41 -0
  75. data/example/provider/.gitattributes +9 -0
  76. data/example/provider/.gitignore +32 -0
  77. data/example/provider/.kamal/hooks/docker-setup.sample +3 -0
  78. data/example/provider/.kamal/hooks/post-deploy.sample +14 -0
  79. data/example/provider/.kamal/hooks/post-proxy-reboot.sample +3 -0
  80. data/example/provider/.kamal/hooks/pre-build.sample +51 -0
  81. data/example/provider/.kamal/hooks/pre-connect.sample +47 -0
  82. data/example/provider/.kamal/hooks/pre-deploy.sample +109 -0
  83. data/example/provider/.kamal/hooks/pre-proxy-reboot.sample +3 -0
  84. data/example/provider/.kamal/secrets +17 -0
  85. data/example/provider/Dockerfile +65 -0
  86. data/example/provider/Gemfile +14 -0
  87. data/example/provider/Rakefile +6 -0
  88. data/example/provider/app/controllers/application_controller.rb +2 -0
  89. data/example/provider/app/controllers/concerns/.keep +0 -0
  90. data/example/provider/app/controllers/people_controller.rb +68 -0
  91. data/example/provider/app/jobs/application_job.rb +7 -0
  92. data/example/provider/app/mailers/application_mailer.rb +4 -0
  93. data/example/provider/app/models/address.rb +3 -0
  94. data/example/provider/app/models/application_record.rb +3 -0
  95. data/example/provider/app/models/company.rb +3 -0
  96. data/example/provider/app/models/concerns/.keep +0 -0
  97. data/example/provider/app/models/person.rb +6 -0
  98. data/example/provider/app/views/layouts/mailer.html.erb +13 -0
  99. data/example/provider/app/views/layouts/mailer.text.erb +1 -0
  100. data/example/provider/bin/brakeman +7 -0
  101. data/example/provider/bin/bundle +109 -0
  102. data/example/provider/bin/dev +2 -0
  103. data/example/provider/bin/docker-entrypoint +14 -0
  104. data/example/provider/bin/jobs +6 -0
  105. data/example/provider/bin/kamal +27 -0
  106. data/example/provider/bin/rails +4 -0
  107. data/example/provider/bin/rake +4 -0
  108. data/example/provider/bin/rubocop +8 -0
  109. data/example/provider/bin/setup +34 -0
  110. data/example/provider/bin/thrust +5 -0
  111. data/example/provider/config/application.rb +44 -0
  112. data/example/provider/config/boot.rb +3 -0
  113. data/example/provider/config/cache.yml +16 -0
  114. data/example/provider/config/credentials.yml.enc +1 -0
  115. data/example/provider/config/database.yml +20 -0
  116. data/example/provider/config/deploy.yml +116 -0
  117. data/example/provider/config/environment.rb +5 -0
  118. data/example/provider/config/environments/development.rb +64 -0
  119. data/example/provider/config/environments/production.rb +85 -0
  120. data/example/provider/config/environments/test.rb +50 -0
  121. data/example/provider/config/initializers/cors.rb +16 -0
  122. data/example/provider/config/initializers/filter_parameter_logging.rb +8 -0
  123. data/example/provider/config/initializers/inflections.rb +16 -0
  124. data/example/provider/config/locales/en.yml +31 -0
  125. data/example/provider/config/puma.rb +41 -0
  126. data/example/provider/config/queue.yml +18 -0
  127. data/example/provider/config/recurring.yml +10 -0
  128. data/example/provider/config/routes.rb +4 -0
  129. data/example/provider/config.ru +6 -0
  130. data/example/provider/db/cache_schema.rb +14 -0
  131. data/example/provider/db/migrate/20241202183937_create_people.rb +11 -0
  132. data/example/provider/db/migrate/20241202183955_create_addresses.rb +13 -0
  133. data/example/provider/db/migrate/20241202184017_create_companies.rb +14 -0
  134. data/example/provider/db/queue_schema.rb +129 -0
  135. data/example/provider/db/schema.rb +47 -0
  136. data/example/provider/db/seeds.rb +18 -0
  137. data/example/provider/lib/tasks/.keep +0 -0
  138. data/example/provider/log/.keep +0 -0
  139. data/example/provider/public/robots.txt +1 -0
  140. data/example/provider/script/.keep +0 -0
  141. data/example/provider/storage/.keep +0 -0
  142. data/example/provider/tmp/.keep +0 -0
  143. data/example/provider/tmp/pids/.keep +0 -0
  144. data/example/provider/tmp/storage/.keep +0 -0
  145. data/example/provider/vendor/.keep +0 -0
  146. data/lib/active_cached_resource/caching.rb +176 -0
  147. data/lib/active_cached_resource/caching_strategies/active_support_cache.rb +31 -0
  148. data/lib/active_cached_resource/caching_strategies/base.rb +114 -0
  149. data/lib/active_cached_resource/caching_strategies/sql_cache.rb +32 -0
  150. data/lib/active_cached_resource/configuration.rb +50 -0
  151. data/lib/active_cached_resource/logger.rb +22 -0
  152. data/lib/active_cached_resource/model.rb +33 -0
  153. data/lib/active_cached_resource/version.rb +12 -0
  154. data/lib/active_cached_resource.rb +64 -0
  155. data/lib/activeresource/.gitignore +15 -0
  156. data/lib/activeresource/README.md +283 -0
  157. data/lib/activeresource/examples/performance.rb +72 -0
  158. data/lib/activeresource/lib/active_resource/active_job_serializer.rb +26 -0
  159. data/lib/activeresource/lib/active_resource/associations/builder/association.rb +32 -0
  160. data/lib/activeresource/lib/active_resource/associations/builder/belongs_to.rb +16 -0
  161. data/lib/activeresource/lib/active_resource/associations/builder/has_many.rb +14 -0
  162. data/lib/activeresource/lib/active_resource/associations/builder/has_one.rb +14 -0
  163. data/lib/activeresource/lib/active_resource/associations.rb +175 -0
  164. data/lib/activeresource/lib/active_resource/base.rb +1741 -0
  165. data/lib/activeresource/lib/active_resource/callbacks.rb +22 -0
  166. data/lib/activeresource/lib/active_resource/collection.rb +214 -0
  167. data/lib/activeresource/lib/active_resource/connection.rb +298 -0
  168. data/lib/activeresource/lib/active_resource/custom_methods.rb +129 -0
  169. data/lib/activeresource/lib/active_resource/exceptions.rb +98 -0
  170. data/lib/activeresource/lib/active_resource/formats/json_format.rb +28 -0
  171. data/lib/activeresource/lib/active_resource/formats/xml_format.rb +27 -0
  172. data/lib/activeresource/lib/active_resource/formats.rb +24 -0
  173. data/lib/activeresource/lib/active_resource/http_mock.rb +386 -0
  174. data/lib/activeresource/lib/active_resource/inheriting_hash.rb +34 -0
  175. data/lib/activeresource/lib/active_resource/log_subscriber.rb +26 -0
  176. data/lib/activeresource/lib/active_resource/railtie.rb +31 -0
  177. data/lib/activeresource/lib/active_resource/reflection.rb +78 -0
  178. data/lib/activeresource/lib/active_resource/schema.rb +60 -0
  179. data/lib/activeresource/lib/active_resource/singleton.rb +111 -0
  180. data/lib/activeresource/lib/active_resource/threadsafe_attributes.rb +65 -0
  181. data/lib/activeresource/lib/active_resource/validations.rb +176 -0
  182. data/lib/activeresource/lib/active_resource.rb +49 -0
  183. data/lib/activeresource/lib/activeresource.rb +3 -0
  184. data/lib/activeresource/test/abstract_unit.rb +153 -0
  185. data/lib/activeresource/test/cases/active_job_serializer_test.rb +53 -0
  186. data/lib/activeresource/test/cases/association_test.rb +104 -0
  187. data/lib/activeresource/test/cases/associations/builder/belongs_to_test.rb +42 -0
  188. data/lib/activeresource/test/cases/associations/builder/has_many_test.rb +28 -0
  189. data/lib/activeresource/test/cases/associations/builder/has_one_test.rb +28 -0
  190. data/lib/activeresource/test/cases/authorization_test.rb +276 -0
  191. data/lib/activeresource/test/cases/base/custom_methods_test.rb +155 -0
  192. data/lib/activeresource/test/cases/base/equality_test.rb +53 -0
  193. data/lib/activeresource/test/cases/base/load_test.rb +249 -0
  194. data/lib/activeresource/test/cases/base/schema_test.rb +428 -0
  195. data/lib/activeresource/test/cases/base_errors_test.rb +129 -0
  196. data/lib/activeresource/test/cases/base_test.rb +1622 -0
  197. data/lib/activeresource/test/cases/callbacks_test.rb +155 -0
  198. data/lib/activeresource/test/cases/collection_test.rb +172 -0
  199. data/lib/activeresource/test/cases/connection_test.rb +357 -0
  200. data/lib/activeresource/test/cases/finder_test.rb +217 -0
  201. data/lib/activeresource/test/cases/format_test.rb +137 -0
  202. data/lib/activeresource/test/cases/http_mock_test.rb +213 -0
  203. data/lib/activeresource/test/cases/inheritence_test.rb +19 -0
  204. data/lib/activeresource/test/cases/inheriting_hash_test.rb +25 -0
  205. data/lib/activeresource/test/cases/log_subscriber_test.rb +63 -0
  206. data/lib/activeresource/test/cases/reflection_test.rb +65 -0
  207. data/lib/activeresource/test/cases/validations_test.rb +78 -0
  208. data/lib/activeresource/test/fixtures/address.rb +20 -0
  209. data/lib/activeresource/test/fixtures/beast.rb +16 -0
  210. data/lib/activeresource/test/fixtures/comment.rb +5 -0
  211. data/lib/activeresource/test/fixtures/customer.rb +5 -0
  212. data/lib/activeresource/test/fixtures/inventory.rb +14 -0
  213. data/lib/activeresource/test/fixtures/person.rb +15 -0
  214. data/lib/activeresource/test/fixtures/pet.rb +6 -0
  215. data/lib/activeresource/test/fixtures/post.rb +5 -0
  216. data/lib/activeresource/test/fixtures/product.rb +11 -0
  217. data/lib/activeresource/test/fixtures/project.rb +19 -0
  218. data/lib/activeresource/test/fixtures/proxy.rb +6 -0
  219. data/lib/activeresource/test/fixtures/sound.rb +11 -0
  220. data/lib/activeresource/test/fixtures/street_address.rb +6 -0
  221. data/lib/activeresource/test/fixtures/subscription_plan.rb +7 -0
  222. data/lib/activeresource/test/fixtures/weather.rb +21 -0
  223. data/lib/activeresource/test/setter_trap.rb +28 -0
  224. data/lib/activeresource/test/singleton_test.rb +138 -0
  225. data/lib/activeresource/test/threadsafe_attributes_test.rb +91 -0
  226. data/lib/generators/active_cached_resource/install_generator.rb +31 -0
  227. data/lib/generators/active_cached_resource/templates/migration.erb +16 -0
  228. data/sorbet/config +4 -0
  229. data/sorbet/rbi/annotations/.gitattributes +1 -0
  230. data/sorbet/rbi/annotations/activemodel.rbi +89 -0
  231. data/sorbet/rbi/annotations/activesupport.rbi +457 -0
  232. data/sorbet/rbi/annotations/minitest.rbi +119 -0
  233. data/sorbet/rbi/annotations/rainbow.rbi +269 -0
  234. data/sorbet/rbi/dsl/.gitattributes +1 -0
  235. data/sorbet/rbi/dsl/active_support/callbacks.rbi +21 -0
  236. data/sorbet/rbi/gems/.gitattributes +1 -0
  237. data/sorbet/rbi/gems/actioncable@8.0.0.rbi +252 -0
  238. data/sorbet/rbi/gems/actionmailbox@8.0.0.rbi +9 -0
  239. data/sorbet/rbi/gems/actionmailer@8.0.0.rbi +9 -0
  240. data/sorbet/rbi/gems/actionpack@8.0.0.rbi +20909 -0
  241. data/sorbet/rbi/gems/actiontext@8.0.0.rbi +9 -0
  242. data/sorbet/rbi/gems/actionview@8.0.0.rbi +16207 -0
  243. data/sorbet/rbi/gems/activejob@8.0.0.rbi +9 -0
  244. data/sorbet/rbi/gems/activemodel-serializers-xml@1.0.3.rbi +166 -0
  245. data/sorbet/rbi/gems/activemodel@8.0.0.rbi +6857 -0
  246. data/sorbet/rbi/gems/activerecord@8.0.0.rbi +42896 -0
  247. data/sorbet/rbi/gems/activeresource@6.1.4.rbi +3944 -0
  248. data/sorbet/rbi/gems/activestorage@8.0.0.rbi +9 -0
  249. data/sorbet/rbi/gems/activesupport@8.0.0.rbi +21251 -0
  250. data/sorbet/rbi/gems/ast@2.4.2.rbi +585 -0
  251. data/sorbet/rbi/gems/base64@0.2.0.rbi +509 -0
  252. data/sorbet/rbi/gems/benchmark@0.4.0.rbi +618 -0
  253. data/sorbet/rbi/gems/bigdecimal@3.1.8.rbi +78 -0
  254. data/sorbet/rbi/gems/builder@3.3.0.rbi +9 -0
  255. data/sorbet/rbi/gems/bump@0.10.0.rbi +169 -0
  256. data/sorbet/rbi/gems/byebug@11.1.3.rbi +3607 -0
  257. data/sorbet/rbi/gems/coderay@1.1.3.rbi +3427 -0
  258. data/sorbet/rbi/gems/concurrent-ruby@1.3.4.rbi +11645 -0
  259. data/sorbet/rbi/gems/connection_pool@2.4.1.rbi +9 -0
  260. data/sorbet/rbi/gems/crass@1.0.6.rbi +623 -0
  261. data/sorbet/rbi/gems/date@3.4.0.rbi +75 -0
  262. data/sorbet/rbi/gems/diff-lcs@1.5.1.rbi +1131 -0
  263. data/sorbet/rbi/gems/docile@1.4.1.rbi +377 -0
  264. data/sorbet/rbi/gems/drb@2.2.1.rbi +1347 -0
  265. data/sorbet/rbi/gems/erubi@1.13.0.rbi +150 -0
  266. data/sorbet/rbi/gems/globalid@1.2.1.rbi +9 -0
  267. data/sorbet/rbi/gems/i18n@1.14.6.rbi +2359 -0
  268. data/sorbet/rbi/gems/io-console@0.7.2.rbi +9 -0
  269. data/sorbet/rbi/gems/json@2.8.2.rbi +1901 -0
  270. data/sorbet/rbi/gems/language_server-protocol@3.17.0.3.rbi +14238 -0
  271. data/sorbet/rbi/gems/lint_roller@1.1.0.rbi +240 -0
  272. data/sorbet/rbi/gems/logger@1.6.1.rbi +920 -0
  273. data/sorbet/rbi/gems/loofah@2.23.1.rbi +1081 -0
  274. data/sorbet/rbi/gems/mail@2.8.1.rbi +9 -0
  275. data/sorbet/rbi/gems/marcel@1.0.4.rbi +9 -0
  276. data/sorbet/rbi/gems/method_source@1.1.0.rbi +304 -0
  277. data/sorbet/rbi/gems/mini_mime@1.1.5.rbi +9 -0
  278. data/sorbet/rbi/gems/minitest@5.25.2.rbi +1547 -0
  279. data/sorbet/rbi/gems/net-imap@0.5.1.rbi +9 -0
  280. data/sorbet/rbi/gems/net-pop@0.1.2.rbi +9 -0
  281. data/sorbet/rbi/gems/net-protocol@0.2.2.rbi +292 -0
  282. data/sorbet/rbi/gems/net-smtp@0.5.0.rbi +9 -0
  283. data/sorbet/rbi/gems/netrc@0.11.0.rbi +159 -0
  284. data/sorbet/rbi/gems/nio4r@2.7.4.rbi +9 -0
  285. data/sorbet/rbi/gems/nokogiri@1.16.7.rbi +7311 -0
  286. data/sorbet/rbi/gems/parallel@1.26.3.rbi +291 -0
  287. data/sorbet/rbi/gems/parser@3.3.6.0.rbi +5519 -0
  288. data/sorbet/rbi/gems/prism@1.2.0.rbi +39085 -0
  289. data/sorbet/rbi/gems/pry-byebug@3.10.1.rbi +1151 -0
  290. data/sorbet/rbi/gems/pry@0.14.2.rbi +10076 -0
  291. data/sorbet/rbi/gems/psych@5.2.0.rbi +1785 -0
  292. data/sorbet/rbi/gems/racc@1.8.1.rbi +162 -0
  293. data/sorbet/rbi/gems/rack-session@2.0.0.rbi +727 -0
  294. data/sorbet/rbi/gems/rack-test@2.1.0.rbi +747 -0
  295. data/sorbet/rbi/gems/rack@3.1.8.rbi +4905 -0
  296. data/sorbet/rbi/gems/rackup@2.2.1.rbi +230 -0
  297. data/sorbet/rbi/gems/rails-dom-testing@2.2.0.rbi +758 -0
  298. data/sorbet/rbi/gems/rails-html-sanitizer@1.6.0.rbi +785 -0
  299. data/sorbet/rbi/gems/rails@8.0.0.rbi +9 -0
  300. data/sorbet/rbi/gems/railties@8.0.0.rbi +6287 -0
  301. data/sorbet/rbi/gems/rainbow@3.1.1.rbi +403 -0
  302. data/sorbet/rbi/gems/rake@13.2.1.rbi +3091 -0
  303. data/sorbet/rbi/gems/rbi@0.2.1.rbi +4535 -0
  304. data/sorbet/rbi/gems/rdoc@6.8.1.rbi +12572 -0
  305. data/sorbet/rbi/gems/regexp_parser@2.9.2.rbi +3772 -0
  306. data/sorbet/rbi/gems/reline@0.5.12.rbi +2416 -0
  307. data/sorbet/rbi/gems/rexml@3.3.9.rbi +4858 -0
  308. data/sorbet/rbi/gems/rspec-core@3.13.2.rbi +11287 -0
  309. data/sorbet/rbi/gems/rspec-expectations@3.13.3.rbi +8183 -0
  310. data/sorbet/rbi/gems/rspec-mocks@3.13.2.rbi +5341 -0
  311. data/sorbet/rbi/gems/rspec-support@3.13.1.rbi +1630 -0
  312. data/sorbet/rbi/gems/rspec@3.13.0.rbi +83 -0
  313. data/sorbet/rbi/gems/rubocop-ast@1.36.1.rbi +7303 -0
  314. data/sorbet/rbi/gems/rubocop-performance@1.21.1.rbi +9 -0
  315. data/sorbet/rbi/gems/rubocop@1.65.1.rbi +58170 -0
  316. data/sorbet/rbi/gems/ruby-progressbar@1.13.0.rbi +1318 -0
  317. data/sorbet/rbi/gems/securerandom@0.3.2.rbi +395 -0
  318. data/sorbet/rbi/gems/simplecov-html@0.13.1.rbi +225 -0
  319. data/sorbet/rbi/gems/simplecov@0.22.0.rbi +2149 -0
  320. data/sorbet/rbi/gems/simplecov_json_formatter@0.1.4.rbi +9 -0
  321. data/sorbet/rbi/gems/spoom@1.5.0.rbi +4932 -0
  322. data/sorbet/rbi/gems/standard-custom@1.0.2.rbi +9 -0
  323. data/sorbet/rbi/gems/standard-performance@1.4.0.rbi +9 -0
  324. data/sorbet/rbi/gems/standard@1.40.0.rbi +929 -0
  325. data/sorbet/rbi/gems/stringio@3.1.2.rbi +9 -0
  326. data/sorbet/rbi/gems/tapioca@0.16.4.rbi +3597 -0
  327. data/sorbet/rbi/gems/thor@1.3.2.rbi +4378 -0
  328. data/sorbet/rbi/gems/timeout@0.4.2.rbi +151 -0
  329. data/sorbet/rbi/gems/tzinfo@2.0.6.rbi +5918 -0
  330. data/sorbet/rbi/gems/unicode-display_width@2.6.0.rbi +66 -0
  331. data/sorbet/rbi/gems/uri@1.0.2.rbi +2377 -0
  332. data/sorbet/rbi/gems/useragent@0.16.10.rbi +9 -0
  333. data/sorbet/rbi/gems/websocket-driver@0.7.6.rbi +9 -0
  334. data/sorbet/rbi/gems/websocket-extensions@0.1.5.rbi +9 -0
  335. data/sorbet/rbi/gems/yard-sorbet@0.9.0.rbi +435 -0
  336. data/sorbet/rbi/gems/yard@0.9.37.rbi +18504 -0
  337. data/sorbet/rbi/gems/zeitwerk@2.7.1.rbi +9 -0
  338. data/sorbet/tapioca/config.yml +13 -0
  339. data/sorbet/tapioca/require.rb +12 -0
  340. metadata +543 -0
@@ -0,0 +1,78 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "active_support/core_ext/class/attribute"
4
+ require "active_support/core_ext/module/deprecation"
5
+
6
+ module ActiveResource
7
+ # = Active Resource reflection
8
+ #
9
+ # Associations in ActiveResource would be used to resolve nested attributes
10
+ # in a response with correct classes.
11
+ # Now they could be specified over Associations with the options :class_name
12
+ module Reflection # :nodoc:
13
+ extend ActiveSupport::Concern
14
+
15
+ included do
16
+ class_attribute :reflections
17
+ self.reflections = {}
18
+ end
19
+
20
+ module ClassMethods
21
+ def create_reflection(macro, name, options)
22
+ reflection = AssociationReflection.new(macro, name, options)
23
+ self.reflections = self.reflections.merge(name => reflection)
24
+ reflection
25
+ end
26
+ end
27
+
28
+
29
+ class AssociationReflection
30
+ def initialize(macro, name, options)
31
+ @macro, @name, @options = macro, name, options
32
+ end
33
+
34
+ # Returns the name of the macro.
35
+ #
36
+ # <tt>has_many :clients</tt> returns <tt>:clients</tt>
37
+ attr_reader :name
38
+
39
+ # Returns the macro type.
40
+ #
41
+ # <tt>has_many :clients</tt> returns <tt>:has_many</tt>
42
+ attr_reader :macro
43
+
44
+ # Returns the hash of options used for the macro.
45
+ #
46
+ # <tt>has_many :clients</tt> returns +{}+
47
+ attr_reader :options
48
+
49
+ # Returns the class for the macro.
50
+ #
51
+ # <tt>has_many :clients</tt> returns the Client class
52
+ def klass
53
+ @klass ||= class_name.constantize
54
+ end
55
+
56
+ # Returns the class name for the macro.
57
+ #
58
+ # <tt>has_many :clients</tt> returns <tt>'Client'</tt>
59
+ def class_name
60
+ @class_name ||= derive_class_name
61
+ end
62
+
63
+ # Returns the foreign_key for the macro.
64
+ def foreign_key
65
+ @foreign_key ||= derive_foreign_key
66
+ end
67
+
68
+ private
69
+ def derive_class_name
70
+ options[:class_name] ? options[:class_name].to_s.camelize : name.to_s.classify
71
+ end
72
+
73
+ def derive_foreign_key
74
+ options[:foreign_key] ? options[:foreign_key].to_s : "#{name.to_s.downcase}_id"
75
+ end
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveResource # :nodoc:
4
+ class Schema # :nodoc:
5
+ # attributes can be known to be one of these types. They are easy to
6
+ # cast to/from.
7
+ KNOWN_ATTRIBUTE_TYPES = %w( string text integer float decimal datetime timestamp time date binary boolean )
8
+
9
+ # An array of attribute definitions, representing the attributes that
10
+ # have been defined.
11
+ attr_accessor :attrs
12
+
13
+ # The internals of an Active Resource Schema are very simple -
14
+ # unlike an Active Record TableDefinition (on which it is based).
15
+ # It provides a set of convenience methods for people to define their
16
+ # schema using the syntax:
17
+ # schema do
18
+ # string :foo
19
+ # integer :bar
20
+ # end
21
+ #
22
+ # The schema stores the name and type of each attribute. That is then
23
+ # read out by the schema method to populate the schema of the actual
24
+ # resource.
25
+ def initialize
26
+ @attrs = {}
27
+ end
28
+
29
+ def attribute(name, type, options = {})
30
+ raise ArgumentError, "Unknown Attribute type: #{type.inspect} for key: #{name.inspect}" unless type.nil? || Schema::KNOWN_ATTRIBUTE_TYPES.include?(type.to_s)
31
+
32
+ the_type = type.to_s
33
+ # TODO: add defaults
34
+ # the_attr = [type.to_s]
35
+ # the_attr << options[:default] if options.has_key? :default
36
+ @attrs[name.to_s] = the_type
37
+ self
38
+ end
39
+
40
+ # The following are the attribute types supported by Active Resource
41
+ # migrations.
42
+ KNOWN_ATTRIBUTE_TYPES.each do |attr_type|
43
+ # def string(*args)
44
+ # options = args.extract_options!
45
+ # attr_names = args
46
+ #
47
+ # attr_names.each { |name| attribute(name, 'string', options) }
48
+ # end
49
+ class_eval <<-EOV, __FILE__, __LINE__ + 1
50
+ # frozen_string_literal: true
51
+ def #{attr_type}(*args)
52
+ options = args.extract_options!
53
+ attr_names = args
54
+
55
+ attr_names.each { |name| attribute(name, '#{attr_type}', options) }
56
+ end
57
+ EOV
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,111 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveResource
4
+ module Singleton
5
+ extend ActiveSupport::Concern
6
+
7
+ module ClassMethods
8
+ attr_writer :singleton_name
9
+
10
+ def singleton_name
11
+ @singleton_name ||= model_name.element
12
+ end
13
+
14
+ # Gets the singleton path for the object. If the +query_options+ parameter is omitted, Rails
15
+ # will split from the \prefix options.
16
+ #
17
+ # ==== Options
18
+ # * +prefix_options+ - A \hash to add a \prefix to the request for nested URLs (e.g., <tt>:account_id => 19</tt>
19
+ # would yield a URL like <tt>/accounts/19/purchases.json</tt>).
20
+ #
21
+ # * +query_options+ - A \hash to add items to the query string for the request.
22
+ #
23
+ # ==== Examples
24
+ # Weather.singleton_path
25
+ # # => /weather.json
26
+ #
27
+ # class Inventory < ActiveResource::Base
28
+ # self.site = "https://37s.sunrise.com"
29
+ # self.prefix = "/products/:product_id/"
30
+ # end
31
+ #
32
+ # Inventory.singleton_path(:product_id => 5)
33
+ # # => /products/5/inventory.json
34
+ #
35
+ # Inventory.singleton_path({:product_id => 5}, {:sold => true})
36
+ # # => /products/5/inventory.json?sold=true
37
+ #
38
+ def singleton_path(prefix_options = {}, query_options = nil)
39
+ check_prefix_options(prefix_options)
40
+
41
+ prefix_options, query_options = split_options(prefix_options) if query_options.nil?
42
+ "#{prefix(prefix_options)}#{singleton_name}#{format_extension}#{query_string(query_options)}"
43
+ end
44
+
45
+ # Core method for finding singleton resources.
46
+ #
47
+ # ==== Arguments
48
+ # Takes a single argument of options
49
+ #
50
+ # ==== Options
51
+ # * <tt>:params</tt> - Sets the query and \prefix (nested URL) parameters.
52
+ #
53
+ # ==== Examples
54
+ # Weather.find
55
+ # # => GET /weather.json
56
+ #
57
+ # Weather.find(:params => {:degrees => 'fahrenheit'})
58
+ # # => GET /weather.json?degrees=fahrenheit
59
+ #
60
+ # == Failure or missing data
61
+ # A failure to find the requested object raises a ResourceNotFound exception.
62
+ #
63
+ # Inventory.find
64
+ # # => raises ResourceNotFound
65
+ def find(options = {})
66
+ find_singleton(options)
67
+ end
68
+
69
+ private
70
+ # Find singleton resource
71
+ def find_singleton(options)
72
+ prefix_options, query_options = split_options(options[:params])
73
+
74
+ path = singleton_path(prefix_options, query_options)
75
+ resp = self.format.decode(self.connection.get(path, self.headers).body)
76
+ instantiate_record(resp, prefix_options)
77
+ end
78
+ end
79
+ # Deletes the resource from the remote service.
80
+ #
81
+ # ==== Examples
82
+ # weather = Weather.find
83
+ # weather.destroy
84
+ # Weather.find # 404 (Resource Not Found)
85
+ def destroy
86
+ connection.delete(singleton_path, self.class.headers)
87
+ end
88
+
89
+
90
+ protected
91
+ # Update the resource on the remote service
92
+ def update
93
+ connection.put(singleton_path(prefix_options), encode, self.class.headers).tap do |response|
94
+ load_attributes_from_response(response)
95
+ end
96
+ end
97
+
98
+ # Create (i.e. \save to the remote service) the \new resource.
99
+ def create
100
+ connection.post(singleton_path, encode, self.class.headers).tap do |response|
101
+ self.id = id_from_response(response)
102
+ load_attributes_from_response(response)
103
+ end
104
+ end
105
+
106
+ private
107
+ def singleton_path(options = nil)
108
+ self.class.singleton_path(options || prefix_options)
109
+ end
110
+ end
111
+ end
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "active_support/core_ext/object/duplicable"
4
+
5
+ module ThreadsafeAttributes
6
+ def self.included(klass)
7
+ klass.extend(ClassMethods)
8
+ end
9
+
10
+ module ClassMethods
11
+ def threadsafe_attribute(*attrs)
12
+ main_thread = Thread.main # remember this, because it could change after forking
13
+
14
+ attrs.each do |attr|
15
+ define_method attr do
16
+ get_threadsafe_attribute(attr, main_thread)
17
+ end
18
+
19
+ define_method "#{attr}=" do |value|
20
+ set_threadsafe_attribute(attr, value, main_thread)
21
+ end
22
+
23
+ define_method "#{attr}_defined?" do
24
+ threadsafe_attribute_defined?(attr, main_thread)
25
+ end
26
+ end
27
+ end
28
+ end
29
+
30
+ private
31
+ def get_threadsafe_attribute(name, main_thread)
32
+ if threadsafe_attribute_defined_by_thread?(name, Thread.current)
33
+ get_threadsafe_attribute_by_thread(name, Thread.current)
34
+ elsif threadsafe_attribute_defined_by_thread?(name, main_thread)
35
+ value = get_threadsafe_attribute_by_thread(name, main_thread)
36
+ value = value.dup if value.duplicable?
37
+ set_threadsafe_attribute_by_thread(name, value, Thread.current)
38
+ value
39
+ end
40
+ end
41
+
42
+ def set_threadsafe_attribute(name, value, main_thread)
43
+ set_threadsafe_attribute_by_thread(name, value, Thread.current)
44
+ unless threadsafe_attribute_defined_by_thread?(name, main_thread)
45
+ set_threadsafe_attribute_by_thread(name, value, main_thread)
46
+ end
47
+ end
48
+
49
+ def threadsafe_attribute_defined?(name, main_thread)
50
+ threadsafe_attribute_defined_by_thread?(name, Thread.current) || ((Thread.current != main_thread) && threadsafe_attribute_defined_by_thread?(name, main_thread))
51
+ end
52
+
53
+ def get_threadsafe_attribute_by_thread(name, thread)
54
+ thread.thread_variable_get "active.resource.#{name}.#{self.object_id}"
55
+ end
56
+
57
+ def set_threadsafe_attribute_by_thread(name, value, thread)
58
+ thread.thread_variable_set "active.resource.#{name}.#{self.object_id}.defined", true
59
+ thread.thread_variable_set "active.resource.#{name}.#{self.object_id}", value
60
+ end
61
+
62
+ def threadsafe_attribute_defined_by_thread?(name, thread)
63
+ thread.thread_variable_get "active.resource.#{name}.#{self.object_id}.defined"
64
+ end
65
+ end
@@ -0,0 +1,176 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "active_support/core_ext/array/wrap"
4
+ require "active_support/core_ext/object/blank"
5
+
6
+ module ActiveResource
7
+ class ResourceInvalid < ClientError # :nodoc:
8
+ end
9
+
10
+ # Active Resource validation is reported to and from this object, which is used by Base#save
11
+ # to determine whether the object in a valid state to be saved. See usage example in Validations.
12
+ class Errors < ActiveModel::Errors
13
+ # Grabs errors from an array of messages (like ActiveRecord::Validations).
14
+ # The second parameter directs the errors cache to be cleared (default)
15
+ # or not (by passing true).
16
+ def from_array(messages, save_cache = false)
17
+ clear unless save_cache
18
+ humanized_attributes = Hash[@base.known_attributes.map { |attr_name| [attr_name.humanize, attr_name] }]
19
+ messages.each do |message|
20
+ attr_message = humanized_attributes.keys.sort_by { |a| -a.length }.detect do |attr_name|
21
+ if message[0, attr_name.size + 1] == "#{attr_name} "
22
+ add humanized_attributes[attr_name], message[(attr_name.size + 1)..-1]
23
+ end
24
+ end
25
+ add(:base, message) if attr_message.nil?
26
+ end
27
+ end
28
+
29
+ # Grabs errors from a hash of attribute => array of errors elements
30
+ # The second parameter directs the errors cache to be cleared (default)
31
+ # or not (by passing true)
32
+ #
33
+ # Unrecognized attribute names will be humanized and added to the record's
34
+ # base errors.
35
+ def from_hash(messages, save_cache = false)
36
+ clear unless save_cache
37
+
38
+ messages.each do |(key, errors)|
39
+ errors.each do |error|
40
+ if @base.known_attributes.include?(key)
41
+ add key, error
42
+ elsif key == "base"
43
+ add(:base, error)
44
+ else
45
+ # reporting an error on an attribute not in attributes
46
+ # format and add them to base
47
+ add(:base, "#{key.humanize} #{error}")
48
+ end
49
+ end
50
+ end
51
+ end
52
+
53
+ # Grabs errors from a json response.
54
+ def from_json(json, save_cache = false)
55
+ decoded = ActiveSupport::JSON.decode(json) || {} rescue {}
56
+ if decoded.kind_of?(Hash) && (decoded.has_key?("errors") || decoded.empty?)
57
+ errors = decoded["errors"] || {}
58
+ if errors.kind_of?(Array)
59
+ # 3.2.1-style with array of strings
60
+ ActiveResource.deprecator.warn("Returning errors as an array of strings is deprecated.")
61
+ from_array errors, save_cache
62
+ else
63
+ # 3.2.2+ style
64
+ from_hash errors, save_cache
65
+ end
66
+ else
67
+ # <3.2-style respond_with - lacks 'errors' key
68
+ ActiveResource.deprecator.warn('Returning errors as a hash without a root "errors" key is deprecated.')
69
+ from_hash decoded, save_cache
70
+ end
71
+ end
72
+
73
+ # Grabs errors from an XML response.
74
+ def from_xml(xml, save_cache = false)
75
+ array = Array.wrap(Hash.from_xml(xml)["errors"]["error"]) rescue []
76
+ from_array array, save_cache
77
+ end
78
+ end
79
+
80
+ # Module to support validation and errors with Active Resource objects. The module overrides
81
+ # Base#save to rescue ActiveResource::ResourceInvalid exceptions and parse the errors returned
82
+ # in the web service response. The module also adds an +errors+ collection that mimics the interface
83
+ # of the errors provided by ActiveModel::Errors.
84
+ #
85
+ # ==== Example
86
+ #
87
+ # Consider a Person resource on the server requiring both a +first_name+ and a +last_name+ with a
88
+ # <tt>validates_presence_of :first_name, :last_name</tt> declaration in the model:
89
+ #
90
+ # person = Person.new(:first_name => "Jim", :last_name => "")
91
+ # person.save # => false (server returns an HTTP 422 status code and errors)
92
+ # person.valid? # => false
93
+ # person.errors.empty? # => false
94
+ # person.errors.count # => 1
95
+ # person.errors.full_messages # => ["Last name can't be empty"]
96
+ # person.errors[:last_name] # => ["can't be empty"]
97
+ # person.last_name = "Halpert"
98
+ # person.save # => true (and person is now saved to the remote service)
99
+ #
100
+ module Validations
101
+ extend ActiveSupport::Concern
102
+ include ActiveModel::Validations
103
+
104
+ included do
105
+ alias_method :save_without_validation, :save
106
+ alias_method :save, :save_with_validation
107
+ end
108
+
109
+ # Validate a resource and save (POST) it to the remote web service.
110
+ # If any local validations fail - the save (POST) will not be attempted.
111
+ def save_with_validation(options = {})
112
+ perform_validation = options[:validate] != false
113
+
114
+ # clear the remote validations so they don't interfere with the local
115
+ # ones. Otherwise we get an endless loop and can never change the
116
+ # fields so as to make the resource valid.
117
+ @remote_errors = nil
118
+ if perform_validation && valid? || !perform_validation
119
+ save_without_validation
120
+ true
121
+ else
122
+ false
123
+ end
124
+ rescue ResourceInvalid => error
125
+ # cache the remote errors because every call to <tt>valid?</tt> clears
126
+ # all errors. We must keep a copy to add these back after local
127
+ # validations.
128
+ @remote_errors = error
129
+ load_remote_errors(@remote_errors, true)
130
+ false
131
+ end
132
+
133
+
134
+ # Loads the set of remote errors into the object's Errors based on the
135
+ # content-type of the error-block received.
136
+ def load_remote_errors(remote_errors, save_cache = false) # :nodoc:
137
+ case self.class.format
138
+ when ActiveResource::Formats[:xml]
139
+ errors.from_xml(remote_errors.response.body, save_cache)
140
+ when ActiveResource::Formats[:json]
141
+ errors.from_json(remote_errors.response.body, save_cache)
142
+ end
143
+ end
144
+
145
+ # Checks for errors on an object (i.e., is resource.errors empty?).
146
+ #
147
+ # Runs all the specified local validations and returns true if no errors
148
+ # were added, otherwise false.
149
+ # Runs local validations (eg those on your Active Resource model), and
150
+ # also any errors returned from the remote system the last time we
151
+ # saved.
152
+ # Remote errors can only be cleared by trying to re-save the resource.
153
+ #
154
+ # ==== Examples
155
+ # my_person = Person.create(params[:person])
156
+ # my_person.valid?
157
+ # # => true
158
+ #
159
+ # my_person.errors.add('login', 'can not be empty') if my_person.login == ''
160
+ # my_person.valid?
161
+ # # => false
162
+ #
163
+ def valid?(context = nil)
164
+ run_callbacks :validate do
165
+ super
166
+ load_remote_errors(@remote_errors, true) if defined?(@remote_errors) && @remote_errors.present?
167
+ errors.empty?
168
+ end
169
+ end
170
+
171
+ # Returns the Errors object that holds all information about attribute error messages.
172
+ def errors
173
+ @errors ||= Errors.new(self)
174
+ end
175
+ end
176
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ #--
4
+ # Copyright (c) 2006-2012 David Heinemeier Hansson
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining
7
+ # a copy of this software and associated documentation files (the
8
+ # "Software"), to deal in the Software without restriction, including
9
+ # without limitation the rights to use, copy, modify, merge, publish,
10
+ # distribute, sublicense, and/or sell copies of the Software, and to
11
+ # permit persons to whom the Software is furnished to do so, subject to
12
+ # the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be
15
+ # included in all copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
+ #++
25
+
26
+ require "uri"
27
+
28
+ require "active_support"
29
+ require "active_model"
30
+ require_relative "active_resource/exceptions"
31
+
32
+ module ActiveResource
33
+
34
+ URI_PARSER = defined?(URI::RFC2396_PARSER) ? URI::RFC2396_PARSER : URI::RFC2396_Parser.new
35
+
36
+ autoload :Base, "#{__dir__}/active_resource/base.rb"
37
+ autoload :Callbacks, "#{__dir__}/active_resource/callbacks.rb"
38
+ autoload :Collection, "#{__dir__}/active_resource/collection.rb"
39
+ autoload :Connection, "#{__dir__}/active_resource/connection.rb"
40
+ autoload :CustomMethods, "#{__dir__}/active_resource/custom_methods.rb"
41
+ autoload :Formats, "#{__dir__}/active_resource/formats.rb"
42
+ autoload :HttpMock, "#{__dir__}/active_resource/http_mock.rb"
43
+ autoload :InheritingHash, "#{__dir__}/active_resource/inheriting_hash.rb"
44
+ autoload :Schema, "#{__dir__}/active_resource/schema.rb"
45
+ autoload :Singleton, "#{__dir__}/active_resource/singleton.rb"
46
+ autoload :Validations, "#{__dir__}/active_resource/validations.rb"
47
+ end
48
+
49
+ require "active_resource/railtie" if defined?(Rails.application)
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "active_resource"