gemstash 1.0.0.pre.1-java → 2.6.0-java

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 (99) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +303 -0
  3. data/exe/gemstash +3 -0
  4. data/lib/gemstash/api_key_authorization.rb +32 -0
  5. data/lib/gemstash/authorization.rb +15 -8
  6. data/lib/gemstash/cache.rb +42 -2
  7. data/lib/gemstash/cli/authorize.rb +52 -9
  8. data/lib/gemstash/cli/base.rb +14 -6
  9. data/lib/gemstash/cli/setup.rb +67 -39
  10. data/lib/gemstash/cli/start.rb +6 -2
  11. data/lib/gemstash/cli/status.rb +3 -1
  12. data/lib/gemstash/cli/stop.rb +4 -1
  13. data/lib/gemstash/cli.rb +59 -1
  14. data/lib/gemstash/config.ru +4 -3
  15. data/lib/gemstash/configuration.rb +61 -8
  16. data/lib/gemstash/db/authorization.rb +5 -3
  17. data/lib/gemstash/db/cached_rubygem.rb +20 -0
  18. data/lib/gemstash/db/dependency.rb +2 -0
  19. data/lib/gemstash/db/rubygem.rb +3 -0
  20. data/lib/gemstash/db/upstream.rb +15 -0
  21. data/lib/gemstash/db/version.rb +25 -2
  22. data/lib/gemstash/db.rb +5 -0
  23. data/lib/gemstash/dependencies.rb +6 -2
  24. data/lib/gemstash/env.rb +44 -13
  25. data/lib/gemstash/gem_fetcher.rb +5 -3
  26. data/lib/gemstash/gem_pusher.rb +25 -18
  27. data/lib/gemstash/gem_source/dependency_caching.rb +4 -4
  28. data/lib/gemstash/gem_source/private_source.rb +34 -50
  29. data/lib/gemstash/gem_source/rack_middleware.rb +3 -0
  30. data/lib/gemstash/gem_source/upstream_source.rb +71 -27
  31. data/lib/gemstash/gem_source.rb +4 -2
  32. data/lib/gemstash/gem_yanker.rb +14 -4
  33. data/lib/gemstash/health.rb +55 -0
  34. data/lib/gemstash/http_client.rb +15 -5
  35. data/lib/gemstash/logging.rb +19 -7
  36. data/lib/gemstash/man/gemstash-authorize.1 +54 -0
  37. data/lib/gemstash/man/gemstash-authorize.1.txt +52 -0
  38. data/lib/gemstash/man/gemstash-configuration.5 +186 -0
  39. data/lib/gemstash/man/gemstash-configuration.5.txt +208 -0
  40. data/lib/gemstash/man/gemstash-customize.7 +273 -0
  41. data/lib/gemstash/man/gemstash-customize.7.txt +184 -0
  42. data/lib/gemstash/man/gemstash-debugging.7 +30 -0
  43. data/lib/gemstash/man/gemstash-debugging.7.txt +27 -0
  44. data/lib/gemstash/man/gemstash-deploy.7 +63 -0
  45. data/lib/gemstash/man/gemstash-deploy.7.txt +57 -0
  46. data/lib/gemstash/man/gemstash-mirror.7 +34 -0
  47. data/lib/gemstash/man/gemstash-mirror.7.txt +31 -0
  48. data/lib/gemstash/man/gemstash-multiple-sources.7 +131 -0
  49. data/lib/gemstash/man/gemstash-multiple-sources.7.txt +116 -0
  50. data/lib/gemstash/man/gemstash-private-gems.7 +191 -0
  51. data/lib/gemstash/man/gemstash-private-gems.7.txt +154 -0
  52. data/lib/gemstash/man/gemstash-readme.7 +199 -0
  53. data/lib/gemstash/man/gemstash-readme.7.txt +177 -0
  54. data/lib/gemstash/man/gemstash-setup.1 +38 -0
  55. data/lib/gemstash/man/gemstash-setup.1.txt +38 -0
  56. data/lib/gemstash/man/gemstash-start.1 +23 -0
  57. data/lib/gemstash/man/gemstash-start.1.txt +24 -0
  58. data/lib/gemstash/man/gemstash-status.1 +17 -0
  59. data/lib/gemstash/man/gemstash-status.1.txt +20 -0
  60. data/lib/gemstash/man/gemstash-stop.1 +17 -0
  61. data/lib/gemstash/man/gemstash-stop.1.txt +20 -0
  62. data/lib/gemstash/man/gemstash-version.1 +17 -0
  63. data/lib/gemstash/man/gemstash-version.1.txt +19 -0
  64. data/lib/gemstash/migrations/01_gem_dependencies.rb +11 -9
  65. data/lib/gemstash/migrations/02_authorizations.rb +4 -2
  66. data/lib/gemstash/migrations/03_cached_gems.rb +26 -0
  67. data/lib/gemstash/migrations/04_health_tests.rb +10 -0
  68. data/lib/gemstash/migrations/05_authorization_names.rb +10 -0
  69. data/lib/gemstash/puma.rb +5 -3
  70. data/lib/gemstash/rack_env_rewriter.rb +11 -2
  71. data/lib/gemstash/specs_builder.rb +25 -15
  72. data/lib/gemstash/storage.rb +175 -32
  73. data/lib/gemstash/upstream.rb +43 -8
  74. data/lib/gemstash/version.rb +4 -2
  75. data/lib/gemstash/web.rb +13 -8
  76. data/lib/gemstash.rb +6 -2
  77. metadata +135 -110
  78. data/.gitignore +0 -10
  79. data/.rspec +0 -2
  80. data/.rubocop-bundler.yml +0 -92
  81. data/.rubocop-relax.yml +0 -11
  82. data/.rubocop.yml +0 -8
  83. data/.travis.yml +0 -20
  84. data/Gemfile +0 -4
  85. data/README.md +0 -139
  86. data/Rakefile +0 -35
  87. data/bin/console +0 -14
  88. data/bin/gemstash +0 -3
  89. data/bin/setup +0 -5
  90. data/docs/config.md +0 -136
  91. data/docs/debug.md +0 -24
  92. data/docs/deploy.md +0 -30
  93. data/docs/mirror.md +0 -30
  94. data/docs/multiple_sources.md +0 -68
  95. data/docs/private_gems.md +0 -140
  96. data/docs/reference.md +0 -308
  97. data/gemstash.gemspec +0 -47
  98. data/gemstash.png +0 -0
  99. data/lib/gemstash/gem_unyanker.rb +0 -61
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: b4f42a90cf7dd5629135b2d0afa39f09b7a35d78
4
- data.tar.gz: 6967678927e52142303a1122f34e800f7dbbaa8c
2
+ SHA256:
3
+ metadata.gz: 2f9413aec2ce0f9af1d98dc5f56e0bdfe8e974ed4a390a05ee0eb648e4c6d65a
4
+ data.tar.gz: eeb7f4aa36d4162467c9f20cf69b8c16ad9d5add6f73571c4ec63d24a4562750
5
5
  SHA512:
6
- metadata.gz: 175724eeb41c706afd9db4d26f03e62925202c0d6644e120a889854469ea00bc82b0b9106187de3fbd91f96fc92d98f9ea0a04edbdc3dd3aaefc59598fde9c64
7
- data.tar.gz: 54e6502a0cfb9a35679cde8d2469176e71f0d67b822b89427eea19ac11bd89a3d3356e1a7a903471749f6c5172995b5bd560cc4a2fd17f662438c033c8afb2fb
6
+ metadata.gz: 7b288f7fa477452839963a78b22d38635dac29a904947c5b04d2d5a67be222e5f1220b253baaf7ac4ca168ee9a8591245bd63d2de80edf52f12cb92bab39d9a2
7
+ data.tar.gz: f8b30aebbe19b38313e5ad1a6a68b0074865adac73d52fb39a0c7be0f43f36eeae053463ca524786f05ac579d53fed39d3ce54594b0a0a868492213c4af32648
data/CHANGELOG.md ADDED
@@ -0,0 +1,303 @@
1
+ ## 2.6.0 (2023-09-30)
2
+
3
+ ### Changes
4
+
5
+ - Support `GEMSTASH_CONFIG` environment variable ([#369](https://github.com/rubygems/gemstash/pull/369), [@kyrofa](https://github.com/kyrofa))
6
+
7
+ ## 2.5.0 (2023-09-28)
8
+
9
+ ### Changes
10
+
11
+ - Add support for upstream auth with ENV variables ([#339](https://github.com/rubygems/gemstash/pull/339), [@CiTroNaK](https://github.com/CiTroNaK))
12
+
13
+ ## 2.4.0 (2023-09-27)
14
+
15
+ ### Changes
16
+
17
+ - Support naming and listing authorizations ([#365](https://github.com/rubygems/gemstash/pull/365), [@kyrofa](https://github.com/kyrofa))
18
+
19
+ ## 2.3.2 (2023-09-14)
20
+
21
+ ### Fixes
22
+
23
+ - Require a now-needed file for Puma 6. Thanks, [@ktreis](https://github.com/ktreis)! ([#362](https://github.com/rubygems/gemstash/pull/362), [@olleolleolle](https://github.com/olleolleolle))
24
+
25
+ ## 2.3.1 (2023-09-05)
26
+
27
+ ### Fixes
28
+
29
+ - Reinstate Ruby Central in README. ([#353](https://github.com/rubygems/gemstash/pull/353), [@olleolleolle](https://github.com/olleolleolle))
30
+ - Implement Puma 5-required logger method `#sync` ([#355](https://github.com/rubygems/gemstash/pull/355), [@ball-hayden](https://github.com/ball-hayden))
31
+
32
+ ## 2.3.0 (2023-08-30)
33
+
34
+ ### Changes
35
+
36
+ - Support Puma 6. ([#335](https://github.com/rubygems/gemstash/pull/335), [@MSP-Greg](https://github.com/MSP-Greg))
37
+ - Make UpstreamSource intermediate specs from upstream. ([#337](https://github.com/rubygems/gemstash/pull/337), [@tedgarb](https://github.com/tedgarb))
38
+ - Mention RubyCentral. ([#338](https://github.com/rubygems/gemstash/pull/338), [@adarsh](https://github.com/adarsh))
39
+ - Configure Dependabot. ([#341](https://github.com/rubygems/gemstash/pull/341), [@olleolleolle](https://github.com/olleolleolle))
40
+
41
+ ## 2.2.2 (2023-03-03)
42
+
43
+ ### Changes
44
+
45
+ - Allow newer versions of the `activesupport` dependency ([#332](https://github.com/rubygems/gemstash/pull/332), [@kyrofa](https://github.com/kyrofa))
46
+
47
+ ## 2.2.1 (2023-02-09)
48
+
49
+ ### Bugfixes
50
+
51
+ - Add permitted classes to a `YAML.load` in cache ([#329](https://github.com/rubygems/gemstash/pull/329), [@SocalNick](https://github.com/SocialNick))
52
+
53
+ ## 2.2.0 (2023-01-27)
54
+
55
+ ### Bugfixes
56
+
57
+ - Respect auth set in upstream host uri ([#317](https://github.com/rubygems/gemstash/pull/317), [@jebentier](https://github.com/jbentier))
58
+ - Change the response code for "/versions" from 403 to 404 ([#326](https://github.com/rubygems/gemstash/pull/326), [@hendric-dev](https://github.com/hendric-dev))
59
+
60
+ ### Changes
61
+
62
+ - Support Ruby 3 ([#312](https://github.com/rubygems/gemstash/pull/312), [@tonytonyjan](https://github.com/tonytonyjan))
63
+ - Drop support for EOL Ruby versions 2.4, 2.5, 2.6 ([#328](https://github.com/rubygems/gemstash/pull/328), [@indirect](https://github.com/indirect))
64
+ - Update `dalli` dependency ([#324](https://github.com/rubygems/gemstash/pull/324), [@indirect](https://github.com/indirect))
65
+ - Also thanks to: [@indirect][] and [@hsbt][] who fixed CI issues and lint warnings.
66
+
67
+ ## 2.1.0 (2020-02-26)
68
+
69
+ ### Bugfixes
70
+
71
+ - Shebang should be the first thing in the file ([#222](https://github.com/rubygems/gemstash/pull/222), [@bronzdoc](https://github.com/bronzdoc))
72
+
73
+ ### Changes
74
+
75
+ - Update rack-test requirement from ~> 0.6 to ~> 1.1 ([#199](https://github.com/rubygems/gemstash/pull/199), [@dependabot](https://github.com/dependabot))
76
+ - Update rake requirement from ~> 10.0 to ~> 12.3 ([#200](https://github.com/rubygems/gemstash/pull/200), [@dependabot](https://github.com/dependabot))
77
+ - CI matrix: Drop 2.0, 2.1, 2.2 ([#201](https://github.com/rubygems/gemstash/pull/201), [@olleolleolle](https://github.com/olleolleolle))
78
+ - Update rubocop version and update files to be inline with new cops ([#202](https://github.com/rubygems/gemstash/pull/202), [@bronzdoc](https://github.com/bronzdoc))
79
+ - Update rubocop requirement from = 0.60.0 to = 0.61.0 ([#208](https://github.com/rubygems/gemstash/pull/208), [@dependabot](https://github.com/dependabot))
80
+ - Update rubocop requirement from = 0.61.0 to = 0.61.1 ([#209](https://github.com/rubygems/gemstash/pull/209), [@dependabot](https://github.com/dependabot))
81
+ - Avoid Rubocop warnings ([#210](https://github.com/rubygems/gemstash/pull/210), [@olleolleolle](https://github.com/olleolleolle))
82
+ - RSpec: config.disable_monkey_patching! ([#211](https://github.com/rubygems/gemstash/pull/211), [@olleolleolle](https://github.com/olleolleolle))
83
+ - Travis: update JRuby to 9.2.5.0 ([#212](https://github.com/rubygems/gemstash/pull/212), [@olleolleolle](https://github.com/olleolleolle))
84
+ - Update rubocop requirement from = 0.61.1 to = 0.62.0 ([#213](https://github.com/rubygems/gemstash/pull/213), [@dependabot](https://github.com/dependabot))
85
+ - Update rubocop requirement from = 0.62.0 to = 0.63.0 ([#215](https://github.com/rubygems/gemstash/pull/215), [@dependabot](https://github.com/dependabot))
86
+ - gemspec: Allow Bundler 2 ([#217](https://github.com/rubygems/gemstash/pull/217), [@olleolleolle](https://github.com/olleolleolle))
87
+ - Update rubocop requirement from = 0.63.0 to = 0.63.1 ([#218](https://github.com/rubygems/gemstash/pull/218), [@dependabot](https://github.com/dependabot))
88
+ - Update rubocop requirement from = 0.63.1 to = 0.64.0 ([#220](https://github.com/rubygems/gemstash/pull/220), [@dependabot](https://github.com/dependabot))
89
+ - CI: matrix updates - update JRuby, add 2.6.1 ([#221](https://github.com/rubygems/gemstash/pull/221), [@olleolleolle](https://github.com/olleolleolle))
90
+ - Add a failing Aruba-based RSpec test for the CLI client output ([#223](https://github.com/rubygems/gemstash/pull/223), [@olleolleolle](https://github.com/olleolleolle))
91
+ - Update rubocop requirement from = 0.64.0 to = 0.65.0 ([#224](https://github.com/rubygems/gemstash/pull/224), [@dependabot](https://github.com/dependabot))
92
+ - CI: use 2.5.5, 2.6.2 ([#225](https://github.com/rubygems/gemstash/pull/225), [@olleolleolle](https://github.com/olleolleolle))
93
+ - Update rubocop requirement from = 0.65.0 to = 0.66.0 ([#226](https://github.com/rubygems/gemstash/pull/226), [@dependabot](https://github.com/dependabot), [@olleolleolle](https://github.com/olleolleolle), [@bronzdoc](https://github.com/bronzdoc))
94
+ - CI: Use 2.4.6 ([#228](https://github.com/rubygems/gemstash/pull/228), [@olleolleolle](https://github.com/olleolleolle))
95
+ - Update rubocop requirement from = 0.66.0 to = 0.67.1 ([#229](https://github.com/rubygems/gemstash/pull/229), [@dependabot](https://github.com/dependabot), [@olleolleolle](https://github.com/olleolleolle))
96
+ - CI: Drop 2.3.8 ([#230](https://github.com/rubygems/gemstash/pull/230), [@olleolleolle](https://github.com/olleolleolle))
97
+ - Update rubocop requirement from = 0.67.1 to = 0.67.2 ([#231](https://github.com/rubygems/gemstash/pull/231), [@dependabot](https://github.com/dependabot))
98
+ - CI: Use JRuby 9.2.7.0 ([#232](https://github.com/rubygems/gemstash/pull/232), [@olleolleolle](https://github.com/olleolleolle))
99
+ - Update rubocop requirement from = 0.67.2 to = 0.68.0 ([#233](https://github.com/rubygems/gemstash/pull/233), [@dependabot](https://github.com/dependabot), [@olleolleolle](https://github.com/olleolleolle))
100
+ - Update rubocop requirement from = 0.68.1 to = 0.69.0 ([#234](https://github.com/rubygems/gemstash/pull/234), [@dependabot](https://github.com/dependabot))
101
+ - Update rubocop requirement from = 0.69.0 to = 0.70.0 ([#235](https://github.com/rubygems/gemstash/pull/235), [@dependabot](https://github.com/dependabot))
102
+ - Set Travis badge to /rubygems user ([#236](https://github.com/rubygems/gemstash/pull/236), [@olleolleolle](https://github.com/olleolleolle))
103
+ - Fix broken links ([#240](https://github.com/rubygems/gemstash/pull/240), [@Aliciawyse](https://github.com/Aliciawyse))
104
+ - Fix various rubocop/codeclimate issues ([#241](https://github.com/rubygems/gemstash/pull/241), [@tchia04](https://github.com/tchia04))
105
+ - Fix some broken links in readme ([#243](https://github.com/rubygems/gemstash/pull/243), [@Aliciawyse](https://github.com/Aliciawyse))
106
+ - Improve webspec tests ([#244](https://github.com/rubygems/gemstash/pull/244), [@Aliciawyse](https://github.com/Aliciawyse))
107
+ - CI: Use jruby-9.2.8.0 ([#245](https://github.com/rubygems/gemstash/pull/245), [@olleolleolle](https://github.com/olleolleolle))
108
+ - CI: Use ruby 2.4.7, 2.5.6, 2.6.4 ([#246](https://github.com/rubygems/gemstash/pull/246), [@olleolleolle](https://github.com/olleolleolle))
109
+ - Add puma server pidfile configuration option ([#248](https://github.com/rubygems/gemstash/pull/248), [@krists](https://github.com/krists))
110
+ - CI: Use jruby-9.2.9.0 ([#249](https://github.com/rubygems/gemstash/pull/249), [@olleolleolle](https://github.com/olleolleolle))
111
+ - Officially drop support for older rubies ([#250](https://github.com/rubygems/gemstash/pull/250), [@deivid-rodriguez](https://github.com/deivid-rodriguez))
112
+ - Add config to ignore Gemfile source ([#253](https://github.com/rubygems/gemstash/pull/253), [@zpdcodes](https://github.com/zpdcodes))
113
+ - Update Puma gem ([#255](https://github.com/rubygems/gemstash/pull/255), [@bronzdoc](https://github.com/bronzdoc))
114
+ - Spec failures might be due to a bundler version ([#256](https://github.com/rubygems/gemstash/pull/256), [@bronzdoc](https://github.com/bronzdoc))
115
+ - Update spec homepage ([#257](https://github.com/rubygems/gemstash/pull/257), [@bronzdoc](https://github.com/bronzdoc))
116
+ - Update README.md links ([#258](https://github.com/rubygems/gemstash/pull/258), [@bronzdoc](https://github.com/bronzdoc))
117
+ - Add PR template ([#259](https://github.com/rubygems/gemstash/pull/259), [@bronzdoc](https://github.com/bronzdoc))
118
+ - Update docs ([#260](https://github.com/rubygems/gemstash/pull/260), [@bronzdoc](https://github.com/bronzdoc))
119
+
120
+ ### Features
121
+
122
+ - Add configuration options cache_expiration, cache_max_size ([#207](https://github.com/rubygems/gemstash/pull/207), [@optix2000](https://github.com/optix2000), [@olleolleolle](https://github.com/olleolleolle))
123
+
124
+ ## 2.0.0 (2018-11-18)
125
+
126
+ ### Changes
127
+
128
+ - Breaking change: remove unyank support ([#119](https://github.com/bundler/gemstash/pull/119), [@olleolleolle](https://github.com/olleolleolle))
129
+ - Travis: JRuby 9.1.7.0, gem update --system, format the buildfile ([#138](https://github.com/bundler/gemstash/pull/138), [@olleolleolle](https://github.com/olleolleolle))
130
+ - Travis: 2.4.1, 2.3.4, jruby-9.1.8.0 ([#142](https://github.com/bundler/gemstash/pull/142), [@olleolleolle](https://github.com/olleolleolle))
131
+ - Add a health check ([#146](https://github.com/bundler/gemstash/pull/146), [@smellsblue](https://github.com/smellsblue))
132
+ - Travis: jruby-9.1.12.0 ([#147](https://github.com/bundler/gemstash/pull/147), [@olleolleolle](https://github.com/olleolleolle))
133
+ - Typo fix in changelog tool ([#152](https://github.com/bundler/gemstash/pull/152), [@olleolleolle](https://github.com/olleolleolle))
134
+ - Rake: Turn rake task files into .rake files, auto-loaded ([#153](https://github.com/bundler/gemstash/pull/153), [@olleolleolle](https://github.com/olleolleolle))
135
+ - Travis: JRUBY_OPTS w/o invalid option jruby.cext.enabled ([#156](https://github.com/bundler/gemstash/pull/156), [@olleolleolle](https://github.com/olleolleolle))
136
+ - Suppress deprecation warnings in production code ([#162](https://github.com/bundler/gemstash/pull/162), [@koic](https://github.com/koic))
137
+ - Travis: jruby-9.1.13.0; use dist: "trusty" ([#167](https://github.com/bundler/gemstash/pull/167), [@olleolleolle](https://github.com/olleolleolle))
138
+ - Allow puma_workers configuration ([#168](https://github.com/bundler/gemstash/pull/168), [@HParker](https://github.com/HParker))
139
+ - Update Puma dependency to ~> 3.10 ([#169](https://github.com/bundler/gemstash/pull/169), [@premist](https://github.com/premist))
140
+ - gem: sequel v5.0.0 ([#170](https://github.com/bundler/gemstash/pull/170), [@olleolleolle](https://github.com/olleolleolle))
141
+ - Travis: Avoid jruby warning about MaxPermSize ([#171](https://github.com/bundler/gemstash/pull/171), [@olleolleolle](https://github.com/olleolleolle))
142
+ - Travis: use JRuby, 9.1.17.0 avoid double gem update --system ([#173](https://github.com/bundler/gemstash/pull/173), [@olleolleolle](https://github.com/olleolleolle))
143
+ - Update rubocop to .49 to fix CVE-2017-8418 ([#174](https://github.com/bundler/gemstash/pull/174), [@matthewalbani](https://github.com/matthewalbani))
144
+ - Add Ruby 2.5.1 to Travis build matrix ([#177](https://github.com/bundler/gemstash/pull/177), [@greysteil](https://github.com/greysteil))
145
+ - Skip stale jruby spec ([#178](https://github.com/bundler/gemstash/pull/178), [@bronzdoc](https://github.com/bronzdoc))
146
+ - Update sinatra dependency to >= 1.4, < 3.0 ([#179](https://github.com/bundler/gemstash/pull/179), [@bronzdoc](https://github.com/bronzdoc))
147
+ - gemspec: use Thor 0.20.0 ([#180](https://github.com/bundler/gemstash/pull/180), [@olleolleolle](https://github.com/olleolleolle))
148
+ - Travis: jruby-9.2.0.0 ([#181](https://github.com/bundler/gemstash/pull/181), [@olleolleolle](https://github.com/olleolleolle))
149
+ - do not set puma worker config when running jruby ([#183](https://github.com/bundler/gemstash/pull/183), [@andreaseger](https://github.com/andreaseger))
150
+ - Add health_tests table, and use in Gemstash::Health for idempotency ([#186](https://github.com/bundler/gemstash/pull/186), [@kurtzur](https://github.com/kurtzur))
151
+ - Pushing an existing version of a gem should not overwrite the gem con… ([#190](https://github.com/bundler/gemstash/pull/190), [@bronzdoc](https://github.com/bronzdoc), [@mzruya](https://github.com/mzruya))
152
+ - Fix jruby builds ([#193](https://github.com/bundler/gemstash/pull/193), [@bronzdoc](https://github.com/bronzdoc))
153
+
154
+ ### Features
155
+
156
+ - Allow stdout logging when running --no-daemonize ([#140](https://github.com/bundler/gemstash/pull/140), [@smellsblue](https://github.com/smellsblue))
157
+
158
+ ## 1.1.0 (2017-07-31)
159
+
160
+ ### Bugfixes
161
+
162
+ - Gracefully handle empty configuration files ([#97](https://github.com/bundler/gemstash/pull/97), [@rjocoleman](https://github.com/rjocoleman))
163
+ - Remove bundler-audit since we don't commit our Gemfile.lock ([#98](https://github.com/bundler/gemstash/pull/98), [@smellsblue](https://github.com/smellsblue))
164
+ - Clarify what is being cached for 30 minutes ([#108](https://github.com/bundler/gemstash/pull/108), [@Nowaker](https://github.com/Nowaker))
165
+ - Update documentation ([#112](https://github.com/bundler/gemstash/pull/112), [@smellsblue](https://github.com/smellsblue))
166
+ - Integration tests for searching for gems ([#113](https://github.com/bundler/gemstash/pull/113), [@smellsblue](https://github.com/smellsblue))
167
+ - Add `ruby-head` Gemfile for Travis ([#121](https://github.com/bundler/gemstash/pull/121), [@olleolleolle](https://github.com/olleolleolle))
168
+ - Make all Pandoc filters executable ([#122](https://github.com/bundler/gemstash/pull/122), [@olleolleolle](https://github.com/olleolleolle))
169
+ - Fix `rake doc` to work with newer versions of Pandoc ([#124](https://github.com/bundler/gemstash/pull/124), [@smellsblue](https://github.com/smellsblue))
170
+ - Use `curl` since `unyank` is removed in newer RubyGems versions ([#125](https://github.com/bundler/gemstash/pull/125), [@smellsblue](https://github.com/smellsblue))
171
+ - Touch up docs and update CHANGELOG ([#128](https://github.com/bundler/gemstash/pull/128), [@smellsblue](https://github.com/smellsblue))
172
+ - Update Travis to use ruby `2.3.3` ([#127](https://github.com/bundler/gemstash/pull/127), [@olleolleolle](https://github.com/olleolleolle))
173
+ - Add Ruby `2.4.0` to Travis ([#132](https://github.com/bundler/gemstash/pull/132), [@thedrow](https://github.com/thedrow))
174
+
175
+ ### Features
176
+
177
+ - Add support for mysql2 adapter ([#71](https://github.com/bundler/gemstash/pull/71), [@chriseckhardt](https://github.com/chriseckhardt))
178
+ - Allow logging to a different file ([#74](https://github.com/bundler/gemstash/pull/74), [@mrchucho](https://github.com/mrchucho))
179
+ - Document temporary protected fetch solution ([#80](https://github.com/bundler/gemstash/pull/80), [@taoza](https://github.com/taoza))
180
+ - Make gem fetch timeout configurable ([#81](https://github.com/bundler/gemstash/pull/81), [@midwire](https://github.com/midwire))
181
+ - Document fallback timeout for when Gemstash is down ([#88](https://github.com/bundler/gemstash/pull/88), [@parndt](https://github.com/parndt))
182
+ - Allow ERB parsed config file via `.erb` extension ([#90](https://github.com/bundler/gemstash/pull/90), [@jiexinhuang](https://github.com/jiexinhuang), [@rjocoleman](https://github.com/rjocoleman))
183
+ - Improve code climate ([#92](https://github.com/bundler/gemstash/pull/92), [@smellsblue](https://github.com/smellsblue))
184
+ - Refactor authorization ([#93](https://github.com/bundler/gemstash/pull/93), [@smellsblue](https://github.com/smellsblue), [@rjocoleman](https://github.com/rjocoleman))
185
+ - Add protected fetch for private gems ([#94](https://github.com/bundler/gemstash/pull/94), [@rjocoleman](https://github.com/rjocoleman))
186
+ - Add Ruby Together call to action ([#116](https://github.com/bundler/gemstash/pull/116), [@mrb](https://github.com/mrb))
187
+ - Configurable options to `Sequel.connect` ([#123](https://github.com/bundler/gemstash/pull/123), [@olleolleolle](https://github.com/olleolleolle))
188
+ - Support the `latest_specs.4.8.gz` endpoint for private gems ([#131](https://github.com/bundler/gemstash/pull/131), [@randycoulman](https://github.com/randycoulman))
189
+ - Merge in the latest 1.0 stable ([#136](https://github.com/bundler/gemstash/pull/136), [@smellsblue](https://github.com/smellsblue), [@randycoulman](https://github.com/randycoulman))
190
+
191
+ ## 1.0.4 (2017-01-27)
192
+
193
+ ### Features
194
+
195
+ - Backport `latest_specs.4.8.gz` endpoint for private gems to the 1.0 branch ([#134](https://github.com/bundler/gemstash/pull/134), [@randycoulman](https://github.com/randycoulman), [@smellsblue](https://github.com/smellsblue))
196
+ - Improve CHANGELOG generation and prepare for `1.0.4` release ([#135](https://github.com/bundler/gemstash/pull/135), [@smellsblue](https://github.com/smellsblue))
197
+
198
+ ## 1.0.3 (2016-10-15)
199
+
200
+ ### Bugfixes
201
+
202
+ - Fix JRuby build ([#110](https://github.com/bundler/gemstash/pull/110), [@smellsblue](https://github.com/smellsblue))
203
+ - Fix nil error when gems are fetched for the first time concurrently ([#111](https://github.com/bundler/gemstash/pull/111), [@smellsblue](https://github.com/smellsblue))
204
+
205
+ ### Features
206
+
207
+ - Embedded documentation via `gemstash help` ([#109](https://github.com/bundler/gemstash/pull/109), [@smellsblue](https://github.com/smellsblue))
208
+
209
+ ## 1.0.2 (2016-07-07)
210
+
211
+ ### Bugfixes
212
+
213
+ - Fix broken JRuby build ([#91](https://github.com/bundler/gemstash/pull/91), [@smellsblue](https://github.com/smellsblue))
214
+ - Drop www.rubygems.org in favor of rubygems.org ([#101](https://github.com/bundler/gemstash/pull/101), [@smellsblue](https://github.com/smellsblue))
215
+ - Redirect /versions and /info/* to index.rubygems.org ([#102](https://github.com/bundler/gemstash/pull/102), [@smellsblue](https://github.com/smellsblue))
216
+ - Backports to the 1.0 branch ([#103](https://github.com/bundler/gemstash/pull/103), [@smellsblue](https://github.com/smellsblue))
217
+
218
+ ## 1.0.1 (2016-02-23)
219
+
220
+ ### Bugfixes
221
+
222
+ - Don't pass along the Content-Length header ([#77](https://github.com/bundler/gemstash/pull/77), [@smellsblue](https://github.com/smellsblue))
223
+
224
+ ## 1.0.0 (2015-12-25)
225
+
226
+ There are no changes since the last release.
227
+
228
+ ## 1.0.0.pre.4 (2015-12-23)
229
+
230
+ ### Upgrade Notes
231
+
232
+ Any gems fetched before this release won't be indexed, which means plugins you
233
+ might install can't know about them. These cached gems might also have
234
+ incorrect headers stored (which shouldn't affect bundling). If you wish to
235
+ correct this, you can delete or back up your cache by deleting or moving your
236
+ `~/.gemstash/gem_cache` directory.
237
+
238
+ ### Bugfixes
239
+
240
+ - Cached gem and spec headers don't clobber each other ([#68](https://github.com/bundler/gemstash/pull/68), [@smellsblue](https://github.com/smellsblue))
241
+
242
+ ### Features
243
+
244
+ - Index cached gems and their upstreams for future use of plugins ([#68](https://github.com/bundler/gemstash/pull/68), [@smellsblue](https://github.com/smellsblue))
245
+
246
+ ## 1.0.0.pre.3 (2015-12-21)
247
+
248
+ ### Bugfixes
249
+
250
+ - Fail on missing specified config ([#66](https://github.com/bundler/gemstash/pull/66), [@smellsblue](https://github.com/smellsblue))
251
+
252
+ ## 1.0.0.pre.2 (2015-12-14)
253
+
254
+ ### Upgrade Notes
255
+
256
+ - If you pushed any private gems to your Gemstash instance, you will need to run: https://gist.github.com/smellsblue/53f5a6757dcc91ad10bc
257
+
258
+ ### Bugfixes
259
+
260
+ - Add --pre option to gemstash installation documentation ([#54](https://github.com/bundler/gemstash/pull/54), [@farukaydin](https://github.com/farukaydin))
261
+ - Fix docs for `gemstash authorize` ([#59](https://github.com/bundler/gemstash/pull/59), [@farukaydin](https://github.com/farukaydin))
262
+ - Refactoring, changed resource metadata `:gemstash_storage_version` to use `:gemstash_resource_version` ([#60](https://github.com/bundler/gemstash/pull/60), [@smellsblue](https://github.com/smellsblue))
263
+ - Fix migrations for utf8 on MySQL >= 5.5 ([#64](https://github.com/bundler/gemstash/pull/64), [@chriseckhardt](https://github.com/chriseckhardt))
264
+
265
+ ### Features
266
+
267
+ - Support MySQL as DB backend ([#52](https://github.com/bundler/gemstash/pull/52), [@pcarranza](https://github.com/pcarranza))
268
+ - Add start/stop output ([#58](https://github.com/bundler/gemstash/pull/58), [@farukaydin](https://github.com/farukaydin))
269
+ - Add `gemstash --version` ([#62](https://github.com/bundler/gemstash/pull/62), [@smellsblue](https://github.com/smellsblue))
270
+ - Create the CHANGELOG ([#63](https://github.com/bundler/gemstash/pull/63), [@smellsblue](https://github.com/smellsblue))
271
+
272
+ ## 1.0.0.pre.1 (2015-11-30)
273
+
274
+ ### Features
275
+
276
+ - Cache gems from multiple sources
277
+ - Push, yank, and unyank private gems
278
+ - Zero setup dependencies
279
+ - Optionally use Memcached for caching or PostgreSQL for the database
280
+ - Pull strategies and storage from bundler-api ([#5](https://github.com/bundler/gemstash/pull/5), [@pcarranza](https://github.com/pcarranza))
281
+ - Defer db connection test until sqlite db file exists ([#8](https://github.com/bundler/gemstash/pull/8), [@carpodaster](https://github.com/carpodaster))
282
+ - Integration specs ([#9](https://github.com/bundler/gemstash/pull/9), [@smellsblue](https://github.com/smellsblue))
283
+ - Logging all the things to a file ([#10](https://github.com/bundler/gemstash/pull/10), [@pcarranza](https://github.com/pcarranza))
284
+ - Gem sources ([#11](https://github.com/bundler/gemstash/pull/11), [@smellsblue](https://github.com/smellsblue))
285
+ - Forward http user agent to the upstream server ([#23](https://github.com/bundler/gemstash/pull/23), [@pcarranza](https://github.com/pcarranza))
286
+ - Documentation ([#25](https://github.com/bundler/gemstash/pull/25), [@smellsblue](https://github.com/smellsblue), [@pcarranza](https://github.com/pcarranza))
287
+ - Avoid filesystem limits using a trie ([#26](https://github.com/bundler/gemstash/pull/26), [@smellsblue](https://github.com/smellsblue))
288
+ - A few tweaks: enable setting the host to bind to, and reduced access for some attributes ([#28](https://github.com/bundler/gemstash/pull/28), [@pcarranza](https://github.com/pcarranza))
289
+ - Handle upstream connection error correctly and die with dignity ([#29](https://github.com/bundler/gemstash/pull/29), [@pcarranza](https://github.com/pcarranza))
290
+ - Add many ruby versions to travis configuration ([#31](https://github.com/bundler/gemstash/pull/31), [@pcarranza](https://github.com/pcarranza))
291
+ - Add rubygems version enforcement ([#32](https://github.com/bundler/gemstash/pull/32), [@pcarranza](https://github.com/pcarranza))
292
+ - Older RubyGems and Ruby 2.0.0 ([#33](https://github.com/bundler/gemstash/pull/33), [@smellsblue](https://github.com/smellsblue))
293
+ - Various fixes ([#34](https://github.com/bundler/gemstash/pull/34), [@smellsblue](https://github.com/smellsblue))
294
+ - Yanking gems ([#36](https://github.com/bundler/gemstash/pull/36), [@smellsblue](https://github.com/smellsblue))
295
+ - Use Sequel::Model ([#37](https://github.com/bundler/gemstash/pull/37), [@smellsblue](https://github.com/smellsblue))
296
+ - Build against JRuby ([#38](https://github.com/bundler/gemstash/pull/38), [@smellsblue](https://github.com/smellsblue))
297
+ - Unyanking gems ([#39](https://github.com/bundler/gemstash/pull/39), [@smellsblue](https://github.com/smellsblue))
298
+ - Add status command ([#40](https://github.com/bundler/gemstash/pull/40), [@smellsblue](https://github.com/smellsblue))
299
+ - Cache if gem is indexed in Gemstash::Storage ([#44](https://github.com/bundler/gemstash/pull/44), [@smellsblue](https://github.com/smellsblue))
300
+ - Full index bundling ([#45](https://github.com/bundler/gemstash/pull/45), [@smellsblue](https://github.com/smellsblue))
301
+ - Various fixes 2 ([#47](https://github.com/bundler/gemstash/pull/47), [@smellsblue](https://github.com/smellsblue))
302
+ - Various fixes 3 ([#49](https://github.com/bundler/gemstash/pull/49), [@smellsblue](https://github.com/smellsblue))
303
+ - Add Gemtash logo ([#50](https://github.com/bundler/gemstash/pull/50), [@jonathanrieta](https://github.com/jonathanrieta))
data/exe/gemstash CHANGED
@@ -1,3 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
+
3
+ # frozen_string_literal: true
4
+
2
5
  require "gemstash/cli"
3
6
  Gemstash::CLI.start
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "gemstash"
4
+
5
+ module Gemstash
6
+ # Authorize actions via an API key and Gemstash::Authorization.
7
+ class ApiKeyAuthorization
8
+ def initialize(key)
9
+ @key = key
10
+ end
11
+
12
+ def self.protect(app, &block)
13
+ key = parse_authorization(app.request.env)
14
+ app.auth = new(key)
15
+ yield
16
+ rescue Gemstash::NotAuthorizedError => e
17
+ app.headers["WWW-Authenticate"] = "Basic realm=\"Gemstash Private Gems\""
18
+ app.halt 401, e.message
19
+ end
20
+
21
+ def self.parse_authorization(request_env)
22
+ http_auth = Rack::Auth::Basic::Request.new(request_env)
23
+ return http_auth.credentials.first if http_auth.provided? && http_auth.basic?
24
+
25
+ request_env["HTTP_AUTHORIZATION"]
26
+ end
27
+
28
+ def check(permission)
29
+ Gemstash::Authorization.check(@key, permission)
30
+ end
31
+ end
32
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "set"
2
4
 
3
5
  module Gemstash
@@ -9,23 +11,23 @@ module Gemstash
9
11
  class Authorization
10
12
  extend Gemstash::Env::Helper
11
13
  extend Gemstash::Logging
12
- VALID_PERMISSIONS = %w(push yank unyank).freeze
14
+ VALID_PERMISSIONS = %w[push yank fetch].freeze
15
+
16
+ attr_reader :name
13
17
 
14
- def self.authorize(auth_key, permissions)
18
+ def self.authorize(auth_key, permissions, name = nil)
15
19
  raise "Authorization key is required!" if auth_key.to_s.strip.empty?
16
20
  raise "Permissions are required!" if permissions.to_s.empty?
17
21
 
18
22
  unless permissions == "all"
19
23
  permissions.each do |permission|
20
- unless VALID_PERMISSIONS.include?(permission)
21
- raise "Invalid permission '#{permission}'"
22
- end
24
+ raise "Invalid permission '#{permission}'" unless VALID_PERMISSIONS.include?(permission)
23
25
  end
24
26
 
25
27
  permissions = permissions.join(",")
26
28
  end
27
29
 
28
- Gemstash::DB::Authorization.insert_or_update(auth_key, permissions)
30
+ Gemstash::DB::Authorization.insert_or_update(auth_key, permissions, name)
29
31
  gemstash_env.cache.invalidate_authorization(auth_key)
30
32
  log.info "Authorization '#{auth_key}' updated with access to '#{permissions}'"
31
33
  end
@@ -33,6 +35,7 @@ module Gemstash
33
35
  def self.remove(auth_key)
34
36
  record = Gemstash::DB::Authorization[auth_key: auth_key]
35
37
  return unless record
38
+
36
39
  record.destroy
37
40
  gemstash_env.cache.invalidate_authorization(auth_key)
38
41
  log.info "Authorization '#{auth_key}' with access to '#{record.permissions}' removed"
@@ -40,6 +43,7 @@ module Gemstash
40
43
 
41
44
  def self.check(auth_key, permission)
42
45
  raise NotAuthorizedError, "Authorization key required" if auth_key.to_s.strip.empty?
46
+
43
47
  auth = self[auth_key]
44
48
  raise NotAuthorizedError, "Authorization key is invalid" unless auth
45
49
  raise NotAuthorizedError, "Authorization key doesn't have #{permission} access" unless auth.can?(permission)
@@ -48,6 +52,7 @@ module Gemstash
48
52
  def self.[](auth_key)
49
53
  cached_auth = gemstash_env.cache.authorization(auth_key)
50
54
  return cached_auth if cached_auth
55
+
51
56
  record = Gemstash::DB::Authorization[auth_key: auth_key]
52
57
 
53
58
  if record
@@ -59,12 +64,14 @@ module Gemstash
59
64
 
60
65
  def initialize(record)
61
66
  @auth_key = record.auth_key
67
+ @name = record.name
62
68
  @all = record.permissions == "all"
63
69
  @permissions = Set.new(record.permissions.split(","))
64
70
  end
65
71
 
66
72
  def can?(permission)
67
73
  raise "Invalid permission '#{permission}'" unless VALID_PERMISSIONS.include?(permission)
74
+
68
75
  all? || @permissions.include?(permission)
69
76
  end
70
77
 
@@ -80,8 +87,8 @@ module Gemstash
80
87
  can?("yank")
81
88
  end
82
89
 
83
- def unyank?
84
- can?("unyank")
90
+ def fetch?
91
+ can?("fetch")
85
92
  end
86
93
  end
87
94
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "lru_redux"
2
4
  require "forwardable"
3
5
 
@@ -6,7 +8,7 @@ module Gemstash
6
8
  # for them. Under the hood is either a Memcached client via the dalli gem, or
7
9
  # an in memory client via the lru_redux gem.
8
10
  class Cache
9
- EXPIRY = 30 * 60
11
+ EXPIRY = Env.current.config[:cache_expiration]
10
12
  extend Forwardable
11
13
  def_delegators :@client, :flush
12
14
 
@@ -47,7 +49,7 @@ module Gemstash
47
49
 
48
50
  # Wrapper around the lru_redux gem to behave like a dalli Memcached client.
49
51
  class LruReduxClient
50
- MAX_SIZE = 500
52
+ MAX_SIZE = Env.current.config[:cache_max_size]
51
53
  EXPIRY = Gemstash::Cache::EXPIRY
52
54
  extend Forwardable
53
55
  def_delegators :@cache, :delete
@@ -68,6 +70,7 @@ module Gemstash
68
70
  # Atomic fetch... don't rely on nil meaning missing
69
71
  value = @cache.fetch(key) { found = false }
70
72
  next unless found
73
+
71
74
  yield(key, value)
72
75
  end
73
76
  end
@@ -76,4 +79,41 @@ module Gemstash
76
79
  @cache[key] = value
77
80
  end
78
81
  end
82
+
83
+ # Wrapper around the redis-rb gem to behave like a dalli Memcached client.
84
+ class RedisClient
85
+ extend Forwardable
86
+
87
+ def_delegator :@cache, :del, :delete
88
+
89
+ def initialize(redis_servers)
90
+ require "redis"
91
+ @cache = ::Redis.new(:url => redis_servers)
92
+ end
93
+
94
+ def alive!
95
+ @cache.ping == "PONG"
96
+ end
97
+
98
+ def get(key)
99
+ val = @cache.get(key)
100
+ YAML.load(val, permitted_classes: [Gemstash::Authorization, Set]) unless val.nil?
101
+ end
102
+
103
+ def get_multi(keys)
104
+ @cache.mget(*keys).each do |k, v|
105
+ next if v.nil?
106
+
107
+ yield(k, YAML.load(v))
108
+ end
109
+ end
110
+
111
+ def set(key, value, expiry)
112
+ @cache.set(key, YAML.dump(value), :ex => expiry)
113
+ end
114
+
115
+ def flush
116
+ @cache.flushdb
117
+ end
118
+ end
79
119
  end
@@ -1,5 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "gemstash"
2
4
  require "securerandom"
5
+ require "terminal-table"
3
6
 
4
7
  module Gemstash
5
8
  class CLI
@@ -10,8 +13,13 @@ module Gemstash
10
13
  prepare
11
14
  setup_logging
12
15
 
16
+ # Catch invalid option combinations
17
+ raise Gemstash::CLI::Error.new(@cli, "--remove and --list cannot both be used") if @cli.options[:remove] && @cli.options[:list]
18
+
13
19
  if @cli.options[:remove]
14
20
  remove_authorization
21
+ elsif @cli.options[:list]
22
+ list_authorizations
15
23
  else
16
24
  save_authorization
17
25
  end
@@ -20,19 +28,21 @@ module Gemstash
20
28
  private
21
29
 
22
30
  def setup_logging
23
- Gemstash::Logging.setup_logger(gemstash_env.base_file("server.log"))
31
+ Gemstash::Logging.setup_logger(gemstash_env.log_file)
24
32
  end
25
33
 
26
34
  def remove_authorization
27
- raise Gemstash::CLI::Error.new(@cli, "To remove individual permissions, you do not need --remove
28
- Instead just authorize with the new set of permissions") unless @args.empty?
29
- Gemstash::Authorization.remove(auth_key(false))
35
+ raise Gemstash::CLI::Error.new(@cli, "--name cannot be used with --remove") if @cli.options[:remove] && @cli.options[:name]
36
+
37
+ unless @args.empty?
38
+ raise Gemstash::CLI::Error.new(@cli, "To remove individual permissions, you do not need --remove
39
+ Instead just authorize with the new set of permissions")
40
+ end
41
+ Gemstash::Authorization.remove(auth_key(allow_generate: false))
30
42
  end
31
43
 
32
44
  def save_authorization
33
- if @args.include?("all")
34
- raise Gemstash::CLI::Error.new(@cli, "Don't specify permissions to authorize for all")
35
- end
45
+ raise Gemstash::CLI::Error.new(@cli, "Don't specify permissions to authorize for all") if @args.include?("all")
36
46
 
37
47
  @args.each do |arg|
38
48
  unless Gemstash::Authorization::VALID_PERMISSIONS.include?(arg)
@@ -41,10 +51,27 @@ Instead just authorize with the new set of permissions") unless @args.empty?
41
51
  end
42
52
  end
43
53
 
44
- Gemstash::Authorization.authorize(auth_key, permissions)
54
+ begin
55
+ name = @cli.options[:name]
56
+ Gemstash::Authorization.authorize(auth_key, permissions, name)
57
+ rescue Sequel::UniqueConstraintViolation => e
58
+ raise unless name && e.message.include?("authorizations.name")
59
+
60
+ raise Gemstash::CLI::Error.new(@cli, "Authorization with name '#{name}' already exists")
61
+ end
62
+ end
63
+
64
+ def list_authorizations
65
+ raise Gemstash::CLI::Error.new(@cli, "--key and --name cannot both be used with --list") if @cli.options[:name] && @cli.options[:key]
66
+
67
+ rows = map_authorizations(@cli.options[:key], @cli.options[:name]) do |authorization|
68
+ [authorization.name, authorization.auth_key, authorization.permissions]
69
+ end
70
+
71
+ @cli.say Terminal::Table.new :headings => %w[Name Key Permissions], :rows => rows
45
72
  end
46
73
 
47
- def auth_key(allow_generate = true)
74
+ def auth_key(allow_generate: true)
48
75
  if @cli.options[:key]
49
76
  @cli.options[:key]
50
77
  elsif allow_generate
@@ -64,6 +91,22 @@ Instead just authorize with the new set of permissions") unless @args.empty?
64
91
  @args
65
92
  end
66
93
  end
94
+
95
+ def map_authorizations(key = nil, name = nil, &block)
96
+ return Gemstash::DB::Authorization.map(&block) unless name || key
97
+
98
+ authorization = if name
99
+ Gemstash::DB::Authorization[name: name].tap do |authorization|
100
+ raise Gemstash::CLI::Error.new(@cli, "No authorization named '#{name}'") unless authorization
101
+ end
102
+ else
103
+ Gemstash::DB::Authorization[auth_key: key].tap do |authorization|
104
+ raise Gemstash::CLI::Error.new(@cli, "No authorization with key '#{key}'") unless authorization
105
+ end
106
+ end
107
+
108
+ [yield(authorization)]
109
+ end
67
110
  end
68
111
  end
69
112
  end