gpig 0.0.2 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/bin/gpig CHANGED
@@ -1,5 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ require 'gpig/version'
4
+ require 'trollop'
5
+ require 'yaml'
6
+
3
7
  def increment_version(vfile)
4
8
  str = File.open(vfile).read
5
9
  str.gsub!(/\r\n?/, "\n")
@@ -17,39 +21,37 @@ def increment_version(vfile)
17
21
  File.open(vfile, 'w') { |file| file.write(str2) }
18
22
  end
19
23
 
20
- class PigConfig
21
- def self.vfile=(str)
22
- @@vfile = str
23
- end
24
- def self.vfile
25
- return @@vfile
26
- end
27
- def self.repo=(str)
28
- @@repo = str
29
- end
30
- def self.repo
31
- return @@repo
32
- end
24
+ opts = Trollop::options do
25
+ # version "gpig version #{Gpig::VERSION}\n"
26
+ banner <<-EOS
27
+ --------------------------------------------------------------------------------
28
+ GPIG (Git Push Install Gem)
29
+ Gpig is a nice little tool to help speed up gem development. It allows you
30
+ to make a change in your gem code, then quickly increment the version of
31
+ the gem code, push changes to a git repository, and install the new version
32
+ of the gem locally so you can test it.
33
+ --------------------------------------------------------------------------------
34
+ EOS
35
+ version "gpig Version #{Gpig::VERSION}\n"
36
+ opt :conf_file , "The configuration file.", :type => :string, :default => File.join(Dir.pwd,'.gpig')
37
+ opt :increment , "Whether or not to increment the version.", :default => true
38
+ opt :version_file , "The version file that holds the VERSION variable that will be incremented.", :type => :string
39
+ opt :repo_url , "The URL of the git repo from which the new gem will be installed.", :type => :string
40
+ opt :remote , "The remote to which the local code changes will be pushed.", :type => :string, :default => 'origin'
41
+ opt :branch , "The branch to which the local code changes will be committed." , :type => :string, :default => 'master'
42
+ opt :commit_message , "The message when committing files to the repo.", :type => :string, :default => "More changes"
33
43
  end
34
44
 
35
- #===============================================================================
36
-
37
- PigConfig.vfile = ARGV.count > 0 ? ARGV[0] : false
38
- PigConfig.repo = ARGV.count > 1 ? ARGV[1] : false
39
-
40
- if (ARGV.count == 0 && File.exists?(File.join(Dir.pwd, '.gpig')))
41
- load File.join(Dir.pwd, '.gpig')
45
+ conf = YAML::load_file(opts.conf_file)
46
+ conf.each do |key,val|
47
+ opts[key.to_sym] = val
42
48
  end
43
49
 
44
- vfile = PigConfig.vfile
45
- repo = PigConfig.repo
46
-
47
- if (!vfile || !repo || vfile.strip.length == 0 || repo.strip.length == 0)
48
- puts "Usage: gpig <version_file> <git_repo_url>\n\n"
49
- puts " or have a .gpig config file with those arguments on the first line."
50
+ if (!opts.version_file || !opts.repo_url || opts.version_file.strip.length == 0 || opts.repo_url.strip.length == 0)
51
+ opts.help
50
52
  exit
51
- elsif (!File.exists?(vfile))
52
- puts "Error: the version file (#{vfile}) doesn't seem to exist.\n";
53
+ elsif (!File.exists?(opts.version_file))
54
+ puts "Error: the version file (#{opts.version_file}) doesn't seem to exist.\n";
53
55
  exit
54
56
  end
55
57
 
@@ -59,16 +61,24 @@ if (!str.index('nothing to commit').nil?)
59
61
  exit
60
62
  end
61
63
 
62
- puts "Modifying the version..."
63
- increment_version(vfile)
64
- puts "Adding files to git repo..."
64
+ if (opts.increment)
65
+ puts "\nModifying the version..."
66
+ increment_version(opts.version_file)
67
+ end
68
+
69
+ puts "\nAdding files to git repo..."
65
70
  `git add -A`
66
- puts "Committing files to git repo..."
67
- `git commit -m 'More changes'`
68
- puts "Pulling in any changes..."
69
- `git pull origin master`
70
- puts "Pushing in any changes..."
71
- `git push origin master`
72
- puts "Installing new version of gem..."
73
- `gem specific_install -l #{repo}`
74
- puts "Finished!\n\n"
71
+
72
+ puts "\nCommitting files to git repo..."
73
+ `git commit -m "#{opts.commit_message}"`
74
+
75
+ puts "\nPulling in any changes..."
76
+ `git pull #{opts.remote} #{opts.branch}`
77
+
78
+ puts "\nPushing in any changes..."
79
+ `git push #{opts.remote} #{opts.branch}`
80
+
81
+ puts "\nInstalling new version of gem..."
82
+ `gem specific_install -l #{opts.repo_url}`
83
+
84
+ puts "\nFinished!\n\n"
data/lib/gpig.rb CHANGED
@@ -1,4 +1,5 @@
1
- require "gpig/engine"
1
+
2
+ require "gpig/version"
2
3
 
3
4
  module Gpig
4
5
  end
data/lib/gpig/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Gpig
2
- VERSION = "0.0.2"
2
+ VERSION = '0.0.4'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gpig
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-04 00:00:00.000000000 Z
12
+ date: 2013-06-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: specific_install
@@ -27,6 +27,22 @@ dependencies:
27
27
  - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
29
  version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: trollop
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
30
46
  description: A tool to quickly add files to a git repo, push, and then use specific_install
31
47
  to install the new gem.
32
48
  email:
@@ -37,7 +53,6 @@ extensions: []
37
53
  extra_rdoc_files: []
38
54
  files:
39
55
  - bin/gpig
40
- - lib/gpig/engine.rb
41
56
  - lib/gpig/version.rb
42
57
  - lib/gpig.rb
43
58
  - MIT-LICENSE
data/lib/gpig/engine.rb DELETED
@@ -1,5 +0,0 @@
1
-
2
- module Gpig
3
- class Engine < ::Rails::Engine
4
- end
5
- end