revans-gitools 0.3.0

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.
data/CHANGELOG.rdoc ADDED
@@ -0,0 +1,8 @@
1
+ Version 0.3.0
2
+ * Added command line tools
3
+
4
+ Version 0.2.0
5
+ * Added individual task method
6
+
7
+ Version 0.1.0
8
+ * Initial Creation
data/LICENSE ADDED
@@ -0,0 +1,18 @@
1
+ Copyright (c) 2009 Robert R Evans, Code Wranglers, Inc.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the "Software"), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7
+ the Software, and to permit persons to whom the Software is furnished to do so,
8
+ subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.markdown ADDED
@@ -0,0 +1,80 @@
1
+ # Git_tools
2
+
3
+ ## How to use
4
+
5
+ Create a yaml file in your config/ directory and name it submodules.yml.
6
+
7
+ Add the git submodules that you want to want to use in your application like so:
8
+
9
+ <pre>
10
+ submodules:
11
+ rspec: git://github.com/dchelimsky/rspec.git
12
+ rspec_rails: git://github.com/dchelimsky/rspec-rails.git
13
+ geokit: git://github.com/ptb/geokit.git
14
+ asset_packager: git://github.com/sbecker/asset_packager.git
15
+ paperclip: git://github.com/thoughtbot/paperclip.git
16
+ will_paginate: git://github.com/mislav/will_paginate.git
17
+ exception_notification: git://github.com/rails/exception_notification.git
18
+ cucumber: git://github.com/aslakhellesoy/cucumber.git
19
+ ssl_requirement: git://github.com/rails/ssl_requirement.git
20
+ rails: git://github.com/rails/rails.git
21
+ active_merchant: git://github.com/Shopify/active_merchant.git
22
+ </pre>
23
+
24
+ A couple of things, it needs to follow the structure above with the name submodules and defining each below it. Use the name
25
+ that you want the plugin to be named when checking out. Put the git location as the value.
26
+
27
+ Now, create a new Rake task in lib/tasks directory. I call mine submodules.rake. Here is what my file looks like:
28
+
29
+ <pre>
30
+ require 'gitools'
31
+
32
+ @configration = File.join(RAILS_ROOT, "config/submodules.yml")
33
+
34
+ namespace :git do
35
+
36
+ namespace :submodule do
37
+
38
+ desc "Remove Submodule cache"
39
+ task :remove, :submodule do |task, args|
40
+ GitTools::Submodule.remove(args.submodule)
41
+ end
42
+
43
+ end
44
+
45
+
46
+ namespace :update do
47
+
48
+ desc "Update all Submodules"
49
+ task :all => :environment do
50
+ GitTools::Submodule.update_all(@configration)
51
+ end
52
+
53
+
54
+ GitTools::Submodule.individual_tasks(@configration) do |name|
55
+ desc "Update #{name} submodule"
56
+ task name.to_sym => :environment do
57
+ GitTools::Submodule.submodule_update("#{name}")
58
+ end
59
+ end
60
+
61
+ end
62
+
63
+ end
64
+ </pre>
65
+
66
+
67
+ ## Command Line
68
+
69
+ When creating a new project, it would be nice to just write your submodule.yml file and then shoot a command off in the terminal and have all your submodules installed for you. Well, now you can! Just do:
70
+
71
+ <pre>
72
+ gitools all
73
+ </pre>
74
+
75
+ That will install all the submodules from your config/submodule.yml file. Here are a couple more commands you can run:
76
+
77
+ <pre>
78
+ gitools -u # For a fresh clone that needs the submodules init/update
79
+ gitools rails # To add rails as a submodule, if you have it specified in your config/submodules.yml file
80
+ </pre>
data/Rakefile ADDED
File without changes
data/bin/gitools ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'gitools'
5
+
6
+
7
+ options = GitTools::Options.parse!(ARGV)
8
+ GitTools::CI.get(options)
data/lib/gitools/ci.rb ADDED
@@ -0,0 +1,18 @@
1
+ module GitTools
2
+ class CI
3
+
4
+ def self.get(options)
5
+ init = new
6
+ @options = options
7
+ @yaml = File.join(@options.yaml, 'config/submodules.yml')
8
+ if @options.update
9
+ GitTools::Submodule.checkout
10
+ elsif @options.library == "all"
11
+ GitTools::Submodule.install_all(@yaml)
12
+ else
13
+ GitTools::Submodule.install_single(@yaml, @options.library)
14
+ end
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,13 @@
1
+ submodules:
2
+ rspec: git://github.com/dchelimsky/rspec.git
3
+ rspec_rails: git://github.com/dchelimsky/rspec-rails.git
4
+ geokit: git://github.com/ptb/geokit.git
5
+ asset_packager: git://github.com/sbecker/asset_packager.git
6
+ paperclip: git://github.com/thoughtbot/paperclip.git
7
+ will_paginate: git://github.com/mislav/will_paginate.git
8
+ ultrasphinx: git://github.com/fauna/ultrasphinx.git
9
+ exception_notification: git://github.com/rails/exception_notification.git
10
+ open_id_authentication: git://github.com/rails/open_id_authentication.git
11
+ cucumber: git://github.com/aslakhellesoy/cucumber.git
12
+ ssl_requirement: git://github.com/rails/ssl_requirement.git
13
+ rails: git://github.com/rails/rails.git
@@ -0,0 +1,43 @@
1
+ module GitTools
2
+ class Options
3
+
4
+ def self.parse!(args)
5
+ options = OpenStruct.new
6
+ options.library = args.first.sub(/(\s+)/, '_') unless args.first.nil?
7
+ options.yaml = Dir.pwd
8
+
9
+ opts = OptionParser.new do |opts|
10
+
11
+ opts.banner = "\nGit Tools Usage: gitools all will install all your git submodules"
12
+ opts.separator "You must be in your Application Root Directory when running this command."
13
+ opts.separator ""
14
+
15
+ opts.on('-u', '--update', 'Update the Submodule instead of adding it.') do |ext|
16
+ options.update = ext
17
+ end
18
+
19
+ opts.on_tail('-v', '--version', "Show GitTools' current version.") do
20
+ puts "\nGit Tools is at version #{GitTools::Version}\n"
21
+ exit(0)
22
+ end
23
+
24
+ opts.on_tail('-h', '--help', "Help Me!") do
25
+ puts "#{opts}\n"
26
+ exit(0)
27
+ end
28
+
29
+ opts.on_tail do
30
+ if (options.library.nil? || options.library == '') && !options.udpate
31
+ puts "\nYou need to tell me what you want library you want to add to git submodule."
32
+ puts "#{opts}\n"
33
+ exit(0)
34
+ end
35
+ end
36
+ end # OptionParser
37
+
38
+ opts.parse!(args)
39
+ options
40
+ end # parse!
41
+
42
+ end
43
+ end
@@ -0,0 +1,61 @@
1
+ module GitTools
2
+
3
+ # TODO: Refactor Class
4
+ class Submodule
5
+
6
+ def self.update_all(yaml)
7
+ @config = load_yaml(yaml)
8
+ @config.each_key do |name|
9
+ message(name) { submodule_update(name) }
10
+ end
11
+ end
12
+
13
+ def self.install_all(yaml)
14
+ @config = load_yaml(yaml)
15
+ @config.each { |plugin, repo| add(plugin, repo) }
16
+ end
17
+
18
+ def self.install_single(yaml, name)
19
+ @config = load_yaml(yaml)
20
+ add(name, @config[name])
21
+ end
22
+
23
+ def self.add(name, repo)
24
+ dir = name == "rails" ? "vendor/rails/" : "vendor/plugins/#{name}"
25
+ system("git submodule add #{repo} #{dir}")
26
+ end
27
+
28
+ def self.checkout
29
+ system("git submodule init")
30
+ system("git submodule update")
31
+ end
32
+
33
+ def self.remove(submodule)
34
+ system("git rm --cache vendor/plugins/#{submodule}")
35
+ end
36
+
37
+ def self.submodule_update(name)
38
+ dir = name == "rails" ? "vendor/rails/" : "vendor/plugins/#{name}"
39
+ system("cd #{dir} && git remote update && git merge origin/master")
40
+ end
41
+
42
+ def self.load_yaml(yaml)
43
+ YAML::load(File.open(yaml))['submodules']
44
+ end
45
+
46
+
47
+ def self.message(name, &block)
48
+ puts "Updating #{name.to_s}"
49
+ yield
50
+ puts "\n"
51
+ end
52
+
53
+
54
+ def self.individual_tasks(yaml, &block)
55
+ @config = load_yaml(yaml)
56
+ @config.each_key { |name| yield name }
57
+ end
58
+
59
+ end
60
+
61
+ end
data/lib/gitools.rb ADDED
@@ -0,0 +1,12 @@
1
+ module GitTools
2
+ Version = "0.3.0"
3
+ end
4
+
5
+ # Required Gems
6
+ %w[optparse ostruct].each { |library| require library }
7
+
8
+ # Gem specific Requires
9
+ require File.dirname(__FILE__) + "/gitools/submodules.rb"
10
+ require File.dirname(__FILE__) + "/gitools/parse.rb"
11
+ require File.dirname(__FILE__) + "/gitools/ci.rb"
12
+ # require File.dirname(__FILE__) + "/git_tools/"
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: revans-gitools
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.0
5
+ platform: ruby
6
+ authors:
7
+ - Robert R Evans
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-01-21 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: An easy way to manage your git submodules in a Rails Application.
17
+ email: robert@codewranglers.org
18
+ executables:
19
+ - gitools
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README.markdown
24
+ - CHANGELOG.rdoc
25
+ - LICENSE
26
+ files:
27
+ - README.markdown
28
+ - LICENSE
29
+ - CHANGELOG.rdoc
30
+ - Rakefile
31
+ - bin/gitools
32
+ - lib/gitools.rb
33
+ - lib/gitools/submodules.rb
34
+ - lib/gitools/config/submodules.yml
35
+ - lib/gitools/parse.rb
36
+ - lib/gitools/ci.rb
37
+ has_rdoc: true
38
+ homepage: http://codewranglers.org
39
+ post_install_message:
40
+ rdoc_options: []
41
+
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: "0"
49
+ version:
50
+ required_rubygems_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: "0"
55
+ version:
56
+ requirements: []
57
+
58
+ rubyforge_project: gitools
59
+ rubygems_version: 1.2.0
60
+ signing_key:
61
+ specification_version: 2
62
+ summary: An easy way to manage your git submodules in a Rails Application.
63
+ test_files: []
64
+