gemfilings 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f343cae261ee32305701ead901375d2dd914c9af
4
+ data.tar.gz: 441811bc97b50f890b77334deee975cc758e85ae
5
+ SHA512:
6
+ metadata.gz: 0c7908d4f08c0e5532a132b1dcc6988e215a6aa80fcf27286a29ab23be4f93b1b3507bd7987b97584b749d4b71d78eeb742ed30585fa6986c08f90a7ed916159
7
+ data.tar.gz: 4a75b92fee0614f50c6ad3a58c9f951f79f2b19aed3bf6c1ad00c2474e0b2b057c72a887b8646c005fc25df0040839e5d325afa4cd5791c4af9fee7c6561a1e3
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Jeff Felchner
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # Gemfilings
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'gemfilings'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install gemfilings
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/gemfilings/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,27 @@
1
+ require 'thor'
2
+ require 'gemfilings/commands/gem'
3
+
4
+ module Gemfilings
5
+ module Binary
6
+ class Runner < Thor
7
+ include Thor::Actions
8
+
9
+ class_option :gemfile,
10
+ type: :string,
11
+ aliases: '-g',
12
+ desc: 'The Gemfile to modify'
13
+
14
+ desc 'gem', 'Displays the list of settings and their values'
15
+
16
+ method_option :toggle_path,
17
+ type: :boolean,
18
+ aliases: '-p',
19
+ desc: 'Switch the specified gem from a non-local path to a local ' \
20
+ 'path or vice versa.'
21
+
22
+ def gem(*gem_names)
23
+ Commands::Gem.call(options, gem_names)
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,36 @@
1
+ require 'bundler'
2
+ require 'gemfilings/gemfile'
3
+
4
+ module Gemfilings
5
+ module Commands
6
+ class Gem
7
+ def initialize(options = {}, gem_names)
8
+ self.toggle_path = options.fetch(:toggle_path, false)
9
+ self.gemfile = options[:gemfile]
10
+ self.gem_names = Array(gem_names)
11
+ end
12
+
13
+ def call
14
+ if toggle_path
15
+ gemfile.toggle_local_path(gem_names)
16
+ end
17
+
18
+ `bundle install`
19
+ end
20
+
21
+ def self.call(options = {}, gem_names)
22
+ new(options, gem_names).call
23
+ end
24
+
25
+ protected
26
+
27
+ attr_accessor :toggle_path,
28
+ :gemfile,
29
+ :gem_names
30
+
31
+ def gemfile=(other)
32
+ @gemfile = Gemfile.new(File.expand_path(other || 'Gemfile'))
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,40 @@
1
+ require 'pathname'
2
+
3
+ module Gemfilings
4
+ class Gemfile
5
+ def initialize(path)
6
+ self.path = path
7
+ self.file = File.read(path)
8
+ self.projects_directory = Pathname.new(ENV['PROJECTS_HOME'])
9
+ end
10
+
11
+ def toggle_local_path(gem_names)
12
+ gem_names.each do |gem_name|
13
+ gem_pattern = /^(\s*gem\s+['"]#{gem_name}['"].*?)(,\s*)?(\s*)(#.*)?$/
14
+ gem_path_pattern = /^(\s*gem\s+['"]#{gem_name}['"].*?)(, path: '([^']+)')/
15
+
16
+ local_path = discovered_gem_path(gem_name)
17
+
18
+ if file =~ gem_path_pattern
19
+ file.gsub!(gem_path_pattern, '\1')
20
+ else
21
+ file.gsub!(gem_pattern, "\\1, path: '#{local_path}'\\2\\3\\4")
22
+ end
23
+
24
+ File.write(path, file)
25
+ end
26
+ end
27
+
28
+ protected
29
+
30
+ attr_accessor :path,
31
+ :file,
32
+ :projects_directory
33
+
34
+ def discovered_gem_path(gem_name)
35
+ Pathname.
36
+ glob("#{projects_directory}/{,*/,*/*/}#{gem_name}", File::FNM_EXTGLOB).
37
+ first
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,3 @@
1
+ module Gemfilings
2
+ VERSION = '0.0.2'
3
+ end
data/lib/gemfilings.rb ADDED
@@ -0,0 +1,4 @@
1
+ require 'gemfilings/version'
2
+
3
+ module Gemfilings
4
+ end
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gemfilings
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - jfelchner
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-03-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ description: Makes working with Gemfiles easier
28
+ email: accounts+git@thekompanee.com
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - LICENSE
34
+ - README.md
35
+ - Rakefile
36
+ - lib/gemfilings.rb
37
+ - lib/gemfilings/binary/runner.rb
38
+ - lib/gemfilings/commands/gem.rb
39
+ - lib/gemfilings/gemfile.rb
40
+ - lib/gemfilings/version.rb
41
+ homepage: https://github.com/thekompanee/gemfilings
42
+ licenses:
43
+ - MIT
44
+ metadata: {}
45
+ post_install_message:
46
+ rdoc_options: []
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ requirements: []
60
+ rubyforge_project:
61
+ rubygems_version: 2.2.2
62
+ signing_key:
63
+ specification_version: 4
64
+ summary: Work With Your Gemfile
65
+ test_files: []
66
+ has_rdoc: