fix_mah_gemfile 0.0.1
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 +7 -0
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE +20 -0
- data/README.md +45 -0
- data/Rakefile +1 -0
- data/bin/fix_mah_gemfile +31 -0
- data/fix_mah_gemfile.gemspec +23 -0
- data/lib/fix_mah_gemfile/version.rb +3 -0
- data/lib/fix_mah_gemfile.rb +107 -0
- metadata +82 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 58a1e1dfd65fc24c222b2ec148817c8707a7750a
|
4
|
+
data.tar.gz: 1066c963e3dde7bf5be74e7a97a09585f420cc5f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f93a94867cdc0aa3edb7cb3c39056a7b7faa2928d7a6231ee279d3e9bbf3cbebeb7d3ddcd10cf127657249f330799f55c7602e5e53350fd013bebf668d56418c
|
7
|
+
data.tar.gz: 3da89b9f615f83036df98199dc2bd268ba350f20ed59b20c0cc122fe03470d37d01087e28eb1f3f1583112445cdd381bc6614bb87eceee97e3fedf4c9d1dba6f
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Ed K
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# FixMahGemfile
|
2
|
+
|
3
|
+
This gem provides a script that modifies the Gemfile and runs bundler in one step. This
|
4
|
+
came about because I needed to regularly make local modifications to a shared project, but
|
5
|
+
didn't or couldn't push my locally needed changes upstream.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
$ gem install fix_mah_gemfile
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
Change your directory to the project, where the Gemfile is available. First generate a sample
|
14
|
+
.fixgemfile_rc in the current directory with:
|
15
|
+
|
16
|
+
$ fix_mah_gemfile --generate_rc
|
17
|
+
|
18
|
+
Then edit the .fixgemfile_rc with the local changes you'd like to apply when running the fix_mah_gemfile
|
19
|
+
script.
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
$ fix_mah_gemfile
|
23
|
+
changing gem: args ["libxml-ruby", {:to=>"~> 2.6"}]... found at 147
|
24
|
+
gem 'libxml-ruby', '~> 2.6', :require => nil
|
25
|
+
removing therubyracer... found at
|
26
|
+
Not found
|
27
|
+
removing guard-less... found at
|
28
|
+
Not found
|
29
|
+
bundle
|
30
|
+
Using rake (10.0.4)
|
31
|
+
Using Ascii85 (1.0.2)
|
32
|
+
...
|
33
|
+
```
|
34
|
+
|
35
|
+
Then before checking-in any changes, either do a git checkout Gemfile* or simply avoid commiting these
|
36
|
+
local changes to your gemfile.
|
37
|
+
|
38
|
+
|
39
|
+
## Contributing
|
40
|
+
|
41
|
+
1. Fork it
|
42
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
43
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
44
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
45
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/fix_mah_gemfile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'fix_mah_gemfile.rb'
|
4
|
+
|
5
|
+
if ARGV.include? "--help"
|
6
|
+
FixMahGemfile::Processor.usage
|
7
|
+
exit 0
|
8
|
+
end
|
9
|
+
|
10
|
+
if ARGV.include? "--generate_rc"
|
11
|
+
FixMahGemfile::Processor.generate_sample_rc
|
12
|
+
exit 0
|
13
|
+
end
|
14
|
+
|
15
|
+
if !File.exist?("./Gemfile")
|
16
|
+
puts "Cant find Gemfile in current directory to modify"
|
17
|
+
FixMahGemfile::Processor.usage
|
18
|
+
exit 1
|
19
|
+
end
|
20
|
+
|
21
|
+
if ARGV[0]
|
22
|
+
load ARGV[0]
|
23
|
+
elsif File.exist?(".fixgemfile_rc")
|
24
|
+
load ".fixgemfile_rc"
|
25
|
+
else
|
26
|
+
FixMahGemfile::Processor.usage
|
27
|
+
exit 1
|
28
|
+
end
|
29
|
+
|
30
|
+
exit 0
|
31
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'fix_mah_gemfile/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "fix_mah_gemfile"
|
8
|
+
spec.version = FixMahGemfile::VERSION
|
9
|
+
spec.authors = ["Eddy Kim"]
|
10
|
+
spec.email = ["eddyhkim@gmail.com"]
|
11
|
+
spec.description = %q{command-line script to modify and run bundler for you in one operation}
|
12
|
+
spec.summary = %q{command-line script to modify and run bundler for you in one operation}
|
13
|
+
spec.homepage = "https://github.com/edk/fix_mah_gemfile"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = ["fix_mah_gemfile"]
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
require "fix_mah_gemfile/version"
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
module FixMahGemfile
|
5
|
+
|
6
|
+
class Processor
|
7
|
+
attr_accessor :gemfile
|
8
|
+
|
9
|
+
def initialize &block
|
10
|
+
@gemfile = File.readlines("Gemfile")
|
11
|
+
@gemfile_orig = @gemfile.dup
|
12
|
+
instance_eval &block if block_given?
|
13
|
+
write_to_file
|
14
|
+
end
|
15
|
+
def log str, color_code=32
|
16
|
+
# green = 32 , red 31, yellow = 33
|
17
|
+
print "\e[#{color_code}m#{str}\e[0m"
|
18
|
+
end
|
19
|
+
def add_gem gemname, *args
|
20
|
+
log "adding #{gemname} #{args.inspect}... "
|
21
|
+
where = args[1].keys.first
|
22
|
+
puts "where #{where} #{args[1][where]}"
|
23
|
+
newline = ([" gem '#{gemname}'", args[0]].join(", ")) << "\n"
|
24
|
+
case where.to_s
|
25
|
+
when 'above_gem'
|
26
|
+
linenum = gem_at_line(args[1][where])
|
27
|
+
gemfile.insert(linenum, newline)
|
28
|
+
when 'below_gem'
|
29
|
+
linenum = gem_at_line(args[1][where])
|
30
|
+
else
|
31
|
+
puts "don't know how to handle directive #{where}"
|
32
|
+
exit 1
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def remove_gem gemname
|
37
|
+
log "removing #{gemname}... "
|
38
|
+
if linenum = gem_at_line(gemname)
|
39
|
+
line = gemfile[linenum]
|
40
|
+
line = "##{line}"
|
41
|
+
gemfile[linenum] = line
|
42
|
+
else
|
43
|
+
puts "Not found"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
def change_gem_version *args
|
47
|
+
log "changing gem: args #{args.inspect}... "
|
48
|
+
gemname = args[0]
|
49
|
+
options = args[1]
|
50
|
+
if linenum = gem_at_line(gemname)
|
51
|
+
line = gemfile[linenum]
|
52
|
+
lineparts = line.split(',')
|
53
|
+
if lineparts[1] # replace
|
54
|
+
lineparts[1] = " '#{options[:to]}'"
|
55
|
+
else # append
|
56
|
+
lineparts << " '#{options[:to]}'"
|
57
|
+
end
|
58
|
+
gemfile[linenum] = lineparts.join(",")
|
59
|
+
else
|
60
|
+
puts "cant find gem to modify"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
def gem_at_line gemname
|
64
|
+
found = gemfile.index { |line| line =~ /^\s*gem ['|"]#{gemname}/ }
|
65
|
+
puts "found at #{found}"
|
66
|
+
if found
|
67
|
+
puts gemfile[found]
|
68
|
+
end
|
69
|
+
found
|
70
|
+
end
|
71
|
+
def write_to_file filename = 'Gemfile'
|
72
|
+
# write out original to backup, overwrite Gemfile with modified version
|
73
|
+
File.open("Gemfile.orig",'w') { |f| f.write(@gemfile_orig.join("")) }
|
74
|
+
File.open("Gemfile",'w') { |f| f.write(@gemfile.join("")) }
|
75
|
+
end
|
76
|
+
def self.usage
|
77
|
+
puts "Usage: #{Pathname.new($0).basename} [--help] [--generate_rc] [path/to/rc_file]"
|
78
|
+
puts " --help : this help"
|
79
|
+
puts " --generate_rc : creates a sample .fixgemfile_rc in the current directory"
|
80
|
+
puts " path/to/rc_file : [optional]\n"
|
81
|
+
puts "This utility will look for a .fixgemfile_rc which consists of directives to modify the Gemfile"
|
82
|
+
puts "in the current directory. An option argument can specify the path to an alternate rc file.\n\n"
|
83
|
+
end
|
84
|
+
def self.generate_sample_rc
|
85
|
+
outfile = "./fixgemfile_rc"
|
86
|
+
file = <<-END
|
87
|
+
# example .fixgemfile_rc
|
88
|
+
FixMahGemfile::Processor.new do
|
89
|
+
remove_gem 'looksee'
|
90
|
+
change_gem_version 'libxml-ruby', :to => '~> 2.7'
|
91
|
+
#add_gem 'therubyracer', "'~> 0.12', :require=>false", :above_gem => "guard"
|
92
|
+
remove_gem 'therubyracer'
|
93
|
+
remove_gem 'guard-less'
|
94
|
+
end
|
95
|
+
|
96
|
+
FixMahGemfile::Processor.run "bundle"
|
97
|
+
#FixMahGemfile::Processor.run "bundle update libxml-ruby"
|
98
|
+
#FixMahGemfile::Processor.run "bundle update guard guard-less therubyracer"
|
99
|
+
END
|
100
|
+
end
|
101
|
+
def self.run str
|
102
|
+
puts str
|
103
|
+
system str
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fix_mah_gemfile
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Eddy Kim
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-02-11 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.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: command-line script to modify and run bundler for you in one operation
|
42
|
+
email:
|
43
|
+
- eddyhkim@gmail.com
|
44
|
+
executables:
|
45
|
+
- fix_mah_gemfile
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- .gitignore
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- bin/fix_mah_gemfile
|
55
|
+
- fix_mah_gemfile.gemspec
|
56
|
+
- lib/fix_mah_gemfile.rb
|
57
|
+
- lib/fix_mah_gemfile/version.rb
|
58
|
+
homepage: https://github.com/edk/fix_mah_gemfile
|
59
|
+
licenses:
|
60
|
+
- MIT
|
61
|
+
metadata: {}
|
62
|
+
post_install_message:
|
63
|
+
rdoc_options: []
|
64
|
+
require_paths:
|
65
|
+
- lib
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
requirements: []
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 2.0.13
|
79
|
+
signing_key:
|
80
|
+
specification_version: 4
|
81
|
+
summary: command-line script to modify and run bundler for you in one operation
|
82
|
+
test_files: []
|