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
data/README.md DELETED
@@ -1,139 +0,0 @@
1
- [![Build Status](https://travis-ci.org/bundler/gemstash.svg?branch=master)](https://travis-ci.org/bundler/gemstash)
2
-
3
- <p align="center"><img src="gemstash.png" /></p>
4
-
5
- ## What is Gemstash?
6
-
7
- Gemstash is both a cache for remote servers such as https://www.rubygems.org,
8
- and a private gem source.
9
-
10
- If you are using [bundler](http://bundler.io/) across many machines that have
11
- access to a server within your control, you might want to use Gemstash.
12
-
13
- If you produce gems that you don't want everyone in the world to have access to,
14
- you might want to use Gemstash.
15
-
16
- If you frequently bundle the same set of gems across multiple projects, you
17
- might want to use Gemstash.
18
-
19
- Are you only using gems from https://www.rubygems.org, and don't bundle the same
20
- gems frequently? Well, maybe you don't need Gemstash... yet.
21
-
22
- ## Quickstart Guide
23
-
24
- ### Setup
25
-
26
- Gemstash is designed to be quick and painless to get set up. By the end of this
27
- Quickstart Guide, you will be able to bundle stashed gems from public sources
28
- against a Gemstash server running on your machine.
29
-
30
- Install Gemstash to get started:
31
- ```
32
- $ gem install gemstash
33
- ```
34
-
35
- After it is installed, starting Gemstash requires no additional steps. Simply
36
- start the Gemstash server with the `gemstash` command:
37
- ```
38
- $ gemstash start
39
- ```
40
-
41
- You may have noticed that the command finished quickly. This is because Gemstash
42
- will run the server in the background by default. The server runs on port 9292.
43
-
44
- ### Bundling
45
-
46
- With the server running, you can bundle against it. Create a simple `Gemfile`
47
- like the following:
48
- ```ruby
49
- # ./Gemfile
50
- source "http://localhost:9292"
51
- gem "rubywarrior"
52
- ```
53
-
54
- The first line is important, as it will tell Bundler to use your new Gemstash
55
- server. The gems you include should be gems you don't yet have installed,
56
- otherwise Gemstash will have nothing to stash. Now bundle:
57
- ```
58
- $ bundle install --path .bundle
59
- ```
60
-
61
- Your Gemstash server has fetched the gems from https://www.rubygems.org and
62
- cached them for you! To prove this, you can disable your Internet connection and
63
- try again. The gem dependencies from https://www.rubygems.org are cached for 30
64
- minutes, so if you bundle again before that, you can successfully bundle without
65
- an Internet connection:
66
- ```
67
- $ # Disable your Internet first!
68
- $ rm -rf Gemfile.lock .bundle
69
- $ bundle
70
- ```
71
-
72
- ### Stopping the Server
73
-
74
- Once you've finish using your Gemstash server, you can stop it just as easily as
75
- you started it:
76
- ```
77
- $ gemstash stop
78
- ```
79
-
80
- ### Under the Hood
81
-
82
- You might wonder where the gems are stored. After running the commands above,
83
- you will find a new directory at `~/.gemstash`. This directory holds all the
84
- cached and private gems. It also has a server log, the database, and
85
- configuration for Gemstash. If you prefer, you can [point to a different
86
- directory](docs/config.md#files).
87
-
88
- Gemstash uses [SQLite](https://www.sqlite.org/) to store details about private
89
- gems. The database will be located in `~/.gemstash`, however you won't see the
90
- database appear until you start using private gems. If you prefer, you can [use
91
- a different database](docs/config.md#database).
92
-
93
- Gemstash temporarily caches things like gem dependencies in memory. Anything
94
- cached in memory will last for 30 minutes before being retrieved again. You can
95
- [use memcached](docs/config.md#cache) instead of caching in memory. Gem files
96
- are always cached permanently, so bundling with a `Gemfile.lock` with all gems
97
- cached will never call out to https://www.rubygems.org.
98
-
99
- The server you ran is provided via [Puma](http://puma.io/) and
100
- [Rack](http://rack.github.io/), however they are not customizable at this point.
101
-
102
- ## Deep Dive
103
-
104
- For a deep dive into the following subjects, follow the links:
105
- * [Private gems](docs/private_gems.md)
106
- * [Multiple gem sources](docs/multiple_sources.md)
107
- * [Using Gemstash as a mirror](docs/mirror.md)
108
- * [Customizing the server (database, storage, caching, and more)](docs/config.md)
109
- * [Deploying Gemstash](docs/deploy.md)
110
- * [Debugging Gemstash](docs/debug.md)
111
-
112
- ## Reference
113
-
114
- For an anatomy of various configuration and commands, follow the links:
115
- * [Configuration](docs/reference.md#configuration)
116
- * [Authorize](docs/reference.md#authorize)
117
- * [Start](docs/reference.md#start)
118
- * [Stop](docs/reference.md#stop)
119
- * [Status](docs/reference.md#status)
120
- * [Setup](docs/reference.md#setup)
121
-
122
- ## Development
123
-
124
- After checking out the repo, run `bin/setup` to install dependencies. Then, run
125
- `rake` to run RuboCop and the tests. While developing, you can run
126
- `bin/gemstash` to run Gemstash. You can also run `bin/console` for an
127
- interactive prompt that will allow you to experiment.
128
-
129
- ## Contributing
130
-
131
- Bug reports and pull requests are welcome on GitHub at
132
- https://github.com/bundler/gemstash. This project is intended to be a safe,
133
- welcoming space for collaboration, and contributors are expected to adhere to
134
- the [Contributor Covenant](CODE_OF_CONDUCT.md) code of conduct.
135
-
136
- ## License
137
-
138
- The gem is available as open source under the terms of the
139
- [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile DELETED
@@ -1,35 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
- require "rubocop/rake_task"
4
-
5
- RuboCop::RakeTask.new
6
-
7
- desc "Run specs"
8
- RSpec::Core::RakeTask.new(:spec) do |t|
9
- t.rspec_opts = %w(--color)
10
- end
11
-
12
- task :spec => :rubocop
13
- task :default => :spec
14
-
15
- desc "Generate Table of Contents for certain docs"
16
- task :toc do
17
- toc_dir = File.expand_path("../tmp/", __FILE__)
18
- toc = File.join(toc_dir, "gh-md-toc")
19
-
20
- unless File.exist?(toc)
21
- require "open-uri"
22
- toc_contents = open("https://raw.githubusercontent.com/ekalinin/github-markdown-toc/master/gh-md-toc", &:read)
23
- Dir.mkdir(toc_dir) unless Dir.exist?(toc_dir)
24
- File.write(toc, toc_contents)
25
- File.chmod(0776, toc)
26
- end
27
-
28
- doc = File.expand_path("../docs/reference.md", __FILE__)
29
- old_contents = File.read(doc)
30
- old_contents.sub!(/\A.*?^---$/m, "---")
31
- File.write(doc, old_contents)
32
- toc_contents = `"#{toc}" "#{doc}"`
33
- toc_contents.sub!(/Created by.*$/, "")
34
- File.write(doc, "#{toc_contents}\n#{old_contents}")
35
- end
data/bin/console DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "gemstash"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start
data/bin/gemstash DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require "bundler/setup"
3
- exec "exe/gemstash", *ARGV
data/bin/setup DELETED
@@ -1,5 +0,0 @@
1
- #!/bin/bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
-
5
- bundle install
data/docs/config.md DELETED
@@ -1,136 +0,0 @@
1
- # Customizing the Server
2
-
3
- Although Gemstash is designed for as minimal setup as possible, there may be
4
- times you will want to change some of the default configuration. By the end of
5
- this guide, you will be able to customize some of the Gemstash behavior,
6
- including where files are stored, what database Gemstash uses, and how Gemstash
7
- caches certain requests.
8
-
9
- ## Setup
10
-
11
- Several customizable options are available via an interactive Gemstash command.
12
- Run `gemstash setup` and answer the questions it provides (a blank answer will
13
- use the default value):
14
- <pre>
15
- $ gemstash setup
16
- Where should files go? [~/.gemstash]
17
- Cache with what? [MEMORY, memcached] <strong>memcached</strong>
18
- What is the comma separated Memcached servers? [localhost:11211]
19
- What database adapter? [SQLITE3, postgres] <strong>postgres</strong>
20
- Where is the database? [postgres:///gemstash]
21
- Checking that the cache is available
22
- Checking that the database is available
23
- The database is not available
24
- </pre>
25
-
26
- Once you've answered the questsions, some checks will be made to ensure the
27
- configuration will work. For example, the database didn't exist in the previous
28
- example, so the command failed and the configuration wasn't saved. If the
29
- command passes, you may provide the `--redo` option to force configuration to be
30
- redone:
31
- <pre>
32
- $ gemstash setup --redo
33
- Where should files go? [~/.gemstash]
34
- Cache with what? [MEMORY, memcached] <strong>memcached</strong>
35
- What is the comma separated Memcached servers? [localhost:11211]
36
- What database adapter? [SQLITE3, postgres]
37
- Checking that the cache is available
38
- Checking that the database is available
39
- You are all setup!
40
- </pre>
41
-
42
- Once all checks have passed, Gemstash will store your answers in the
43
- configuration file located at `~/.gemstash/config.yml`.
44
-
45
- ## Files
46
-
47
- Storage in Gemstash defaults to `~/.gemstash` unless otherwise specified. You
48
- can change this in your config file via the `:base_path` key:
49
- ```yaml
50
- # ~/.gemstash/config.yml
51
- ---
52
- :base_path: "/var/gemstash"
53
- ```
54
-
55
- When customizing the `base_path`, the directory must exist, otherwise Gemstash
56
- will fail to run. Thus, if you want to use `/var/gemstash` like in the previous
57
- example, make sure to `mkdir /var/gemstash` and grant access to the directory
58
- for the user you run Gemstash with.
59
-
60
- ## Database
61
-
62
- The `:db_adapter` configuration key specifies what database you will be using.
63
- The default `:db_adapter` is [`sqlite3`](https://www.sqlite.org/), which will
64
- use a database file located within your `:base_path`. The database file will
65
- always be named `gemstash.db`.
66
-
67
- You may also use [`postgres`](http://www.postgresql.org/) for your
68
- `:db_adapter`. When using PostgreSQL, you need to specify the `:db_url` to point
69
- to an existing database. Here is an example configuration to use the `postgres`
70
- adapter:
71
- ```yaml
72
- # ~/.gemstash/config.yml
73
- ---
74
- :db_adapter: postgres
75
- :db_url: postgres:///gemstash
76
- ```
77
-
78
- Regardless of the adapter you choose, the database will automatically migrate to
79
- your version of Gemstash whenever the database is needed. Except for `sqlite3`,
80
- you only need to ensure the database exists and Gemstash will do the rest.
81
-
82
- ## Cache
83
-
84
- Certain things (like dependencies) are cached in memory. This avoids web calls
85
- to the gem source, and database calls for private gems. The memory cache can
86
- optionally be swapped out with a [Memcached](http://memcached.org/) server (or
87
- cluster of servers). To use Memcached, you must update the `:cache_type`
88
- configuration key to be `memcached`, and provide the servers via the
89
- `:memcached_servers` configuration key:
90
- ```yaml
91
- # ~/.gemstash/config.yml
92
- ---
93
- :cache_type: memcached
94
- :memcached_servers: memcached1.local:11211,memcached2.local:11211
95
- ```
96
-
97
- Note that the `:memcached_servers` requires a comma separated list of servers.
98
- All caching lasts for 30 minutes.
99
-
100
- ## Server
101
-
102
- Gemstash uses [Puma](http://puma.io/) and [Rack](http://rack.github.io/) as the
103
- server. Alternate server configurations are not currently supported, but you can
104
- take a look at the [Puma configuration](../lib/gemstash/puma.rb) and the [rackup
105
- file](../lib/gemstash/config.ru) for inspiration.
106
-
107
- While the server is not customizable, the way Gemstash binds the port can be
108
- changed. To change the binding, update the `:bind` configuration key:
109
- ```yaml
110
- # ~/.gemstash/config.yml
111
- ---
112
- :bind: tcp://0.0.0.0:4242
113
- ```
114
-
115
- This maps directly to the [Puma bind
116
- flag](https://github.com/puma/puma#binding-tcp--sockets), and will support
117
- anything valid for that flag.
118
-
119
- ## Config File Location
120
-
121
- By default, configuration for Gemstash will be at `~/.gemstash/config.yml`. This
122
- can be changed by providing the `--config-file` option to the various Gemstash
123
- commands:
124
- ```
125
- $ gemstash setup --config-file ./gemstash-config.yml
126
- $ gemstash authorize --config-file ./gemstash-config.yml
127
- $ gemstash start --config-file ./gemstash-config.yml
128
- $ gemstash stop --config-file ./gemstash-config.yml
129
- $ gemstash status --config-file ./gemstash-config.yml
130
- ```
131
-
132
- When providing `--config-file` to `gemstash setup`, the provided file will be
133
- output to with the provided configuration. **This will overwrite** any existing
134
- configuration. If the file doesn't exist when providing `--config-file` to
135
- `gemstash start`, `gemstash stop`, `gemstash status`, and `gemstash authorize`,
136
- the default configuration will be used.
data/docs/debug.md DELETED
@@ -1,24 +0,0 @@
1
- # Debugging Gemstash
2
-
3
- If you are finding Gemstash isn't behaving as you would expect, you might want
4
- to start by looking at the server log. You can find the log at `server.log`
5
- within your base directory. By default, this will be at
6
- `~/.gemstash/server.log`.
7
-
8
- You might find it easier to view the log directly in your terminal. If you run
9
- Gemstash [in non-daemonized form](reference.md#--no-daemonize), the log will be
10
- output directly to standard out:
11
- ```
12
- $ gemstash start --no-daemonize
13
- ```
14
-
15
- You can also [check the status](reference.md#status) of the server:
16
- ```
17
- $ gemstash status
18
- ```
19
-
20
- The server status is checked by passing through to
21
- [pumactl](https://github.com/puma/puma#pumactl).
22
-
23
- If you find a bug, please don't hesitate to [open a bug
24
- report](../README.md#contributing)!
data/docs/deploy.md DELETED
@@ -1,30 +0,0 @@
1
- # Deploying Gemstash
2
-
3
- Bundler is here for the rescue to keep Gemstash up to date! Create a `Gemfile`
4
- pointing to Gemstash:
5
- ```ruby
6
- # ./Gemfile
7
- source "https://www.rubygems.org"
8
- gem "gemstash"
9
- ```
10
-
11
- Then `bundle` to create your `Gemfile.lock`. When you are ready to upgrade,
12
- simply `bundle update`. You may need to run `gemstash` via `bundle exec`.
13
- Alternatively, you can `gem uninstall gemstash` and `gem install gemstash` when
14
- you want to upgrade.
15
-
16
- Gemstash will automatically run any necessary migrations, so updating the gem is
17
- all that needs to be done.
18
-
19
- It is probably wise to stop Gemstash before upgrading, then starting again once
20
- you are done:
21
- ```
22
- $ bundle exec gemstash stop
23
- $ bundle update
24
- $ bundle exec gemstash start
25
- ```
26
-
27
- ## Downgrading
28
-
29
- It is not recommended to go backwards in Gemstash versions. Migrations may have
30
- run that could leave the database in a bad state.
data/docs/mirror.md DELETED
@@ -1,30 +0,0 @@
1
- # Using Gemstash as a Mirror
2
-
3
- If you don't have control over your `Gemfile`, or you don't want to force
4
- everyone on your team to go through the Gemstash server, you can use Bundler
5
- mirroring to bundle against your Gemstash server.
6
-
7
- For each source in your `Gemfile`, add a mirror pointing to your Gemstash
8
- server:
9
- ```
10
- $ bundle config mirror.http://rubygems.org http://localhost:9292
11
- $ bundle config mirror.https://my.gem-source.local http://localhost:9292/upstream/$(ruby -rcgi -e 'puts CGI.escape("https://my.gem-source.local")')
12
- ```
13
-
14
- From now on, bundler will fetch gems from those sources via your Gemstash
15
- server.
16
-
17
- # Simpler Gemstash Mirrors
18
-
19
- **WARNING: This feature is not yet available.**
20
-
21
- **This feature requires Bundler to be at least version `1.11.0`.**
22
-
23
- If you are using Bundler version `1.11.0` or greater, the mirroring becomes a
24
- bit easier:
25
- ```
26
- $ bundle config mirror.http://rubygems.org http://localhost:9292
27
- $ bundle config mirror.https://my.gem-source.local http://localhost:9292
28
- ```
29
-
30
- Bundler will then send headers to Gemstash to indicate the correct upstream.
@@ -1,68 +0,0 @@
1
- # Multiple Gem Sources
2
-
3
- Gemstash will stash from any amount of gem sources. By the end of this guide,
4
- you will be able to bundle using multiple gem sources, all stashed within your
5
- Gemstash server.
6
-
7
- ## Default Source
8
-
9
- When you don't provide an explicit source (as with the [Quickstart
10
- Guide](../README.md#quickstart-guide)), your gems will be fetched from
11
- https://www.rubygems.org. This default source is not set in stone. To change it,
12
- you need only edit the Gemstash configuration found at `~/.gemstash/config.yml`:
13
- ```yaml
14
- # ~/.gemstash/config.yml
15
- ---
16
- :rubygems_url: https://my.gem-source.local
17
- ```
18
-
19
- Make sure to restart your Gemstash server after changing the config:
20
- ```
21
- $ gemstash stop
22
- $ gemstash start
23
- ```
24
-
25
- Once restarted, bundling against `http://localhost:9292` will fetch gems from
26
- `https://my.gem-source.local`. If you had bundled before making these changes,
27
- fear not; bundling with a different default gem source will store gems in a
28
- separate location, ensuring different sources won't leak between each other.
29
-
30
- ## Bundling with Multiple Sources
31
-
32
- Changing the default source won't help you if you need to bundle against
33
- https://www.rubygems.org along with additional sources. If you need to bundle
34
- with multiple gem sources, Gemstash doesn't need to be specially configured.
35
- Your Gemstash server will honor any gem source specified via a specialized URL.
36
- Consider the following `Gemfile`:
37
- ```ruby
38
- # ./Gemfile
39
- require "cgi"
40
- source "http://localhost:9292"
41
- gem "rubywarrior"
42
-
43
- source "http://localhost:9292/upstream/#{CGI.escape("https://my.gem-source.local")}" do
44
- gem "my-gem"
45
- end
46
- ```
47
-
48
- Notice the `CGI.escape` call in the second source. This is important, as it
49
- properly URL escapes the source URL so Gemstash knows what gem source you want.
50
- The `/upstream` prefix tells Gemstash to use a gem source other than the default
51
- source. You can now bundle with the additional source.
52
-
53
- ## Redirecting
54
-
55
- Gemstash supports an alternate mode of specifying your gem sources. If you want
56
- Gemstash to redirect Bundler to your given gem sources, then you can specify
57
- your `Gemfile` like so:
58
- ```ruby
59
- # ./Gemfile
60
- require "cgi"
61
- source "http://localhost:9292/redirect/#{CGI.escape("https://www.rubygems.org")}"
62
- gem "rubywarrior"
63
- ```
64
-
65
- Notice the `/redirect` prefix. This prefix tells Gemstash to redirect API calls
66
- to the provided URL. Redirected calls like this will not be cached by Gemstash,
67
- and gem files will not be stashed, even if they were previously cached or
68
- stashed from the same gem source.
data/docs/private_gems.md DELETED
@@ -1,140 +0,0 @@
1
- # Private Gems
2
-
3
- Stashing private gems in your Gemstash server requires a bit of additional
4
- setup. If you haven't read through the [Quickstart
5
- Guide](../README.md#quickstart-guide), you should do that first. By the end of
6
- this guide, you will be able to interact with your Gemstash server to store and
7
- retrieve your private gems.
8
-
9
- ## Authorizing
10
-
11
- **IMPORTANT NOTE:** Do not use the actual key value in this document, otherwise
12
- your Gemstash server will be vulnerable to anyone who wants to try to use the
13
- key against your server. Instead of the key value here, use whatever key is
14
- generated from running the commands.
15
-
16
- In order to push a gem to your Gemstash server, you need to first create an API
17
- key. Utilize the `gemstash` command to create the API key:
18
- ```
19
- $ gemstash authorize
20
- Your new key is: e374e237fdf5fa5718d2a21bd63dc911
21
- ```
22
-
23
- This new key can `push`, `yank`, and `unyank` gems from your Gemstash server.
24
- Run `gemstash authorize` with just the permissions you want to limit what the
25
- key will be allowed to do. You can similarly update a specific key by providing
26
- it via the `--key` option:
27
- ```
28
- $ gemstash authorize push yank --key e374e237fdf5fa5718d2a21bd63dc911
29
- ```
30
-
31
- When no permissions are provided (like the first example), the key will be
32
- authorized for all permissions. Leave the key authorized with everything if you
33
- want to use it to try all private gem interactions:
34
- ```
35
- $ gemstash authorize --key e374e237fdf5fa5718d2a21bd63dc911
36
- ```
37
-
38
- With the key generated, you'll need to tell Rubygems about your new key. If
39
- you've pushed a gem to https://www.rubygems.org, then you will already have a
40
- credentials file to add the key to. If not, run the following commands before
41
- modifying the credentials file:
42
- ```
43
- $ mkdir -p ~/.gem
44
- $ touch ~/.gem/credentials
45
- $ chmod 0600 ~/.gem/credentials
46
- ```
47
-
48
- Add your new key to credentials such that it looks something like this (but make
49
- sure not to remove any existing keys):
50
- ```yaml
51
- # ~/.gem/credentials
52
- ---
53
- :test_key: e374e237fdf5fa5718d2a21bd63dc911
54
- ```
55
-
56
- The name `test_key` can be anything you want, but you will need to remember it
57
- and use it again later in this guide for the `--key` option.
58
-
59
- ## Creating a Test Gem
60
-
61
- You'll need a test gem before you can play with private gems on your Gemstash
62
- server. If you have a gem you can use, move along to the next section. You can
63
- start by instantiating a test gem via Bundler:
64
- ```
65
- $ bundle gem private-example
66
- ```
67
-
68
- You'll need to add a summary and description to the new gem's gemspec file in
69
- order to successfully build it. Once you've built the gem, you will be ready to
70
- push the new gem.
71
- ```
72
- $ cd private-example
73
- $ rake build
74
- ```
75
-
76
- You will now have a gem at `private-example/pkg/private-example-0.1.0.gem`.
77
-
78
- ## Pushing
79
-
80
- If your Gemstash server isn't running, go ahead and start it:
81
- ```
82
- $ gemstash start
83
- ```
84
-
85
- Push your test gem using Rubygems:
86
- ```
87
- $ gem push --key test_key --host http://localhost:9292/private pkg/private-example-0.1.0.gem
88
- ```
89
-
90
- The `/private` portion of the `--host` option tells Gemstash you are interacting
91
- with the private gems. Gemstash will not let you push, yank, or unyank from
92
- anything except `/private`.
93
-
94
- ## Bundling
95
-
96
- Once your gem is pushed to your Gemstash server, you are ready to bundle it.
97
- Create a `Gemfile` and specify the gem. You will probably want to wrap the
98
- private gem in a source block, and let the rest of Gemstash handle all other
99
- gems:
100
- ```ruby
101
- # ./Gemfile
102
- source "http://localhost:9292"
103
- gem "rubywarrior"
104
-
105
- source "http://localhost:9292/private" do
106
- gem "private-example"
107
- end
108
- ```
109
-
110
- Notice that the Gemstash server points to `/private` again when installing your
111
- private gem. Go ahead and bundle to install your new private gem:
112
- ```
113
- $ bundle
114
- ```
115
-
116
- ## Yanking
117
-
118
- If you push a private gem by accident, you can yank the gem with Rubygems:
119
- ```
120
- $ RUBYGEMS_HOST=http://localhost:9292/private gem yank --key test_key private-example --version 0.1.0
121
- ```
122
-
123
- Like with pushing, the `/private` portion of the host option tells Gemstash you
124
- are interacting with private gems. Gemstash will only let you yank from
125
- `/private`. Unlike pushing, Rubygems doesn't support `--host` for yank and
126
- unyank (yet), so you need to specify the host via the `RUBYGEMS_HOST`
127
- environment variable.
128
-
129
- ## Unyanking
130
-
131
- If you yank a private gem by accident, you can unyank the gem with Rubygems:
132
- ```
133
- $ RUBYGEMS_HOST=http://localhost:9292/private gem yank --key test_key private-example --version 0.1.0 --undo
134
- ```
135
-
136
- Like with pushing and yanking, the `/private` portion of the host option tells
137
- Gemstash you are interacting with private gems. Gemstash will only let you
138
- unyank from `/private`. Unlike pushing, Rubygems doesn't support `--host` for
139
- unyank and yank (yet), so you need to specify the host via the `RUBYGEMS_HOST`
140
- environment variable.