gemstash 1.0.0.pre.1-java → 2.5.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +295 -0
- data/exe/gemstash +3 -0
- data/lib/gemstash/api_key_authorization.rb +32 -0
- data/lib/gemstash/authorization.rb +15 -8
- data/lib/gemstash/cache.rb +42 -2
- data/lib/gemstash/cli/authorize.rb +52 -9
- data/lib/gemstash/cli/base.rb +14 -6
- data/lib/gemstash/cli/setup.rb +67 -39
- data/lib/gemstash/cli/start.rb +6 -2
- data/lib/gemstash/cli/status.rb +3 -1
- data/lib/gemstash/cli/stop.rb +4 -1
- data/lib/gemstash/cli.rb +59 -1
- data/lib/gemstash/config.ru +4 -3
- data/lib/gemstash/configuration.rb +56 -8
- data/lib/gemstash/db/authorization.rb +5 -3
- data/lib/gemstash/db/cached_rubygem.rb +20 -0
- data/lib/gemstash/db/dependency.rb +2 -0
- data/lib/gemstash/db/rubygem.rb +3 -0
- data/lib/gemstash/db/upstream.rb +15 -0
- data/lib/gemstash/db/version.rb +25 -2
- data/lib/gemstash/db.rb +5 -0
- data/lib/gemstash/dependencies.rb +6 -2
- data/lib/gemstash/env.rb +44 -13
- data/lib/gemstash/gem_fetcher.rb +5 -3
- data/lib/gemstash/gem_pusher.rb +25 -18
- data/lib/gemstash/gem_source/dependency_caching.rb +4 -4
- data/lib/gemstash/gem_source/private_source.rb +34 -50
- data/lib/gemstash/gem_source/rack_middleware.rb +3 -0
- data/lib/gemstash/gem_source/upstream_source.rb +71 -27
- data/lib/gemstash/gem_source.rb +4 -2
- data/lib/gemstash/gem_yanker.rb +14 -4
- data/lib/gemstash/health.rb +55 -0
- data/lib/gemstash/http_client.rb +15 -5
- data/lib/gemstash/logging.rb +19 -7
- data/lib/gemstash/man/gemstash-authorize.1 +54 -0
- data/lib/gemstash/man/gemstash-authorize.1.txt +52 -0
- data/lib/gemstash/man/gemstash-configuration.5 +186 -0
- data/lib/gemstash/man/gemstash-configuration.5.txt +208 -0
- data/lib/gemstash/man/gemstash-customize.7 +273 -0
- data/lib/gemstash/man/gemstash-customize.7.txt +184 -0
- data/lib/gemstash/man/gemstash-debugging.7 +30 -0
- data/lib/gemstash/man/gemstash-debugging.7.txt +27 -0
- data/lib/gemstash/man/gemstash-deploy.7 +63 -0
- data/lib/gemstash/man/gemstash-deploy.7.txt +57 -0
- data/lib/gemstash/man/gemstash-mirror.7 +34 -0
- data/lib/gemstash/man/gemstash-mirror.7.txt +31 -0
- data/lib/gemstash/man/gemstash-multiple-sources.7 +131 -0
- data/lib/gemstash/man/gemstash-multiple-sources.7.txt +116 -0
- data/lib/gemstash/man/gemstash-private-gems.7 +191 -0
- data/lib/gemstash/man/gemstash-private-gems.7.txt +154 -0
- data/lib/gemstash/man/gemstash-readme.7 +199 -0
- data/lib/gemstash/man/gemstash-readme.7.txt +177 -0
- data/lib/gemstash/man/gemstash-setup.1 +38 -0
- data/lib/gemstash/man/gemstash-setup.1.txt +38 -0
- data/lib/gemstash/man/gemstash-start.1 +23 -0
- data/lib/gemstash/man/gemstash-start.1.txt +24 -0
- data/lib/gemstash/man/gemstash-status.1 +17 -0
- data/lib/gemstash/man/gemstash-status.1.txt +20 -0
- data/lib/gemstash/man/gemstash-stop.1 +17 -0
- data/lib/gemstash/man/gemstash-stop.1.txt +20 -0
- data/lib/gemstash/man/gemstash-version.1 +17 -0
- data/lib/gemstash/man/gemstash-version.1.txt +19 -0
- data/lib/gemstash/migrations/01_gem_dependencies.rb +11 -9
- data/lib/gemstash/migrations/02_authorizations.rb +4 -2
- data/lib/gemstash/migrations/03_cached_gems.rb +26 -0
- data/lib/gemstash/migrations/04_health_tests.rb +10 -0
- data/lib/gemstash/migrations/05_authorization_names.rb +10 -0
- data/lib/gemstash/puma.rb +5 -3
- data/lib/gemstash/rack_env_rewriter.rb +11 -2
- data/lib/gemstash/specs_builder.rb +25 -15
- data/lib/gemstash/storage.rb +175 -32
- data/lib/gemstash/upstream.rb +43 -8
- data/lib/gemstash/version.rb +4 -2
- data/lib/gemstash/web.rb +13 -8
- data/lib/gemstash.rb +6 -2
- metadata +135 -110
- data/.gitignore +0 -10
- data/.rspec +0 -2
- data/.rubocop-bundler.yml +0 -92
- data/.rubocop-relax.yml +0 -11
- data/.rubocop.yml +0 -8
- data/.travis.yml +0 -20
- data/Gemfile +0 -4
- data/README.md +0 -139
- data/Rakefile +0 -35
- data/bin/console +0 -14
- data/bin/gemstash +0 -3
- data/bin/setup +0 -5
- data/docs/config.md +0 -136
- data/docs/debug.md +0 -24
- data/docs/deploy.md +0 -30
- data/docs/mirror.md +0 -30
- data/docs/multiple_sources.md +0 -68
- data/docs/private_gems.md +0 -140
- data/docs/reference.md +0 -308
- data/gemstash.gemspec +0 -47
- data/gemstash.png +0 -0
- data/lib/gemstash/gem_unyanker.rb +0 -61
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: bafa064aa396390248f3259372d3ba055174fcaab399cd1e8d3c0e4ddcecdf4c
|
4
|
+
data.tar.gz: 47e818b43ba9632d805f23aa75e645da1c0f52a1de443a969d9d3df0409b26c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7d1082fc37b03770575dc99e9626b83da40af72f9a731501e3737240b144685b14945957f5128b2dc31772d2108a060cdbb4d5a6315611705bff5c5b4e13c54
|
7
|
+
data.tar.gz: 54547a4b9791bda410bb4480977f1c9ab4c47b60060def54d819fb5bc5865e6974fb4ee5fce58e957fd18d5cae5e91b41f4f78c7e72d3647b5a91eedcf7888ba
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,295 @@
|
|
1
|
+
## 2.5.0 (2023-09-28)
|
2
|
+
|
3
|
+
- Add support for upstream auth with ENV variables ([#339](https://github.com/rubygems/gemstash/pull/339), [@CiTroNaK](https://github.com/CiTroNaK))
|
4
|
+
|
5
|
+
## 2.4.0 (2023-09-27)
|
6
|
+
|
7
|
+
### Changes
|
8
|
+
|
9
|
+
- Support naming and listing authorizations ([#365](https://github.com/rubygems/gemstash/pull/365), [@kyrofa](https://github.com/kyrofa))
|
10
|
+
|
11
|
+
## 2.3.2 (2023-09-14)
|
12
|
+
|
13
|
+
### Fixes
|
14
|
+
|
15
|
+
- 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))
|
16
|
+
|
17
|
+
## 2.3.1 (2023-09-05)
|
18
|
+
|
19
|
+
### Fixes
|
20
|
+
|
21
|
+
- Reinstate Ruby Central in README. ([#353](https://github.com/rubygems/gemstash/pull/353), [@olleolleolle](https://github.com/olleolleolle))
|
22
|
+
- Implement Puma 5-required logger method `#sync` ([#355](https://github.com/rubygems/gemstash/pull/355), [@ball-hayden](https://github.com/ball-hayden))
|
23
|
+
|
24
|
+
## 2.3.0 (2023-08-30)
|
25
|
+
|
26
|
+
### Changes
|
27
|
+
|
28
|
+
- Support Puma 6. ([#335](https://github.com/rubygems/gemstash/pull/335), [@MSP-Greg](https://github.com/MSP-Greg))
|
29
|
+
- Make UpstreamSource intermediate specs from upstream. ([#337](https://github.com/rubygems/gemstash/pull/337), [@tedgarb](https://github.com/tedgarb))
|
30
|
+
- Mention RubyCentral. ([#338](https://github.com/rubygems/gemstash/pull/338), [@adarsh](https://github.com/adarsh))
|
31
|
+
- Configure Dependabot. ([#341](https://github.com/rubygems/gemstash/pull/341), [@olleolleolle](https://github.com/olleolleolle))
|
32
|
+
|
33
|
+
## 2.2.2 (2023-03-03)
|
34
|
+
|
35
|
+
### Changes
|
36
|
+
|
37
|
+
- Allow newer versions of the `activesupport` dependency ([#332](https://github.com/rubygems/gemstash/pull/332), [@kyrofa](https://github.com/kyrofa))
|
38
|
+
|
39
|
+
## 2.2.1 (2023-02-09)
|
40
|
+
|
41
|
+
### Bugfixes
|
42
|
+
|
43
|
+
- Add permitted classes to a `YAML.load` in cache ([#329](https://github.com/rubygems/gemstash/pull/329), [@SocalNick](https://github.com/SocialNick))
|
44
|
+
|
45
|
+
## 2.2.0 (2023-01-27)
|
46
|
+
|
47
|
+
### Bugfixes
|
48
|
+
|
49
|
+
- Respect auth set in upstream host uri ([#317](https://github.com/rubygems/gemstash/pull/317), [@jebentier](https://github.com/jbentier))
|
50
|
+
- 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))
|
51
|
+
|
52
|
+
### Changes
|
53
|
+
|
54
|
+
- Support Ruby 3 ([#312](https://github.com/rubygems/gemstash/pull/312), [@tonytonyjan](https://github.com/tonytonyjan))
|
55
|
+
- 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))
|
56
|
+
- Update `dalli` dependency ([#324](https://github.com/rubygems/gemstash/pull/324), [@indirect](https://github.com/indirect))
|
57
|
+
- Also thanks to: [@indirect][] and [@hsbt][] who fixed CI issues and lint warnings.
|
58
|
+
|
59
|
+
## 2.1.0 (2020-02-26)
|
60
|
+
|
61
|
+
### Bugfixes
|
62
|
+
|
63
|
+
- Shebang should be the first thing in the file ([#222](https://github.com/rubygems/gemstash/pull/222), [@bronzdoc](https://github.com/bronzdoc))
|
64
|
+
|
65
|
+
### Changes
|
66
|
+
|
67
|
+
- Update rack-test requirement from ~> 0.6 to ~> 1.1 ([#199](https://github.com/rubygems/gemstash/pull/199), [@dependabot](https://github.com/dependabot))
|
68
|
+
- Update rake requirement from ~> 10.0 to ~> 12.3 ([#200](https://github.com/rubygems/gemstash/pull/200), [@dependabot](https://github.com/dependabot))
|
69
|
+
- CI matrix: Drop 2.0, 2.1, 2.2 ([#201](https://github.com/rubygems/gemstash/pull/201), [@olleolleolle](https://github.com/olleolleolle))
|
70
|
+
- 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))
|
71
|
+
- Update rubocop requirement from = 0.60.0 to = 0.61.0 ([#208](https://github.com/rubygems/gemstash/pull/208), [@dependabot](https://github.com/dependabot))
|
72
|
+
- Update rubocop requirement from = 0.61.0 to = 0.61.1 ([#209](https://github.com/rubygems/gemstash/pull/209), [@dependabot](https://github.com/dependabot))
|
73
|
+
- Avoid Rubocop warnings ([#210](https://github.com/rubygems/gemstash/pull/210), [@olleolleolle](https://github.com/olleolleolle))
|
74
|
+
- RSpec: config.disable_monkey_patching! ([#211](https://github.com/rubygems/gemstash/pull/211), [@olleolleolle](https://github.com/olleolleolle))
|
75
|
+
- Travis: update JRuby to 9.2.5.0 ([#212](https://github.com/rubygems/gemstash/pull/212), [@olleolleolle](https://github.com/olleolleolle))
|
76
|
+
- Update rubocop requirement from = 0.61.1 to = 0.62.0 ([#213](https://github.com/rubygems/gemstash/pull/213), [@dependabot](https://github.com/dependabot))
|
77
|
+
- Update rubocop requirement from = 0.62.0 to = 0.63.0 ([#215](https://github.com/rubygems/gemstash/pull/215), [@dependabot](https://github.com/dependabot))
|
78
|
+
- gemspec: Allow Bundler 2 ([#217](https://github.com/rubygems/gemstash/pull/217), [@olleolleolle](https://github.com/olleolleolle))
|
79
|
+
- Update rubocop requirement from = 0.63.0 to = 0.63.1 ([#218](https://github.com/rubygems/gemstash/pull/218), [@dependabot](https://github.com/dependabot))
|
80
|
+
- Update rubocop requirement from = 0.63.1 to = 0.64.0 ([#220](https://github.com/rubygems/gemstash/pull/220), [@dependabot](https://github.com/dependabot))
|
81
|
+
- CI: matrix updates - update JRuby, add 2.6.1 ([#221](https://github.com/rubygems/gemstash/pull/221), [@olleolleolle](https://github.com/olleolleolle))
|
82
|
+
- 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))
|
83
|
+
- Update rubocop requirement from = 0.64.0 to = 0.65.0 ([#224](https://github.com/rubygems/gemstash/pull/224), [@dependabot](https://github.com/dependabot))
|
84
|
+
- CI: use 2.5.5, 2.6.2 ([#225](https://github.com/rubygems/gemstash/pull/225), [@olleolleolle](https://github.com/olleolleolle))
|
85
|
+
- 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))
|
86
|
+
- CI: Use 2.4.6 ([#228](https://github.com/rubygems/gemstash/pull/228), [@olleolleolle](https://github.com/olleolleolle))
|
87
|
+
- 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))
|
88
|
+
- CI: Drop 2.3.8 ([#230](https://github.com/rubygems/gemstash/pull/230), [@olleolleolle](https://github.com/olleolleolle))
|
89
|
+
- Update rubocop requirement from = 0.67.1 to = 0.67.2 ([#231](https://github.com/rubygems/gemstash/pull/231), [@dependabot](https://github.com/dependabot))
|
90
|
+
- CI: Use JRuby 9.2.7.0 ([#232](https://github.com/rubygems/gemstash/pull/232), [@olleolleolle](https://github.com/olleolleolle))
|
91
|
+
- 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))
|
92
|
+
- Update rubocop requirement from = 0.68.1 to = 0.69.0 ([#234](https://github.com/rubygems/gemstash/pull/234), [@dependabot](https://github.com/dependabot))
|
93
|
+
- Update rubocop requirement from = 0.69.0 to = 0.70.0 ([#235](https://github.com/rubygems/gemstash/pull/235), [@dependabot](https://github.com/dependabot))
|
94
|
+
- Set Travis badge to /rubygems user ([#236](https://github.com/rubygems/gemstash/pull/236), [@olleolleolle](https://github.com/olleolleolle))
|
95
|
+
- Fix broken links ([#240](https://github.com/rubygems/gemstash/pull/240), [@Aliciawyse](https://github.com/Aliciawyse))
|
96
|
+
- Fix various rubocop/codeclimate issues ([#241](https://github.com/rubygems/gemstash/pull/241), [@tchia04](https://github.com/tchia04))
|
97
|
+
- Fix some broken links in readme ([#243](https://github.com/rubygems/gemstash/pull/243), [@Aliciawyse](https://github.com/Aliciawyse))
|
98
|
+
- Improve webspec tests ([#244](https://github.com/rubygems/gemstash/pull/244), [@Aliciawyse](https://github.com/Aliciawyse))
|
99
|
+
- CI: Use jruby-9.2.8.0 ([#245](https://github.com/rubygems/gemstash/pull/245), [@olleolleolle](https://github.com/olleolleolle))
|
100
|
+
- 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))
|
101
|
+
- Add puma server pidfile configuration option ([#248](https://github.com/rubygems/gemstash/pull/248), [@krists](https://github.com/krists))
|
102
|
+
- CI: Use jruby-9.2.9.0 ([#249](https://github.com/rubygems/gemstash/pull/249), [@olleolleolle](https://github.com/olleolleolle))
|
103
|
+
- Officially drop support for older rubies ([#250](https://github.com/rubygems/gemstash/pull/250), [@deivid-rodriguez](https://github.com/deivid-rodriguez))
|
104
|
+
- Add config to ignore Gemfile source ([#253](https://github.com/rubygems/gemstash/pull/253), [@zpdcodes](https://github.com/zpdcodes))
|
105
|
+
- Update Puma gem ([#255](https://github.com/rubygems/gemstash/pull/255), [@bronzdoc](https://github.com/bronzdoc))
|
106
|
+
- Spec failures might be due to a bundler version ([#256](https://github.com/rubygems/gemstash/pull/256), [@bronzdoc](https://github.com/bronzdoc))
|
107
|
+
- Update spec homepage ([#257](https://github.com/rubygems/gemstash/pull/257), [@bronzdoc](https://github.com/bronzdoc))
|
108
|
+
- Update README.md links ([#258](https://github.com/rubygems/gemstash/pull/258), [@bronzdoc](https://github.com/bronzdoc))
|
109
|
+
- Add PR template ([#259](https://github.com/rubygems/gemstash/pull/259), [@bronzdoc](https://github.com/bronzdoc))
|
110
|
+
- Update docs ([#260](https://github.com/rubygems/gemstash/pull/260), [@bronzdoc](https://github.com/bronzdoc))
|
111
|
+
|
112
|
+
### Features
|
113
|
+
|
114
|
+
- 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))
|
115
|
+
|
116
|
+
## 2.0.0 (2018-11-18)
|
117
|
+
|
118
|
+
### Changes
|
119
|
+
|
120
|
+
- Breaking change: remove unyank support ([#119](https://github.com/bundler/gemstash/pull/119), [@olleolleolle](https://github.com/olleolleolle))
|
121
|
+
- 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))
|
122
|
+
- 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))
|
123
|
+
- Add a health check ([#146](https://github.com/bundler/gemstash/pull/146), [@smellsblue](https://github.com/smellsblue))
|
124
|
+
- Travis: jruby-9.1.12.0 ([#147](https://github.com/bundler/gemstash/pull/147), [@olleolleolle](https://github.com/olleolleolle))
|
125
|
+
- Typo fix in changelog tool ([#152](https://github.com/bundler/gemstash/pull/152), [@olleolleolle](https://github.com/olleolleolle))
|
126
|
+
- Rake: Turn rake task files into .rake files, auto-loaded ([#153](https://github.com/bundler/gemstash/pull/153), [@olleolleolle](https://github.com/olleolleolle))
|
127
|
+
- Travis: JRUBY_OPTS w/o invalid option jruby.cext.enabled ([#156](https://github.com/bundler/gemstash/pull/156), [@olleolleolle](https://github.com/olleolleolle))
|
128
|
+
- Suppress deprecation warnings in production code ([#162](https://github.com/bundler/gemstash/pull/162), [@koic](https://github.com/koic))
|
129
|
+
- Travis: jruby-9.1.13.0; use dist: "trusty" ([#167](https://github.com/bundler/gemstash/pull/167), [@olleolleolle](https://github.com/olleolleolle))
|
130
|
+
- Allow puma_workers configuration ([#168](https://github.com/bundler/gemstash/pull/168), [@HParker](https://github.com/HParker))
|
131
|
+
- Update Puma dependency to ~> 3.10 ([#169](https://github.com/bundler/gemstash/pull/169), [@premist](https://github.com/premist))
|
132
|
+
- gem: sequel v5.0.0 ([#170](https://github.com/bundler/gemstash/pull/170), [@olleolleolle](https://github.com/olleolleolle))
|
133
|
+
- Travis: Avoid jruby warning about MaxPermSize ([#171](https://github.com/bundler/gemstash/pull/171), [@olleolleolle](https://github.com/olleolleolle))
|
134
|
+
- 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))
|
135
|
+
- Update rubocop to .49 to fix CVE-2017-8418 ([#174](https://github.com/bundler/gemstash/pull/174), [@matthewalbani](https://github.com/matthewalbani))
|
136
|
+
- Add Ruby 2.5.1 to Travis build matrix ([#177](https://github.com/bundler/gemstash/pull/177), [@greysteil](https://github.com/greysteil))
|
137
|
+
- Skip stale jruby spec ([#178](https://github.com/bundler/gemstash/pull/178), [@bronzdoc](https://github.com/bronzdoc))
|
138
|
+
- Update sinatra dependency to >= 1.4, < 3.0 ([#179](https://github.com/bundler/gemstash/pull/179), [@bronzdoc](https://github.com/bronzdoc))
|
139
|
+
- gemspec: use Thor 0.20.0 ([#180](https://github.com/bundler/gemstash/pull/180), [@olleolleolle](https://github.com/olleolleolle))
|
140
|
+
- Travis: jruby-9.2.0.0 ([#181](https://github.com/bundler/gemstash/pull/181), [@olleolleolle](https://github.com/olleolleolle))
|
141
|
+
- do not set puma worker config when running jruby ([#183](https://github.com/bundler/gemstash/pull/183), [@andreaseger](https://github.com/andreaseger))
|
142
|
+
- Add health_tests table, and use in Gemstash::Health for idempotency ([#186](https://github.com/bundler/gemstash/pull/186), [@kurtzur](https://github.com/kurtzur))
|
143
|
+
- 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))
|
144
|
+
- Fix jruby builds ([#193](https://github.com/bundler/gemstash/pull/193), [@bronzdoc](https://github.com/bronzdoc))
|
145
|
+
|
146
|
+
### Features
|
147
|
+
|
148
|
+
- Allow stdout logging when running --no-daemonize ([#140](https://github.com/bundler/gemstash/pull/140), [@smellsblue](https://github.com/smellsblue))
|
149
|
+
|
150
|
+
## 1.1.0 (2017-07-31)
|
151
|
+
|
152
|
+
### Bugfixes
|
153
|
+
|
154
|
+
- Gracefully handle empty configuration files ([#97](https://github.com/bundler/gemstash/pull/97), [@rjocoleman](https://github.com/rjocoleman))
|
155
|
+
- Remove bundler-audit since we don't commit our Gemfile.lock ([#98](https://github.com/bundler/gemstash/pull/98), [@smellsblue](https://github.com/smellsblue))
|
156
|
+
- Clarify what is being cached for 30 minutes ([#108](https://github.com/bundler/gemstash/pull/108), [@Nowaker](https://github.com/Nowaker))
|
157
|
+
- Update documentation ([#112](https://github.com/bundler/gemstash/pull/112), [@smellsblue](https://github.com/smellsblue))
|
158
|
+
- Integration tests for searching for gems ([#113](https://github.com/bundler/gemstash/pull/113), [@smellsblue](https://github.com/smellsblue))
|
159
|
+
- Add `ruby-head` Gemfile for Travis ([#121](https://github.com/bundler/gemstash/pull/121), [@olleolleolle](https://github.com/olleolleolle))
|
160
|
+
- Make all Pandoc filters executable ([#122](https://github.com/bundler/gemstash/pull/122), [@olleolleolle](https://github.com/olleolleolle))
|
161
|
+
- Fix `rake doc` to work with newer versions of Pandoc ([#124](https://github.com/bundler/gemstash/pull/124), [@smellsblue](https://github.com/smellsblue))
|
162
|
+
- Use `curl` since `unyank` is removed in newer RubyGems versions ([#125](https://github.com/bundler/gemstash/pull/125), [@smellsblue](https://github.com/smellsblue))
|
163
|
+
- Touch up docs and update CHANGELOG ([#128](https://github.com/bundler/gemstash/pull/128), [@smellsblue](https://github.com/smellsblue))
|
164
|
+
- Update Travis to use ruby `2.3.3` ([#127](https://github.com/bundler/gemstash/pull/127), [@olleolleolle](https://github.com/olleolleolle))
|
165
|
+
- Add Ruby `2.4.0` to Travis ([#132](https://github.com/bundler/gemstash/pull/132), [@thedrow](https://github.com/thedrow))
|
166
|
+
|
167
|
+
### Features
|
168
|
+
|
169
|
+
- Add support for mysql2 adapter ([#71](https://github.com/bundler/gemstash/pull/71), [@chriseckhardt](https://github.com/chriseckhardt))
|
170
|
+
- Allow logging to a different file ([#74](https://github.com/bundler/gemstash/pull/74), [@mrchucho](https://github.com/mrchucho))
|
171
|
+
- Document temporary protected fetch solution ([#80](https://github.com/bundler/gemstash/pull/80), [@taoza](https://github.com/taoza))
|
172
|
+
- Make gem fetch timeout configurable ([#81](https://github.com/bundler/gemstash/pull/81), [@midwire](https://github.com/midwire))
|
173
|
+
- Document fallback timeout for when Gemstash is down ([#88](https://github.com/bundler/gemstash/pull/88), [@parndt](https://github.com/parndt))
|
174
|
+
- 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))
|
175
|
+
- Improve code climate ([#92](https://github.com/bundler/gemstash/pull/92), [@smellsblue](https://github.com/smellsblue))
|
176
|
+
- Refactor authorization ([#93](https://github.com/bundler/gemstash/pull/93), [@smellsblue](https://github.com/smellsblue), [@rjocoleman](https://github.com/rjocoleman))
|
177
|
+
- Add protected fetch for private gems ([#94](https://github.com/bundler/gemstash/pull/94), [@rjocoleman](https://github.com/rjocoleman))
|
178
|
+
- Add Ruby Together call to action ([#116](https://github.com/bundler/gemstash/pull/116), [@mrb](https://github.com/mrb))
|
179
|
+
- Configurable options to `Sequel.connect` ([#123](https://github.com/bundler/gemstash/pull/123), [@olleolleolle](https://github.com/olleolleolle))
|
180
|
+
- Support the `latest_specs.4.8.gz` endpoint for private gems ([#131](https://github.com/bundler/gemstash/pull/131), [@randycoulman](https://github.com/randycoulman))
|
181
|
+
- 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))
|
182
|
+
|
183
|
+
## 1.0.4 (2017-01-27)
|
184
|
+
|
185
|
+
### Features
|
186
|
+
|
187
|
+
- 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))
|
188
|
+
- Improve CHANGELOG generation and prepare for `1.0.4` release ([#135](https://github.com/bundler/gemstash/pull/135), [@smellsblue](https://github.com/smellsblue))
|
189
|
+
|
190
|
+
## 1.0.3 (2016-10-15)
|
191
|
+
|
192
|
+
### Bugfixes
|
193
|
+
|
194
|
+
- Fix JRuby build ([#110](https://github.com/bundler/gemstash/pull/110), [@smellsblue](https://github.com/smellsblue))
|
195
|
+
- 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))
|
196
|
+
|
197
|
+
### Features
|
198
|
+
|
199
|
+
- Embedded documentation via `gemstash help` ([#109](https://github.com/bundler/gemstash/pull/109), [@smellsblue](https://github.com/smellsblue))
|
200
|
+
|
201
|
+
## 1.0.2 (2016-07-07)
|
202
|
+
|
203
|
+
### Bugfixes
|
204
|
+
|
205
|
+
- Fix broken JRuby build ([#91](https://github.com/bundler/gemstash/pull/91), [@smellsblue](https://github.com/smellsblue))
|
206
|
+
- Drop www.rubygems.org in favor of rubygems.org ([#101](https://github.com/bundler/gemstash/pull/101), [@smellsblue](https://github.com/smellsblue))
|
207
|
+
- Redirect /versions and /info/* to index.rubygems.org ([#102](https://github.com/bundler/gemstash/pull/102), [@smellsblue](https://github.com/smellsblue))
|
208
|
+
- Backports to the 1.0 branch ([#103](https://github.com/bundler/gemstash/pull/103), [@smellsblue](https://github.com/smellsblue))
|
209
|
+
|
210
|
+
## 1.0.1 (2016-02-23)
|
211
|
+
|
212
|
+
### Bugfixes
|
213
|
+
|
214
|
+
- Don't pass along the Content-Length header ([#77](https://github.com/bundler/gemstash/pull/77), [@smellsblue](https://github.com/smellsblue))
|
215
|
+
|
216
|
+
## 1.0.0 (2015-12-25)
|
217
|
+
|
218
|
+
There are no changes since the last release.
|
219
|
+
|
220
|
+
## 1.0.0.pre.4 (2015-12-23)
|
221
|
+
|
222
|
+
### Upgrade Notes
|
223
|
+
|
224
|
+
Any gems fetched before this release won't be indexed, which means plugins you
|
225
|
+
might install can't know about them. These cached gems might also have
|
226
|
+
incorrect headers stored (which shouldn't affect bundling). If you wish to
|
227
|
+
correct this, you can delete or back up your cache by deleting or moving your
|
228
|
+
`~/.gemstash/gem_cache` directory.
|
229
|
+
|
230
|
+
### Bugfixes
|
231
|
+
|
232
|
+
- Cached gem and spec headers don't clobber each other ([#68](https://github.com/bundler/gemstash/pull/68), [@smellsblue](https://github.com/smellsblue))
|
233
|
+
|
234
|
+
### Features
|
235
|
+
|
236
|
+
- Index cached gems and their upstreams for future use of plugins ([#68](https://github.com/bundler/gemstash/pull/68), [@smellsblue](https://github.com/smellsblue))
|
237
|
+
|
238
|
+
## 1.0.0.pre.3 (2015-12-21)
|
239
|
+
|
240
|
+
### Bugfixes
|
241
|
+
|
242
|
+
- Fail on missing specified config ([#66](https://github.com/bundler/gemstash/pull/66), [@smellsblue](https://github.com/smellsblue))
|
243
|
+
|
244
|
+
## 1.0.0.pre.2 (2015-12-14)
|
245
|
+
|
246
|
+
### Upgrade Notes
|
247
|
+
|
248
|
+
- If you pushed any private gems to your Gemstash instance, you will need to run: https://gist.github.com/smellsblue/53f5a6757dcc91ad10bc
|
249
|
+
|
250
|
+
### Bugfixes
|
251
|
+
|
252
|
+
- Add --pre option to gemstash installation documentation ([#54](https://github.com/bundler/gemstash/pull/54), [@farukaydin](https://github.com/farukaydin))
|
253
|
+
- Fix docs for `gemstash authorize` ([#59](https://github.com/bundler/gemstash/pull/59), [@farukaydin](https://github.com/farukaydin))
|
254
|
+
- 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))
|
255
|
+
- Fix migrations for utf8 on MySQL >= 5.5 ([#64](https://github.com/bundler/gemstash/pull/64), [@chriseckhardt](https://github.com/chriseckhardt))
|
256
|
+
|
257
|
+
### Features
|
258
|
+
|
259
|
+
- Support MySQL as DB backend ([#52](https://github.com/bundler/gemstash/pull/52), [@pcarranza](https://github.com/pcarranza))
|
260
|
+
- Add start/stop output ([#58](https://github.com/bundler/gemstash/pull/58), [@farukaydin](https://github.com/farukaydin))
|
261
|
+
- Add `gemstash --version` ([#62](https://github.com/bundler/gemstash/pull/62), [@smellsblue](https://github.com/smellsblue))
|
262
|
+
- Create the CHANGELOG ([#63](https://github.com/bundler/gemstash/pull/63), [@smellsblue](https://github.com/smellsblue))
|
263
|
+
|
264
|
+
## 1.0.0.pre.1 (2015-11-30)
|
265
|
+
|
266
|
+
### Features
|
267
|
+
|
268
|
+
- Cache gems from multiple sources
|
269
|
+
- Push, yank, and unyank private gems
|
270
|
+
- Zero setup dependencies
|
271
|
+
- Optionally use Memcached for caching or PostgreSQL for the database
|
272
|
+
- Pull strategies and storage from bundler-api ([#5](https://github.com/bundler/gemstash/pull/5), [@pcarranza](https://github.com/pcarranza))
|
273
|
+
- Defer db connection test until sqlite db file exists ([#8](https://github.com/bundler/gemstash/pull/8), [@carpodaster](https://github.com/carpodaster))
|
274
|
+
- Integration specs ([#9](https://github.com/bundler/gemstash/pull/9), [@smellsblue](https://github.com/smellsblue))
|
275
|
+
- Logging all the things to a file ([#10](https://github.com/bundler/gemstash/pull/10), [@pcarranza](https://github.com/pcarranza))
|
276
|
+
- Gem sources ([#11](https://github.com/bundler/gemstash/pull/11), [@smellsblue](https://github.com/smellsblue))
|
277
|
+
- Forward http user agent to the upstream server ([#23](https://github.com/bundler/gemstash/pull/23), [@pcarranza](https://github.com/pcarranza))
|
278
|
+
- Documentation ([#25](https://github.com/bundler/gemstash/pull/25), [@smellsblue](https://github.com/smellsblue), [@pcarranza](https://github.com/pcarranza))
|
279
|
+
- Avoid filesystem limits using a trie ([#26](https://github.com/bundler/gemstash/pull/26), [@smellsblue](https://github.com/smellsblue))
|
280
|
+
- 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))
|
281
|
+
- Handle upstream connection error correctly and die with dignity ([#29](https://github.com/bundler/gemstash/pull/29), [@pcarranza](https://github.com/pcarranza))
|
282
|
+
- Add many ruby versions to travis configuration ([#31](https://github.com/bundler/gemstash/pull/31), [@pcarranza](https://github.com/pcarranza))
|
283
|
+
- Add rubygems version enforcement ([#32](https://github.com/bundler/gemstash/pull/32), [@pcarranza](https://github.com/pcarranza))
|
284
|
+
- Older RubyGems and Ruby 2.0.0 ([#33](https://github.com/bundler/gemstash/pull/33), [@smellsblue](https://github.com/smellsblue))
|
285
|
+
- Various fixes ([#34](https://github.com/bundler/gemstash/pull/34), [@smellsblue](https://github.com/smellsblue))
|
286
|
+
- Yanking gems ([#36](https://github.com/bundler/gemstash/pull/36), [@smellsblue](https://github.com/smellsblue))
|
287
|
+
- Use Sequel::Model ([#37](https://github.com/bundler/gemstash/pull/37), [@smellsblue](https://github.com/smellsblue))
|
288
|
+
- Build against JRuby ([#38](https://github.com/bundler/gemstash/pull/38), [@smellsblue](https://github.com/smellsblue))
|
289
|
+
- Unyanking gems ([#39](https://github.com/bundler/gemstash/pull/39), [@smellsblue](https://github.com/smellsblue))
|
290
|
+
- Add status command ([#40](https://github.com/bundler/gemstash/pull/40), [@smellsblue](https://github.com/smellsblue))
|
291
|
+
- Cache if gem is indexed in Gemstash::Storage ([#44](https://github.com/bundler/gemstash/pull/44), [@smellsblue](https://github.com/smellsblue))
|
292
|
+
- Full index bundling ([#45](https://github.com/bundler/gemstash/pull/45), [@smellsblue](https://github.com/smellsblue))
|
293
|
+
- Various fixes 2 ([#47](https://github.com/bundler/gemstash/pull/47), [@smellsblue](https://github.com/smellsblue))
|
294
|
+
- Various fixes 3 ([#49](https://github.com/bundler/gemstash/pull/49), [@smellsblue](https://github.com/smellsblue))
|
295
|
+
- Add Gemtash logo ([#50](https://github.com/bundler/gemstash/pull/50), [@jonathanrieta](https://github.com/jonathanrieta))
|
data/exe/gemstash
CHANGED
@@ -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
|
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
|
84
|
-
can?("
|
90
|
+
def fetch?
|
91
|
+
can?("fetch")
|
85
92
|
end
|
86
93
|
end
|
87
94
|
end
|
data/lib/gemstash/cache.rb
CHANGED
@@ -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 =
|
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 =
|
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.
|
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, "
|
28
|
-
|
29
|
-
|
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
|
-
|
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
|
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
|