gem-local 0.1.6 → 0.1.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e36d6e61332c32a6b59f16b65dc5c3bee0db3bf7
4
- data.tar.gz: 2647fd75bda2cd6a431259530fe774da97f7265f
3
+ metadata.gz: d1b94904afdc5de2c12787a6ac78b3c1cc5c7dcb
4
+ data.tar.gz: 7187a5b97309f43fc8251ad45941eb3cfe210de4
5
5
  SHA512:
6
- metadata.gz: 17c01ff9231ba646576c7d1e55a128921a108ec9be37c878ee783a4f26a34c50ab2244fbb1494b3b4933f47ff7fc198d3368036433b92e2ee8cf9dec9394d3d4
7
- data.tar.gz: d6854207619b7b2b33c531f2ce9edb62547a6de85adb41791f99e6926f6b7a054de51c7873ce2fb72c4d4802a48503f25c12665194684d84124224c8f2aaf564
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
- ### Initialization
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 the local `.bundle/config` and `.gemlocal` files don't get committed.
37
+ This isn't strictly neccessary--it just ensures that your local `.bundle/config` and `.gemlocal` files don't get committed.
27
38
 
28
- ### Adding local repos
39
+ #### Adding local repos
29
40
 
30
- Define the dependencies of this project that you have local copies of, and their locations:
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
- ### Using local repos
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 tutorials run with) to refer to the path you supplied it.
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
- ### Ignoring local repos
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 to know it's been disabled.
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
- ### Multiple gems at once
76
+ #### Multiple gems at once
59
77
 
60
- The `use` and `ignore` commands (and their aliases--see the `help`) work for multiple registered gems at once, as well as all registered gems if you don't specify any.
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: metasyntactic @ /Users/rubyist/code/oss/variable
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: metasyntactic @ /Users/rubyist/code/oss/variable
93
+ # off: metasyntactic @ /Users/rubyist/code/oss/variable
76
94
 
77
- gem local enable
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 disable
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
- ### Rebuilding the local gem db
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 configuration.
118
+ to update your file against bundler's version.
101
119
 
102
- ### Other commands
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
- ### Detailed help
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
- ## Contributing
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
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "gem-local"
7
- spec.version = "0.1.6"
7
+ spec.version = "0.1.7"
8
8
  spec.authors = ["Chris Keele"]
9
9
  spec.email = ["dev@chriskeele.com"]
10
10
 
@@ -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
- update_config(name, location: setting.location, status: setting.status)
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
- config.each do |name, setting|
84
+ configuration.each do |name, setting|
85
85
  puts show_setting_for(name, setting)
86
86
  end
87
87
  elsif name
88
- if setting = config[name]
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#{find_config}"
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
- config.delete(name)
103
- write_config(config)
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 = config.keys if names.empty?
111
+ names = configuration.keys if names.empty?
112
112
  names.each do |name|
113
- if setting = config[name]
113
+ if setting = configuration[name]
114
114
  if bundler_add name, setting
115
- update_config(name, status: "on")
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#{find_config}"
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 = config.values if names.empty?
131
+ names = configuration.values if names.empty?
132
132
  names.each do |name|
133
- if setting = config[name]
133
+ if setting = configuration[name]
134
134
  if bundler_remove name, setting
135
- update_config(name, status: "off")
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#{find_config}"
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
- config = read_config.dup
152
- clear_config_cache
153
- File.open(find_config, "w") do |file|
154
- config.each do |name, old_setting|
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 config_for(name, setting.location, setting.status)
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 config.",
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 config_for(name, location, status)
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 config
309
- @config ||= read_config
308
+ def configuration
309
+ @configuration ||= read_configuration
310
310
  end
311
311
 
312
- def clear_config_cache
313
- @config = nil
312
+ def clear_configuration_cache
313
+ @configuration = nil
314
314
  end
315
315
 
316
- def read_config
317
- File.open(find_config) do |file|
318
- config = Hash[
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 `#{find_config}` 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}"
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 find_config
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 write_config(config)
352
- File.open(find_config, "w") do |file|
353
- config.each do |name, setting|
354
- file.puts config_for(name, setting.location, setting.status)
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 update_config(name, properties = {})
360
- new_setting = config[name] || Setting.new(nil)
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
- config[name] = new_setting
365
- write_config config
364
+ configuration[name] = new_setting
365
+ write_configuration configuration
366
366
  puts show_setting_for(name, new_setting)
367
367
  end
368
368
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gem-local
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Keele