gemstash 2.1.0 → 2.2.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +57 -0
- data/lib/gemstash/cache.rb +37 -0
- data/lib/gemstash/cli/authorize.rb +2 -2
- data/lib/gemstash/cli/setup.rb +11 -3
- data/lib/gemstash/configuration.rb +1 -1
- data/lib/gemstash/dependencies.rb +2 -2
- data/lib/gemstash/env.rb +2 -0
- data/lib/gemstash/gem_fetcher.rb +2 -2
- data/lib/gemstash/gem_pusher.rb +2 -2
- data/lib/gemstash/gem_source/private_source.rb +3 -3
- data/lib/gemstash/gem_source.rb +2 -2
- data/lib/gemstash/http_client.rb +8 -3
- data/lib/gemstash/logging.rb +1 -1
- data/lib/gemstash/man/gemstash-authorize.1.txt +0 -45
- data/lib/gemstash/man/gemstash-configuration.5.txt +0 -209
- data/lib/gemstash/man/gemstash-customize.7.txt +0 -186
- data/lib/gemstash/man/gemstash-debugging.7.txt +0 -28
- data/lib/gemstash/man/gemstash-deploy.7.txt +0 -58
- data/lib/gemstash/man/gemstash-mirror.7.txt +0 -32
- data/lib/gemstash/man/gemstash-multiple-sources.7.txt +0 -70
- data/lib/gemstash/man/gemstash-private-gems.7.txt +0 -155
- data/lib/gemstash/man/gemstash-readme.7.txt +0 -181
- data/lib/gemstash/man/gemstash-setup.1.txt +0 -39
- data/lib/gemstash/man/gemstash-start.1.txt +0 -25
- data/lib/gemstash/man/gemstash-status.1.txt +0 -21
- data/lib/gemstash/man/gemstash-stop.1.txt +0 -21
- data/lib/gemstash/man/gemstash-version.1.txt +0 -20
- data/lib/gemstash/storage.rb +5 -4
- data/lib/gemstash/upstream.rb +6 -5
- data/lib/gemstash/version.rb +2 -2
- data/lib/gemstash/web.rb +6 -4
- data/lib/gemstash.rb +1 -1
- metadata +31 -171
- data/lib/gemstash/man/gemstash-authorize.1 +0 -51
- data/lib/gemstash/man/gemstash-configuration.5 +0 -229
- data/lib/gemstash/man/gemstash-customize.7 +0 -301
- data/lib/gemstash/man/gemstash-debugging.7 +0 -34
- data/lib/gemstash/man/gemstash-deploy.7 +0 -72
- data/lib/gemstash/man/gemstash-mirror.7 +0 -40
- data/lib/gemstash/man/gemstash-multiple-sources.7 +0 -89
- data/lib/gemstash/man/gemstash-private-gems.7 +0 -227
- data/lib/gemstash/man/gemstash-readme.7 +0 -233
- data/lib/gemstash/man/gemstash-setup.1 +0 -43
- data/lib/gemstash/man/gemstash-start.1 +0 -26
- data/lib/gemstash/man/gemstash-status.1 +0 -20
- data/lib/gemstash/man/gemstash-stop.1 +0 -20
- data/lib/gemstash/man/gemstash-version.1 +0 -22
@@ -1,187 +1 @@
|
|
1
|
-
gemstash-customize(7) gemstash-customize(7)
|
2
1
|
|
3
|
-
|
4
|
-
|
5
|
-
1mCUSTOMIZING THE SERVER0m
|
6
|
-
Although Gemstash is designed for as minimal setup as possible, there
|
7
|
-
may be times you will want to change some of the default configuration.
|
8
|
-
By the end of this guide, you will be able to customize some of the
|
9
|
-
Gemstash behavior, including where files are stored, what database Gem-
|
10
|
-
stash uses, and how Gemstash caches certain requests.
|
11
|
-
|
12
|
-
1mSETUP0m
|
13
|
-
Several customizable options are available via an interactive Gemstash
|
14
|
-
command. Run gemstash setup and answer the questions it provides (a
|
15
|
-
blank answer will use the default value):
|
16
|
-
|
17
|
-
$ gemstash setup
|
18
|
-
Where should files go? [~/.gemstash]
|
19
|
-
Cache with what? [MEMORY, memcached] 1mmemcached0m
|
20
|
-
What is the comma separated Memcached servers? [local-
|
21
|
-
host:11211]
|
22
|
-
What database adapter? [SQLITE3, postgres, mysql, mysql2] 1mpost-0m
|
23
|
-
1mgres0m
|
24
|
-
Where is the database? [postgres:///gemstash]
|
25
|
-
Checking that the cache is available
|
26
|
-
Checking that the database is available
|
27
|
-
The database is not available
|
28
|
-
Once you've answered the questions, some checks will be made to ensure
|
29
|
-
the configuration will work. For example, the database didn't exist in
|
30
|
-
the previous example, so the command failed and the configuration
|
31
|
-
wasn't saved. If the command passes, you may provide the --redo option
|
32
|
-
to force configuration to be redone:
|
33
|
-
|
34
|
-
$ gemstash setup --redo
|
35
|
-
Where should files go? [~/.gemstash]
|
36
|
-
Cache with what? [MEMORY, memcached] 1mmemcached0m
|
37
|
-
What is the comma separated Memcached servers? [local-
|
38
|
-
host:11211]
|
39
|
-
What database adapter? [SQLITE3, postgres, mysql, mysql2]
|
40
|
-
Checking that the cache is available
|
41
|
-
Checking that the database is available
|
42
|
-
You are all setup!
|
43
|
-
Once all checks have passed, Gemstash will store your answers in the
|
44
|
-
configuration file located at ~/.gemstash/config.yml.
|
45
|
-
|
46
|
-
1mFILES0m
|
47
|
-
Storage in Gemstash defaults to ~/.gemstash unless otherwise specified.
|
48
|
-
You can change this in your config file via the :base_path key:
|
49
|
-
|
50
|
-
# ~/.gemstash/config.yml
|
51
|
-
---
|
52
|
-
:base_path: "/var/gemstash"
|
53
|
-
|
54
|
-
When customizing the base_path, the directory must exist, otherwise
|
55
|
-
Gemstash will fail to run. Thus, if you want to use /var/gemstash like
|
56
|
-
in the previous example, make sure to mkdir /var/gemstash and grant ac-
|
57
|
-
cess to the directory for the user you run Gemstash with.
|
58
|
-
|
59
|
-
1mDATABASE0m
|
60
|
-
The :db_adapter configuration key specifies what database you will be
|
61
|
-
using. The default :db_adapter is sqlite3 (https://www.sqlite.org/),
|
62
|
-
which will use a database file located within your :base_path. The
|
63
|
-
database file will always be named gemstash.db.
|
64
|
-
|
65
|
-
You may also use postgres (http://www.postgresql.org/), mysql
|
66
|
-
(http://www.mysql.com/), or mysql2 (http://sequel.jeremye-
|
67
|
-
vans.net/rdoc/files/doc/opening_databases_rdoc.html#label-mysql2) for
|
68
|
-
your :db_adapter. When using any of these options, you need to specify
|
69
|
-
the :db_url to point to an existing database. Here is an example con-
|
70
|
-
figuration to use the postgres adapter:
|
71
|
-
|
72
|
-
# ~/.gemstash/config.yml
|
73
|
-
---
|
74
|
-
:db_adapter: postgres
|
75
|
-
:db_url: postgres:///gemstash
|
76
|
-
:db_connection_options: # Sequel.connect options
|
77
|
-
:connect_timeout: 10
|
78
|
-
:read_timeout: 5
|
79
|
-
:timeout: 30
|
80
|
-
|
81
|
-
Regardless of the adapter you choose, the database will automatically
|
82
|
-
migrate to your version of Gemstash whenever the database is needed.
|
83
|
-
You only need to ensure the database exists and Gemstash will do the
|
84
|
-
rest, except for sqlite3 (for which Gemstash will also create the data-
|
85
|
-
base for you).
|
86
|
-
|
87
|
-
1mCACHE0m
|
88
|
-
Certain things (like dependencies) are cached in memory. This avoids
|
89
|
-
web calls to the gem source, and database calls for private gems.
|
90
|
-
|
91
|
-
# ~/.gemstash/config.yml
|
92
|
-
---
|
93
|
-
:cache_type: memory
|
94
|
-
:cache_max_size: 2000
|
95
|
-
|
96
|
-
This configuration uses the default memory cache, and has increased the
|
97
|
-
cache_max_size setting from its default of 500 items.
|
98
|
-
|
99
|
-
The memory cache can optionally be swapped out with a Memcached
|
100
|
-
(http://memcached.org/) server (or cluster of servers).
|
101
|
-
|
102
|
-
To use Memcached, use the memcached :cache_type configuration.
|
103
|
-
|
104
|
-
Provide the servers as a comma-separated list to the :memcached_servers
|
105
|
-
configuration key:
|
106
|
-
|
107
|
-
# ~/.gemstash/config.yml
|
108
|
-
---
|
109
|
-
:cache_type: memcached
|
110
|
-
:memcached_servers: memcached1.local:11211,memcached2.local:11211
|
111
|
-
:cache_expiration: 1800
|
112
|
-
|
113
|
-
All caching expires in cache_expiration number of seconds. Default is
|
114
|
-
1800 seconds (30 minutes). This option applies to all caching.
|
115
|
-
|
116
|
-
1mSERVER0m
|
117
|
-
Gemstash uses Puma (http://puma.io/) and Rack (http://rack.github.io/)
|
118
|
-
as the server. Alternate server configurations are not currently sup-
|
119
|
-
ported, but you can take a look at the Puma configuration
|
120
|
-
(https://github.com/rubygems/gemstash/blob/master/lib/gemstash/puma.rb)
|
121
|
-
and the rackup file (https://github.com/rubygems/gemstash/blob/mas-
|
122
|
-
ter/lib/gemstash/config.ru) for inspiration.
|
123
|
-
|
124
|
-
While the server is not customizable, the way Gemstash binds the port
|
125
|
-
can be changed. To change the binding, update the :bind configuration
|
126
|
-
key:
|
127
|
-
|
128
|
-
# ~/.gemstash/config.yml
|
129
|
-
---
|
130
|
-
:bind: tcp://0.0.0.0:4242
|
131
|
-
|
132
|
-
This maps directly to the Puma bind flag
|
133
|
-
(https://github.com/puma/puma#binding-tcp--sockets), and will support
|
134
|
-
anything valid for that flag.
|
135
|
-
|
136
|
-
The number of threads Puma uses is also customizable via the
|
137
|
-
:puma_threads configuration key. The default is 16.
|
138
|
-
|
139
|
-
1mPROTECTED FETCH0m
|
140
|
-
Gemstash by default allows unauthenticated access for private gems.
|
141
|
-
Authenticated access is available via the :protected_fetch configura-
|
142
|
-
tion key.
|
143
|
-
|
144
|
-
# ~/.gemstash/config.yml
|
145
|
-
---
|
146
|
-
:protected_fetch: true
|
147
|
-
|
148
|
-
More details on protected_fetch are here (gemstash help private-
|
149
|
-
gems.7).
|
150
|
-
|
151
|
-
1mFETCH TIMEOUT0m
|
152
|
-
The default fetch timeout is 20 seconds. Use the :fetch_timeout con-
|
153
|
-
figuration key to change it.
|
154
|
-
|
155
|
-
---
|
156
|
-
:fetch_timeout: 20
|
157
|
-
|
158
|
-
1mCONFIG FILE LOCATION0m
|
159
|
-
By default, configuration for Gemstash will be at ~/.gemstash/con-
|
160
|
-
fig.yml. This can be changed by providing the --config-file option to
|
161
|
-
the various Gemstash commands:
|
162
|
-
|
163
|
-
$ gemstash setup --config-file ./gemstash-config.yml
|
164
|
-
$ gemstash authorize --config-file ./gemstash-config.yml
|
165
|
-
$ gemstash start --config-file ./gemstash-config.yml
|
166
|
-
$ gemstash stop --config-file ./gemstash-config.yml
|
167
|
-
$ gemstash status --config-file ./gemstash-config.yml
|
168
|
-
|
169
|
-
When providing --config-file to gemstash setup, the provided file will
|
170
|
-
be output to with the provided configuration. 1mThis will overwrite 22many
|
171
|
-
existing configuration. If the file doesn't exist when providing
|
172
|
-
--config-file to gemstash start, gemstash stop, gemstash status, and
|
173
|
-
gemstash authorize, the default configuration will be used.
|
174
|
-
|
175
|
-
1mERB PARSED CONFIG0m
|
176
|
-
You may also create a ~/.gemstash/config.yml.erb file. If present,
|
177
|
-
this will be used instead of ~/.gemstash/config.yml. For example, with
|
178
|
-
this you can use environment variables in the config:
|
179
|
-
|
180
|
-
# ~/.gemstash/config.yml.erb
|
181
|
-
---
|
182
|
-
:db_adapter: postgres
|
183
|
-
:db_url: <%= ENV["DATABASE_URL"] %>
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
October 28, 2015 gemstash-customize(7)
|
@@ -1,29 +1 @@
|
|
1
|
-
gemstash-debugging(7) gemstash-debugging(7)
|
2
1
|
|
3
|
-
|
4
|
-
|
5
|
-
1mDEBUGGING GEMSTASH0m
|
6
|
-
If you are finding Gemstash isn't behaving as you would expect, you
|
7
|
-
might want to start by looking at the server log. You can find the log
|
8
|
-
at server.log within your base directory. By default, this will be at
|
9
|
-
~/.gemstash/server.log.
|
10
|
-
|
11
|
-
You might find it easier to view the log directly in your terminal. If
|
12
|
-
you run Gemstash in non-daemonized form (gemstash help start.1), the
|
13
|
-
log will be output directly to standard out:
|
14
|
-
|
15
|
-
$ gemstash start --no-daemonize
|
16
|
-
|
17
|
-
You can also check the status (gemstash help status.1) of the server:
|
18
|
-
|
19
|
-
$ gemstash status
|
20
|
-
|
21
|
-
The server status is checked by passing through to pumactl
|
22
|
-
(https://github.com/puma/puma#pumactl).
|
23
|
-
|
24
|
-
If you find a bug, please don't hesitate to open a bug report
|
25
|
-
(https://github.com/rubygems/gemstash#contributing)!
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
October 28, 2015 gemstash-debugging(7)
|
@@ -1,59 +1 @@
|
|
1
|
-
gemstash-deploy(7) gemstash-deploy(7)
|
2
1
|
|
3
|
-
|
4
|
-
|
5
|
-
1mDEPLOYING GEMSTASH0m
|
6
|
-
Bundler is here for the rescue to keep Gemstash up to date! Create a
|
7
|
-
Gemfile pointing to Gemstash:
|
8
|
-
|
9
|
-
# ./Gemfile
|
10
|
-
source "https://rubygems.org"
|
11
|
-
gem "gemstash"
|
12
|
-
|
13
|
-
Then bundle to create your Gemfile.lock. When you are ready to up-
|
14
|
-
grade, simply bundle update. You may need to run gemstash via bundle
|
15
|
-
exec. Alternatively, you can gem uninstall gemstash and gem install
|
16
|
-
gemstash when you want to upgrade.
|
17
|
-
|
18
|
-
Gemstash will automatically run any necessary migrations, so updating
|
19
|
-
the gem is all that needs to be done.
|
20
|
-
|
21
|
-
It is probably wise to stop Gemstash before upgrading, then starting
|
22
|
-
again once you are done:
|
23
|
-
|
24
|
-
$ bundle exec gemstash stop
|
25
|
-
$ bundle update
|
26
|
-
$ bundle exec gemstash start
|
27
|
-
|
28
|
-
1mMONITORING0m
|
29
|
-
Health monitoring is built in to Gemstash using the serv-
|
30
|
-
er_health_check-rack (https://github.com/on-site/server_health_check-
|
31
|
-
rack) gem. If you request /health from your Gemstash instance, you
|
32
|
-
will get a JSON response along with an HTTP status code indicating suc-
|
33
|
-
cess or failure. The JSON response will look something like this for a
|
34
|
-
success case:
|
35
|
-
|
36
|
-
{
|
37
|
-
"status": {
|
38
|
-
"heartbeat": "OK",
|
39
|
-
"storage_read": "OK",
|
40
|
-
"storage_write": "OK",
|
41
|
-
"db_read": "OK",
|
42
|
-
"db_write": "OK"
|
43
|
-
}
|
44
|
-
}
|
45
|
-
|
46
|
-
This request will test storage and database access and report on the
|
47
|
-
result. Each key in the status can be requested alone to just report
|
48
|
-
on that status. For example, if you would like a health check that
|
49
|
-
doesn't interact with storage or the database, you can use
|
50
|
-
/health/heartbeat which will always respond with a success while your
|
51
|
-
Gemstash server is running.
|
52
|
-
|
53
|
-
1mDOWNGRADING0m
|
54
|
-
It is not recommended to go backwards in Gemstash versions. Migrations
|
55
|
-
may have run that could leave the database in a bad state.
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
October 25, 2015 gemstash-deploy(7)
|
@@ -1,33 +1 @@
|
|
1
|
-
gemstash-mirror(7) gemstash-mirror(7)
|
2
1
|
|
3
|
-
|
4
|
-
|
5
|
-
1mUSING GEMSTASH AS A MIRROR0m
|
6
|
-
If you don't have control over your Gemfile, or you don't want to force
|
7
|
-
everyone on your team to go through the Gemstash server, you can use
|
8
|
-
Bundler mirroring to bundle against your Gemstash server.
|
9
|
-
|
10
|
-
For each source in your Gemfile, add a mirror pointing to your Gemstash
|
11
|
-
server:
|
12
|
-
|
13
|
-
$ bundle config mirror.http://rubygems.org http://localhost:9292
|
14
|
-
$ bundle config mirror.https://my.gem-source.local http://localhost:9292/upstream/$(ruby -rcgi -e 'puts CGI.escape("https://my.gem-source.local")')
|
15
|
-
|
16
|
-
From now on, bundler will fetch gems from those sources via your Gem-
|
17
|
-
stash server.
|
18
|
-
|
19
|
-
1mSIMPLER GEMSTASH MIRRORS0m
|
20
|
-
1mThis feature requires Bundler to be at least version 1.11.0.0m
|
21
|
-
|
22
|
-
If you are using Bundler version 1.11.0 or greater, the mirroring be-
|
23
|
-
comes a bit easier:
|
24
|
-
|
25
|
-
$ bundle config mirror.http://rubygems.org http://localhost:9292
|
26
|
-
$ bundle config mirror.https://my.gem-source.local http://localhost:9292
|
27
|
-
|
28
|
-
Bundler will then send headers to Gemstash to indicate the correct up-
|
29
|
-
stream.
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
October 25, 2015 gemstash-mirror(7)
|
@@ -1,71 +1 @@
|
|
1
|
-
gemstash-multiple-sources(7) gemstash-multiple-sources(7)
|
2
1
|
|
3
|
-
|
4
|
-
|
5
|
-
1mMULTIPLE GEM SOURCES0m
|
6
|
-
Gemstash will stash from any amount of gem sources. By the end of this
|
7
|
-
guide, you will be able to bundle using multiple gem sources, all
|
8
|
-
stashed within your Gemstash server.
|
9
|
-
|
10
|
-
1mDEFAULT SOURCE0m
|
11
|
-
When you don't provide an explicit source (as with the Quickstart Guide
|
12
|
-
(../readme.md#quickstart-guide)), your gems will be fetched from
|
13
|
-
https://rubygems.org. This default source is not set in stone. To
|
14
|
-
change it, you need only edit the Gemstash configuration found at
|
15
|
-
~/.gemstash/config.yml:
|
16
|
-
|
17
|
-
# ~/.gemstash/config.yml
|
18
|
-
---
|
19
|
-
:rubygems_url: https://my.gem-source.local
|
20
|
-
|
21
|
-
Make sure to restart your Gemstash server after changing the config:
|
22
|
-
|
23
|
-
$ gemstash stop
|
24
|
-
$ gemstash start
|
25
|
-
|
26
|
-
Once restarted, bundling against http://localhost:9292 will fetch gems
|
27
|
-
from https://my.gem-source.local. If you had bundled before making
|
28
|
-
these changes, fear not; bundling with a different default gem source
|
29
|
-
will store gems in a separate location, ensuring different sources
|
30
|
-
won't leak between each other.
|
31
|
-
|
32
|
-
1mBUNDLING WITH MULTIPLE SOURCES0m
|
33
|
-
Changing the default source won't help you if you need to bundle
|
34
|
-
against https://rubygems.org along with additional sources. If you
|
35
|
-
need to bundle with multiple gem sources, Gemstash doesn't need to be
|
36
|
-
specially configured. Your Gemstash server will honor any gem source
|
37
|
-
specified via a specialized URL. Consider the following Gemfile:
|
38
|
-
|
39
|
-
# ./Gemfile
|
40
|
-
require "cgi"
|
41
|
-
source "http://localhost:9292"
|
42
|
-
gem "rubywarrior"
|
43
|
-
|
44
|
-
source "http://localhost:9292/upstream/#{CGI.escape("https://my.gem-source.local")}" do
|
45
|
-
gem "my-gem"
|
46
|
-
end
|
47
|
-
|
48
|
-
Notice the CGI.escape call in the second source. This is important, as
|
49
|
-
it properly URL escapes the source URL so Gemstash knows what gem
|
50
|
-
source you want. The /upstream prefix tells Gemstash to use a gem
|
51
|
-
source other than the default source. You can now bundle with the ad-
|
52
|
-
ditional source.
|
53
|
-
|
54
|
-
1mREDIRECTING0m
|
55
|
-
Gemstash supports an alternate mode of specifying your gem sources. If
|
56
|
-
you want Gemstash to redirect Bundler to your given gem sources, then
|
57
|
-
you can specify your Gemfile like so:
|
58
|
-
|
59
|
-
# ./Gemfile
|
60
|
-
require "cgi"
|
61
|
-
source "http://localhost:9292/redirect/#{CGI.escape("https://rubygems.org")}"
|
62
|
-
gem "rubywarrior"
|
63
|
-
|
64
|
-
Notice the /redirect prefix. This prefix tells Gemstash to redirect
|
65
|
-
API calls to the provided URL. Redirected calls like this will not be
|
66
|
-
cached by Gemstash, and gem files will not be stashed, even if they
|
67
|
-
were previously cached or stashed from the same gem source.
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
October 8, 2015 gemstash-multiple-sources(7)
|
@@ -1,156 +1 @@
|
|
1
|
-
gemstash-private-gems(7) gemstash-private-gems(7)
|
2
1
|
|
3
|
-
|
4
|
-
|
5
|
-
1mPRIVATE GEMS0m
|
6
|
-
Stashing private gems in your Gemstash server requires a bit of addi-
|
7
|
-
tional setup. If you haven't read through the Quickstart Guide
|
8
|
-
(../readme.md#quickstart-guide), you should do that first. By the end
|
9
|
-
of this guide, you will be able to interact with your Gemstash server
|
10
|
-
to store and retrieve your private gems.
|
11
|
-
|
12
|
-
1mAUTHORIZING0m
|
13
|
-
1mIMPORTANT NOTE: 22mDo not use the actual key value in this document, oth-
|
14
|
-
erwise your Gemstash server will be vulnerable to anyone who wants to
|
15
|
-
try to use the key against your server. Instead of the key value here,
|
16
|
-
use whatever key is generated from running the commands.
|
17
|
-
|
18
|
-
In order to push a gem to your Gemstash server, you need to first cre-
|
19
|
-
ate an API key. Utilize the gemstash authorize command to create the
|
20
|
-
API key:
|
21
|
-
|
22
|
-
$ gemstash authorize
|
23
|
-
Your new key is: e374e237fdf5fa5718d2a21bd63dc911
|
24
|
-
|
25
|
-
This new key can push, yank, and fetch gems from your Gemstash server.
|
26
|
-
Run gemstash authorize with just the permissions you want to limit what
|
27
|
-
the key will be allowed to do. You can similarly update a specific key
|
28
|
-
by providing it via the --key option:
|
29
|
-
|
30
|
-
$ gemstash authorize push yank --key e374e237fdf5fa5718d2a21bd63dc911
|
31
|
-
|
32
|
-
When no permissions are provided (like the first example), the key will
|
33
|
-
be authorized for all permissions. Leave the key authorized with ev-
|
34
|
-
erything if you want to use it to try all private gem interactions:
|
35
|
-
|
36
|
-
$ gemstash authorize --key e374e237fdf5fa5718d2a21bd63dc911
|
37
|
-
|
38
|
-
With the key generated, you'll need to tell Rubygems about your new
|
39
|
-
key. If you've pushed a gem to https://rubygems.org, then you will al-
|
40
|
-
ready have a credentials file to add the key to. If not, run the fol-
|
41
|
-
lowing commands before modifying the credentials file:
|
42
|
-
|
43
|
-
$ mkdir -p ~/.gem
|
44
|
-
$ touch ~/.gem/credentials
|
45
|
-
$ chmod 0600 ~/.gem/credentials
|
46
|
-
|
47
|
-
Add your new key to credentials such that it looks something like this
|
48
|
-
(but make sure not to remove any existing keys):
|
49
|
-
|
50
|
-
# ~/.gem/credentials
|
51
|
-
---
|
52
|
-
:test_key: e374e237fdf5fa5718d2a21bd63dc911
|
53
|
-
|
54
|
-
The name test_key can be anything you want, but you will need to remem-
|
55
|
-
ber it and use it again later in this guide for the --key option.
|
56
|
-
|
57
|
-
1mCREATING A TEST GEM0m
|
58
|
-
You'll need a test gem before you can play with private gems on your
|
59
|
-
Gemstash server. If you have a gem you can use, move along to the next
|
60
|
-
section. You can start by instantiating a test gem via Bundler:
|
61
|
-
|
62
|
-
$ bundle gem private-example
|
63
|
-
|
64
|
-
You'll need to add a summary and description to the new gem's gemspec
|
65
|
-
file in order to successfully build it. Once you've built the gem, you
|
66
|
-
will be ready to push the new gem.
|
67
|
-
|
68
|
-
$ cd private-example
|
69
|
-
$ rake build
|
70
|
-
|
71
|
-
You will now have a gem at private-example/pkg/private-exam-
|
72
|
-
ple-0.1.0.gem.
|
73
|
-
|
74
|
-
1mPUSHING0m
|
75
|
-
If your Gemstash server isn't running, go ahead and start it:
|
76
|
-
|
77
|
-
$ gemstash start
|
78
|
-
|
79
|
-
Push your test gem using Rubygems:
|
80
|
-
|
81
|
-
$ gem push --key test_key --host http://localhost:9292/private pkg/private-example-0.1.0.gem
|
82
|
-
|
83
|
-
The /private portion of the --host option tells Gemstash you are inter-
|
84
|
-
acting with the private gems. Gemstash will not let you push, or yank
|
85
|
-
from anything except /private.
|
86
|
-
|
87
|
-
1mBUNDLING0m
|
88
|
-
Once your gem is pushed to your Gemstash server, you are ready to bun-
|
89
|
-
dle it. Create a Gemfile and specify the gem. You will probably want
|
90
|
-
to wrap the private gem in a source block, and let the rest of Gemstash
|
91
|
-
handle all other gems:
|
92
|
-
|
93
|
-
# ./Gemfile
|
94
|
-
source "http://localhost:9292"
|
95
|
-
gem "rubywarrior"
|
96
|
-
|
97
|
-
source "http://localhost:9292/private" do
|
98
|
-
gem "private-example"
|
99
|
-
end
|
100
|
-
|
101
|
-
Notice that the Gemstash server points to /private again when in-
|
102
|
-
stalling your private gem. Go ahead and bundle to install your new
|
103
|
-
private gem:
|
104
|
-
|
105
|
-
$ bundle
|
106
|
-
|
107
|
-
1mYANKING0m
|
108
|
-
If you push a private gem by accident, you can yank the gem with
|
109
|
-
Rubygems:
|
110
|
-
|
111
|
-
$ RUBYGEMS_HOST=http://localhost:9292/private gem yank --key test_key private-example --version 0.1.0
|
112
|
-
|
113
|
-
Like with pushing, the /private portion of the host option tells Gem-
|
114
|
-
stash you are interacting with private gems. Gemstash will only let
|
115
|
-
you yank from /private. Unlike pushing, Rubygems doesn't support
|
116
|
-
--host for yank (yet), so you need to specify the host via the
|
117
|
-
RUBYGEMS_HOST environment variable.
|
118
|
-
|
119
|
-
1mPROTECTED FETCHING0m
|
120
|
-
By default, private gems and specs can be accessed without authentica-
|
121
|
-
tion.
|
122
|
-
|
123
|
-
Private gems often require protected fetching. For backwards compati-
|
124
|
-
bility this is disabled by default, but can be enabled via $ gemstash
|
125
|
-
setup command.
|
126
|
-
|
127
|
-
When protected fetching is enabled API keys with the permissions all or
|
128
|
-
fetch can be used to download gems and specs.
|
129
|
-
|
130
|
-
On the Bundler side, there are a few ways to configure credentials for
|
131
|
-
a given gem source:
|
132
|
-
|
133
|
-
Add credentials globally:
|
134
|
-
|
135
|
-
$ bundle config my-gemstash.dev api_key
|
136
|
-
|
137
|
-
Add credentials in Gemfile:
|
138
|
-
|
139
|
-
source "https://api_key@my-gemstash.dev"
|
140
|
-
|
141
|
-
However, it's not a good practice to commit credentials to source con-
|
142
|
-
trol. A recommended solution is to use Bundler's configuration keys
|
143
|
-
(http://bundler.io/man/bundle-config.1.html#CONFIGURATION-KEYS), e.g.:
|
144
|
-
|
145
|
-
$ export BUNDLE_MYGEMSTASH__DEV=api_key
|
146
|
-
|
147
|
-
Behind the scene, Bundler will pick up the ENV var according to the
|
148
|
-
host name (e.g. mygemstash.dev) and add to URI.userinfo for making re-
|
149
|
-
quests.
|
150
|
-
|
151
|
-
The API key is treated as a HTTP Basic Auth username and any HTTP Basic
|
152
|
-
password supplied will be ignored.
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
October 8, 2015 gemstash-private-gems(7)
|