gem-local 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +43 -26
- data/gem-local.gemspec +1 -1
- data/lib/rubygems/commands/local_command.rb +38 -38
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d1b94904afdc5de2c12787a6ac78b3c1cc5c7dcb
|
4
|
+
data.tar.gz: 7187a5b97309f43fc8251ad45941eb3cfe210de4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cfb2befa4dbd2f372be0b0a976f209cad45a4fa2eb18be52a6a0587b2eca72d721917bdcd26add2e731f5ef68aac3891bec587dedcab487eedac5e1dd1c2bea9
|
7
|
+
data.tar.gz: b8ad9e202b219b4bb3888fd7068c589a71310d8505bfbf308612af413262a26139be08da83fb77fec2e6e2ac70094c117eb012c7988bf963c1174757bdc0a04c
|
data/README.md
CHANGED
@@ -3,6 +3,19 @@ Command: gem local
|
|
3
3
|
|
4
4
|
> **Lets you register and manage [local bundler git repos](http://bundler.io/v1.5/git.html#local) per-project.**
|
5
5
|
|
6
|
+
If you're developing a gem alongside projects that consume them, you've probably used `gem 'name', path: '~/local/path/to/gem'` in your Gemfile before.
|
7
|
+
|
8
|
+
Of course, if you accidentally commit this, you'll probably cause somebody or someserver some grief down the line. This is why [local bundler git repos](http://bundler.io/v1.5/git.html#local) exist: so that by using `gem 'name', git: 'repo', branch: 'master'`, you can program against a local gem dependency while always leaving your Gemfile in a valid state.
|
9
|
+
|
10
|
+
However, actually *using* `bundler config local....` is a bit of a pain:
|
11
|
+
|
12
|
+
- you have to remember to use the `--local` flag every invocation, otherwise you might bork other local projects using the dependency
|
13
|
+
- you have to remember to unset the configuration if you check out a version of your Gemfile without the `gem git:, branch:` bit
|
14
|
+
- you have to remember what that configuration was and to reset it when you checkout back to your branch
|
15
|
+
- if you frequently develop against local gems, you have to do this for every gem, in every project, and remember where you are in the above workflow every time you revisit a project after a few days
|
16
|
+
|
17
|
+
`gem local` makes this a little less of a hassle.
|
18
|
+
|
6
19
|
Installation
|
7
20
|
------------
|
8
21
|
|
@@ -15,27 +28,25 @@ gem install gem-local
|
|
15
28
|
Usage
|
16
29
|
-----
|
17
30
|
|
18
|
-
|
19
|
-
|
20
|
-
If using git, inside a project with a `Gemfile` where you want to be able to toggle local bundler gem loadpaths, run:
|
31
|
+
After installing the gem, inside your project, run:
|
21
32
|
|
22
33
|
```sh
|
23
34
|
gem local install
|
24
35
|
```
|
25
36
|
|
26
|
-
This ensures that
|
37
|
+
This isn't strictly neccessary--it just ensures that your local `.bundle/config` and `.gemlocal` files don't get committed.
|
27
38
|
|
28
|
-
|
39
|
+
#### Adding local repos
|
29
40
|
|
30
|
-
Define
|
41
|
+
Define your project dependencies that you have local copies of, and their locations:
|
31
42
|
|
32
43
|
```sh
|
33
44
|
gem local add my-dependency ~/code/ruby/gems/my-dependency
|
34
45
|
```
|
35
46
|
|
36
|
-
This lets `git local` know about this dependency.
|
47
|
+
This lets `git local` know about this dependency. Note that relative paths are supported, and `~` gets expanded, which is the format `bundle config` expects.
|
37
48
|
|
38
|
-
|
49
|
+
#### Using local repos
|
39
50
|
|
40
51
|
When you want to use your local copy, run
|
41
52
|
|
@@ -43,21 +54,28 @@ When you want to use your local copy, run
|
|
43
54
|
gem local use my-dependency
|
44
55
|
```
|
45
56
|
|
46
|
-
It updates the **local** bundler config (not *global*, as bundler does by default, which many
|
57
|
+
It updates the **local** bundler config (not *global*, as bundler does by default, which many guides run with) to refer to the path you supplied it.
|
47
58
|
|
48
|
-
|
59
|
+
#### Ignoring local repos
|
49
60
|
|
50
|
-
When you want to use the remote version again, run
|
61
|
+
When you want to use the standard remote version of the dependency again, run
|
51
62
|
|
52
63
|
```sh
|
53
64
|
gem local ignore my-dependency
|
54
65
|
```
|
55
66
|
|
56
|
-
This will remove it from your bundler config and update your `.gitlocal` accordingly
|
67
|
+
This will remove it from your bundler config and update your `.gitlocal` accordingly. If you've ever seen the message:
|
68
|
+
|
69
|
+
```sh
|
70
|
+
Cannot use local override for gem-name at path/to/gem because :branch is not specified in Gemfile.
|
71
|
+
Specify a branch or use `bundle config --delete` to remove the local override
|
72
|
+
```
|
73
|
+
|
74
|
+
you've probably checked out a different version of your Gemfile without updating your bundle config. Now you can do so with `gem local off gem-name` and not completely forget how to re-configure things when you check your WIP branch back out.
|
57
75
|
|
58
|
-
|
76
|
+
#### Multiple gems at once
|
59
77
|
|
60
|
-
The `use` and `ignore` commands (and their aliases--see
|
78
|
+
The `use` and `ignore` commands (and their aliases--see them in `help <cmd>`) work for multiple gems at once, as well as all registered gems if you don't specify any.
|
61
79
|
|
62
80
|
```sh
|
63
81
|
gem local status
|
@@ -65,23 +83,23 @@ gem local status
|
|
65
83
|
# on: bar @ /Users/rubyist/code/oss/bar
|
66
84
|
# on: fizz @ /Users/rubyist/code/oss/fizz
|
67
85
|
# on: buzz @ /Users/rubyist/code/oss/buzz
|
68
|
-
# off:
|
86
|
+
# off: metasyntactic @ /Users/rubyist/code/oss/variable
|
69
87
|
|
70
88
|
gem local ignore bar fizz
|
71
89
|
# off: foo @ /Users/rubyist/code/oss/foo
|
72
90
|
# off: bar @ /Users/rubyist/code/oss/bar
|
73
91
|
# off: fizz @ /Users/rubyist/code/oss/fizz
|
74
92
|
# on: buzz @ /Users/rubyist/code/oss/buzz
|
75
|
-
# off:
|
93
|
+
# off: metasyntactic @ /Users/rubyist/code/oss/variable
|
76
94
|
|
77
|
-
gem local
|
95
|
+
gem local use
|
78
96
|
# on: foo @ /Users/rubyist/code/oss/foo
|
79
97
|
# on: bar @ /Users/rubyist/code/oss/bar
|
80
98
|
# on: fizz @ /Users/rubyist/code/oss/fizz
|
81
99
|
# on: buzz @ /Users/rubyist/code/oss/buzz
|
82
100
|
# on: metasyntactic @ /Users/rubyist/code/oss/variable
|
83
101
|
|
84
|
-
gem local
|
102
|
+
gem local ignore
|
85
103
|
# off: foo @ /Users/rubyist/code/oss/foo
|
86
104
|
# off: bar @ /Users/rubyist/code/oss/bar
|
87
105
|
# off: fizz @ /Users/rubyist/code/oss/fizz
|
@@ -89,17 +107,17 @@ gem local disable
|
|
89
107
|
# off: metasyntactic @ /Users/rubyist/code/oss/variable
|
90
108
|
```
|
91
109
|
|
92
|
-
|
110
|
+
#### Rebuilding the local gem db
|
93
111
|
|
94
|
-
If invocations of `bundle config --local local...` cause your `.gemlocal` file to get out of sync with bundler's settings in `.bundle/config`, run
|
112
|
+
If manual invocations of `bundle config --local local...` cause your `.gemlocal` file to get out of sync with bundler's settings in `.bundle/config`, run
|
95
113
|
|
96
114
|
```sh
|
97
115
|
gem local rebuild
|
98
116
|
```
|
99
117
|
|
100
|
-
to update your file against bundler's
|
118
|
+
to update your file against bundler's version.
|
101
119
|
|
102
|
-
|
120
|
+
#### Other commands
|
103
121
|
|
104
122
|
For other commands and usage, see
|
105
123
|
|
@@ -107,14 +125,13 @@ For other commands and usage, see
|
|
107
125
|
gem local help
|
108
126
|
```
|
109
127
|
|
110
|
-
|
111
|
-
|
112
|
-
For details on a command, for example `install`, run
|
128
|
+
For full details of a command, for example `install`, run
|
113
129
|
|
114
130
|
```sh
|
115
131
|
gem local help install
|
116
132
|
```
|
117
133
|
|
118
|
-
|
134
|
+
Contributing
|
135
|
+
------------
|
119
136
|
|
120
137
|
Bug reports and pull requests are welcome on GitHub at https://github.com/christhekeele/gem-local.
|
data/gem-local.gemspec
CHANGED
@@ -71,7 +71,7 @@ help [cmd] | Displays help information.
|
|
71
71
|
if name and location and args.empty?
|
72
72
|
setting = Setting.new(location)
|
73
73
|
if bundler_add name, setting
|
74
|
-
|
74
|
+
update_configuration(name, location: setting.location, status: setting.status)
|
75
75
|
end
|
76
76
|
else
|
77
77
|
arity_error __method__
|
@@ -81,14 +81,14 @@ help [cmd] | Displays help information.
|
|
81
81
|
|
82
82
|
def status(name = nil, *args)
|
83
83
|
if not name and args.empty?
|
84
|
-
|
84
|
+
configuration.each do |name, setting|
|
85
85
|
puts show_setting_for(name, setting)
|
86
86
|
end
|
87
87
|
elsif name
|
88
|
-
if setting =
|
88
|
+
if setting = configuration[name]
|
89
89
|
puts show_setting_for(name, setting)
|
90
90
|
else
|
91
|
-
raise "`gem local #{__method__}` could not find `#{name}` in:\n#{
|
91
|
+
raise "`gem local #{__method__}` could not find `#{name}` in:\n#{find_configuration}"
|
92
92
|
end
|
93
93
|
else
|
94
94
|
arity_error __method__
|
@@ -99,8 +99,8 @@ help [cmd] | Displays help information.
|
|
99
99
|
|
100
100
|
def remove(name = nil, *args)
|
101
101
|
if name and args.empty?
|
102
|
-
|
103
|
-
|
102
|
+
configuration.delete(name)
|
103
|
+
write_configuration(configuration)
|
104
104
|
else
|
105
105
|
arity_error __method__
|
106
106
|
end
|
@@ -108,16 +108,16 @@ help [cmd] | Displays help information.
|
|
108
108
|
alias_method :delete, :remove
|
109
109
|
|
110
110
|
def use(*names)
|
111
|
-
names =
|
111
|
+
names = configuration.keys if names.empty?
|
112
112
|
names.each do |name|
|
113
|
-
if setting =
|
113
|
+
if setting = configuration[name]
|
114
114
|
if bundler_add name, setting
|
115
|
-
|
115
|
+
update_configuration(name, status: "on")
|
116
116
|
else
|
117
117
|
raise "Could not activate gem, make sure `bundle config local.#{name}` #{setting.location} succeeds"
|
118
118
|
end
|
119
119
|
else
|
120
|
-
raise "`gem local #{__method__}` could not find `#{name}` in:\n#{
|
120
|
+
raise "`gem local #{__method__}` could not find `#{name}` in:\n#{find_configuration}"
|
121
121
|
end
|
122
122
|
end
|
123
123
|
end
|
@@ -128,16 +128,16 @@ help [cmd] | Displays help information.
|
|
128
128
|
alias_method :reactivate, :use
|
129
129
|
|
130
130
|
def ignore(*names)
|
131
|
-
names =
|
131
|
+
names = configuration.values if names.empty?
|
132
132
|
names.each do |name|
|
133
|
-
if setting =
|
133
|
+
if setting = configuration[name]
|
134
134
|
if bundler_remove name, setting
|
135
|
-
|
135
|
+
update_configuration(name, status: "off")
|
136
136
|
else
|
137
137
|
raise "Could not deactivate gem, make sure `bundle config --delete local.#{name}` succeeds"
|
138
138
|
end
|
139
139
|
else
|
140
|
-
raise "`gem local #{__method__}` could not find `#{name}` in:\n#{
|
140
|
+
raise "`gem local #{__method__}` could not find `#{name}` in:\n#{find_configuration}"
|
141
141
|
end
|
142
142
|
end
|
143
143
|
end
|
@@ -148,12 +148,12 @@ help [cmd] | Displays help information.
|
|
148
148
|
|
149
149
|
def rebuild(*args)
|
150
150
|
if args.empty?
|
151
|
-
|
152
|
-
|
153
|
-
File.open(
|
154
|
-
|
151
|
+
configuration = read_configuration.dup
|
152
|
+
clear_configuration_cache
|
153
|
+
File.open(find_configuration, "w") do |file|
|
154
|
+
configuration.each do |name, old_setting|
|
155
155
|
if setting = bundler_value(name, old_setting)
|
156
|
-
file.puts
|
156
|
+
file.puts configuration_for(name, setting.location, setting.status)
|
157
157
|
end
|
158
158
|
end
|
159
159
|
end
|
@@ -217,7 +217,7 @@ private
|
|
217
217
|
aliases: %w[new],
|
218
218
|
},
|
219
219
|
"status" => {
|
220
|
-
description: "Displays the current local gem configuration, or the specified gem's
|
220
|
+
description: "Displays the current local gem configuration, or the specified gem's configuration.",
|
221
221
|
usage: "gem local status [gem]",
|
222
222
|
arguments: "takes zero or one arguments",
|
223
223
|
aliases: %w[config show],
|
@@ -294,7 +294,7 @@ private
|
|
294
294
|
info[:description]
|
295
295
|
end
|
296
296
|
|
297
|
-
def
|
297
|
+
def configuration_for(name, location, status)
|
298
298
|
"%-3.3s #{name} #{location}" % status
|
299
299
|
end
|
300
300
|
|
@@ -305,17 +305,17 @@ private
|
|
305
305
|
|
306
306
|
# PLUMBING
|
307
307
|
|
308
|
-
def
|
309
|
-
@
|
308
|
+
def configuration
|
309
|
+
@configuration ||= read_configuration
|
310
310
|
end
|
311
311
|
|
312
|
-
def
|
313
|
-
@
|
312
|
+
def clear_configuration_cache
|
313
|
+
@configuration = nil
|
314
314
|
end
|
315
315
|
|
316
|
-
def
|
317
|
-
File.open(
|
318
|
-
|
316
|
+
def read_configuration
|
317
|
+
File.open(find_configuration) do |file|
|
318
|
+
Hash[
|
319
319
|
file.readlines.reject do |line|
|
320
320
|
line.start_with? "#" or line.strip.empty?
|
321
321
|
end.map do |line|
|
@@ -323,7 +323,7 @@ private
|
|
323
323
|
if status and name and location and args.empty?
|
324
324
|
[name, Setting.new(location, status)]
|
325
325
|
else
|
326
|
-
raise "`gem local` config in `#{
|
326
|
+
raise "`gem local` config in `#{find_configuration}` is corrupt, each non-empty non-commented line must contain a status, a gem name, and the local path to that gem, separated by spaces\nerror at:\n#{line}"
|
327
327
|
end
|
328
328
|
end
|
329
329
|
]
|
@@ -342,27 +342,27 @@ private
|
|
342
342
|
end
|
343
343
|
end
|
344
344
|
|
345
|
-
def
|
345
|
+
def find_configuration
|
346
346
|
find_file Bundler.default_gemfile.dirname + '.gemlocal'
|
347
347
|
rescue Bundler::GemfileNotFound
|
348
348
|
raise "`gem local` could not locate a `Gemfile` file, which it uses to determine the root of your project"
|
349
349
|
end
|
350
350
|
|
351
|
-
def
|
352
|
-
File.open(
|
353
|
-
|
354
|
-
file.puts
|
351
|
+
def write_configuration(configuration)
|
352
|
+
File.open(find_configuration, "w") do |file|
|
353
|
+
configuration.each do |name, setting|
|
354
|
+
file.puts configuration_for(name, setting.location, setting.status)
|
355
355
|
end
|
356
356
|
end
|
357
357
|
end
|
358
358
|
|
359
|
-
def
|
360
|
-
new_setting =
|
359
|
+
def update_configuration(name, properties = {})
|
360
|
+
new_setting = configuration[name] || Setting.new(nil)
|
361
361
|
properties.each do |field, value|
|
362
362
|
new_setting.send(:"#{field}=", value)
|
363
363
|
end
|
364
|
-
|
365
|
-
|
364
|
+
configuration[name] = new_setting
|
365
|
+
write_configuration configuration
|
366
366
|
puts show_setting_for(name, new_setting)
|
367
367
|
end
|
368
368
|
|