pullable 0.0.2 → 1.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 +4 -4
- data/README.md +24 -3
- data/bin/pullable +1 -1
- data/lib/pullable/directory.rb +60 -0
- data/lib/pullable/version.rb +1 -1
- data/lib/pullable.rb +7 -35
- data/pullable.gemspec +11 -9
- data/spec/lib/pullable/directory_spec.rb +60 -0
- data/spec/pullable_spec.rb +15 -0
- data/spec/spec_helper.rb +8 -0
- metadata +33 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: ba1c8bbf6d383e5772d0cf55811f4afc961e3b63
         | 
| 4 | 
            +
              data.tar.gz: e83d49e8d69e26d12babda9ccf6778720372995d
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: ab68f3c9aacd86de1e4fc6f349bbfba9867b0f8302dbe41cb6b1762bcd4c29cc85d6fae38cd2f159fc0db087269238ca7c315c7199ac9f8890e9e3353ee52726
         | 
| 7 | 
            +
              data.tar.gz: 66c727d42f2cfccd7ea70789fd64b2b341a6bb5caed73554a629c9103b919858d3c5277982ebc43850e7b0f81a7fa322b4d8bf9e75deb85f20aaa0aa83218bfe
         | 
    
        data/README.md
    CHANGED
    
    | @@ -1,5 +1,7 @@ | |
| 1 1 | 
             
            # Pullable
         | 
| 2 2 |  | 
| 3 | 
            +
            [](https://travis-ci.org/itsmeduncan/pullable)
         | 
| 4 | 
            +
             | 
| 3 5 | 
             
            Loop over a directory of Git repositories, fetch, and fast-forward merge from
         | 
| 4 6 | 
             
            origin.
         | 
| 5 7 |  | 
| @@ -19,9 +21,28 @@ Or install it yourself as: | |
| 19 21 |  | 
| 20 22 | 
             
            ## Usage
         | 
| 21 23 |  | 
| 22 | 
            -
             | 
| 23 | 
            -
             | 
| 24 | 
            -
             | 
| 24 | 
            +
                ls ~/Projects
         | 
| 25 | 
            +
                foo    bar    .DS_Store
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                pullable ~/Projects
         | 
| 28 | 
            +
                # cd ~/Projects
         | 
| 29 | 
            +
                # cd ~/Projects/foo
         | 
| 30 | 
            +
                # git fetch -p && git merge --ff-only origin/master
         | 
| 31 | 
            +
                # cd ~/Projects/bar
         | 
| 32 | 
            +
                # git fetch -p && git merge --ff-only origin/master
         | 
| 33 | 
            +
                 
         | 
| 34 | 
            +
                pullable ~/Projects pull
         | 
| 35 | 
            +
                # cd ~/Projects
         | 
| 36 | 
            +
                # cd ~/Projects/foo
         | 
| 37 | 
            +
                # git fetch -p && git pull origin master
         | 
| 38 | 
            +
                # cd ~/Projects/bar
         | 
| 39 | 
            +
                # git fetch -p && git pull origin master
         | 
| 40 | 
            +
             | 
| 41 | 
            +
            ## TODO
         | 
| 42 | 
            +
             | 
| 43 | 
            +
            * Logging
         | 
| 44 | 
            +
            * Finer grain command line options
         | 
| 45 | 
            +
            * Grit?
         | 
| 25 46 |  | 
| 26 47 | 
             
            ## Contributing
         | 
| 27 48 |  | 
    
        data/bin/pullable
    CHANGED
    
    
| @@ -0,0 +1,60 @@ | |
| 1 | 
            +
            require 'fileutils'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Pullable
         | 
| 4 | 
            +
              class Directory
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                VALID_METHODS = ['pull', 'merge']
         | 
| 7 | 
            +
                SKIPPED_DIRECTORIES = ['.DS_Store']
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                attr_reader :path, :method
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                def initialize(path, method)
         | 
| 12 | 
            +
                  unless File.directory?(path)
         | 
| 13 | 
            +
                    raise ArgumentError.new('Please pass a directory that exists!')
         | 
| 14 | 
            +
                  end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                  unless VALID_METHODS.include?(method)
         | 
| 17 | 
            +
                    raise ArgumentError.new("#{method} cannot be used to update the repo!")
         | 
| 18 | 
            +
                  end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                  @path   = path
         | 
| 21 | 
            +
                  @method = method
         | 
| 22 | 
            +
                end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                def process!
         | 
| 25 | 
            +
                  Dir.foreach(path) do |directory|
         | 
| 26 | 
            +
                    if File.directory?(directory)
         | 
| 27 | 
            +
                      unless SKIPPED_DIRECTORIES.include?(directory)
         | 
| 28 | 
            +
                        FileUtils.cd(directory)
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                        if File.directory?('.git')
         | 
| 31 | 
            +
                          puts "Updated:\t#{directory}"
         | 
| 32 | 
            +
                          update!
         | 
| 33 | 
            +
                        end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                        FileUtils.cd(path)
         | 
| 36 | 
            +
                      end
         | 
| 37 | 
            +
                    end
         | 
| 38 | 
            +
                  end
         | 
| 39 | 
            +
                end
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                def self.process!(path, method = 'merge')
         | 
| 42 | 
            +
                  new(path, method).process!
         | 
| 43 | 
            +
                end
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                def update!
         | 
| 46 | 
            +
                  system "git fetch -p && #{command} > /dev/null"
         | 
| 47 | 
            +
                end
         | 
| 48 | 
            +
             | 
| 49 | 
            +
                def command
         | 
| 50 | 
            +
                  case @method
         | 
| 51 | 
            +
                  when 'merge'
         | 
| 52 | 
            +
                    'git merge --ff-only origin/master'
         | 
| 53 | 
            +
                  when 'pull'
         | 
| 54 | 
            +
                    'git pull origin master'
         | 
| 55 | 
            +
                  else
         | 
| 56 | 
            +
                    raise NotImplementedError
         | 
| 57 | 
            +
                  end
         | 
| 58 | 
            +
                end
         | 
| 59 | 
            +
              end
         | 
| 60 | 
            +
            end
         | 
    
        data/lib/pullable/version.rb
    CHANGED
    
    
    
        data/lib/pullable.rb
    CHANGED
    
    | @@ -1,42 +1,14 @@ | |
| 1 | 
            -
            require  | 
| 2 | 
            -
            require  | 
| 3 | 
            -
             | 
| 4 | 
            -
            SKIPPED_DIRECTORIES = ['.DS_Store']
         | 
| 1 | 
            +
            require 'pullable/directory'
         | 
| 2 | 
            +
            require 'pullable/version'
         | 
| 5 3 |  | 
| 6 4 | 
             
            module Pullable
         | 
| 7 5 |  | 
| 8 | 
            -
              def self.process!( | 
| 9 | 
            -
                 | 
| 10 | 
            -
             | 
| 11 | 
            -
                raise ArgumentError.new("Please pass a root directoy!") if root.nil?
         | 
| 12 | 
            -
                raise ArgumentError.new("Please pass a valid root directoy!") unless File.directory?(root)
         | 
| 13 | 
            -
             | 
| 14 | 
            -
                Dir.foreach(root) do |directory|
         | 
| 15 | 
            -
                  if File.directory?(directory)
         | 
| 16 | 
            -
                    unless SKIPPED_DIRECTORIES.include?(directory)
         | 
| 17 | 
            -
                      FileUtils.cd(directory)
         | 
| 18 | 
            -
             | 
| 19 | 
            -
                      if File.directory?('.git')
         | 
| 20 | 
            -
                        puts "Pulling:\t#{directory}"
         | 
| 21 | 
            -
                        `git fetch -p`
         | 
| 22 | 
            -
                        `git merge --ff-only origin/master`
         | 
| 23 | 
            -
                      end
         | 
| 24 | 
            -
             | 
| 25 | 
            -
                      unless $?.success?
         | 
| 26 | 
            -
                        failed << directory
         | 
| 27 | 
            -
                      else
         | 
| 28 | 
            -
                        pulled << directory
         | 
| 29 | 
            -
                      end
         | 
| 30 | 
            -
             | 
| 31 | 
            -
                      FileUtils.cd(root)
         | 
| 32 | 
            -
                    end
         | 
| 33 | 
            -
                  else
         | 
| 34 | 
            -
                    skipped << directory
         | 
| 35 | 
            -
                  end
         | 
| 6 | 
            +
              def self.process!(path, method = 'merge')
         | 
| 7 | 
            +
                if method == '' || method == nil
         | 
| 8 | 
            +
                  method = 'merge'
         | 
| 36 9 | 
             
                end
         | 
| 37 10 |  | 
| 38 | 
            -
                 | 
| 39 | 
            -
                puts "Skipped:\t#{skipped.inspect}" unless skipped.empty?
         | 
| 40 | 
            -
                puts "Failed:\t\t#{failed.inspect}" unless failed.empty?
         | 
| 11 | 
            +
                Pullable::Directory.process!(path, method)
         | 
| 41 12 | 
             
              end
         | 
| 13 | 
            +
             | 
| 42 14 | 
             
            end
         | 
    
        data/pullable.gemspec
    CHANGED
    
    | @@ -4,21 +4,23 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) | |
| 4 4 | 
             
            require 'pullable/version'
         | 
| 5 5 |  | 
| 6 6 | 
             
            Gem::Specification.new do |spec|
         | 
| 7 | 
            -
              spec.name          =  | 
| 7 | 
            +
              spec.name          = 'pullable'
         | 
| 8 8 | 
             
              spec.version       = Pullable::VERSION
         | 
| 9 | 
            -
              spec.authors       = [ | 
| 10 | 
            -
              spec.email         = [ | 
| 9 | 
            +
              spec.authors       = ['Duncan Grazier']
         | 
| 10 | 
            +
              spec.email         = ['itsmeduncan@gmail.com']
         | 
| 11 11 | 
             
              spec.description   = %q{Update your Git repositories}
         | 
| 12 12 | 
             
              spec.summary       = %q{A simple tool to update your local repositories}
         | 
| 13 | 
            -
              spec.homepage      =  | 
| 14 | 
            -
              spec.license       =  | 
| 13 | 
            +
              spec.homepage      = 'https://github.com/itsmeduncan/pullable'
         | 
| 14 | 
            +
              spec.license       = 'MIT'
         | 
| 15 15 |  | 
| 16 16 | 
             
              spec.files         = `git ls-files`.split($/)
         | 
| 17 17 | 
             
              spec.executables   = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
         | 
| 18 18 | 
             
              spec.test_files    = spec.files.grep(%r{^(test|spec|features)/})
         | 
| 19 | 
            -
              spec.require_paths = [ | 
| 19 | 
            +
              spec.require_paths = ['lib']
         | 
| 20 20 |  | 
| 21 | 
            -
              spec.add_development_dependency  | 
| 22 | 
            -
              spec.add_development_dependency  | 
| 23 | 
            -
              spec.add_development_dependency  | 
| 21 | 
            +
              spec.add_development_dependency 'bundler', '~> 1.3'
         | 
| 22 | 
            +
              spec.add_development_dependency 'mocha'
         | 
| 23 | 
            +
              spec.add_development_dependency 'rake'
         | 
| 24 | 
            +
              spec.add_development_dependency 'rspec'
         | 
| 25 | 
            +
              spec.add_development_dependency 'simplecov'
         | 
| 24 26 | 
             
            end
         | 
| @@ -0,0 +1,60 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe Pullable::Directory do
         | 
| 4 | 
            +
             | 
| 5 | 
            +
              describe '.new' do
         | 
| 6 | 
            +
                it 'raises if the directory does not exist' do
         | 
| 7 | 
            +
                  File.expects(:directory?).with('foo').returns(false)
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                  expect {
         | 
| 10 | 
            +
                    described_class.new('foo', 'merge')
         | 
| 11 | 
            +
                  }.to raise_error(ArgumentError, 'Please pass a directory that exists!')
         | 
| 12 | 
            +
                end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                it 'raises if the method is invalid' do
         | 
| 15 | 
            +
                  expect {
         | 
| 16 | 
            +
                    described_class.new('.', 'foo')
         | 
| 17 | 
            +
                  }.to raise_error(ArgumentError, 'foo cannot be used to update the repo!')
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
              end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
              describe '#process!' do
         | 
| 22 | 
            +
                it 'initializes a new Pullable::Directory with the given parameters' do
         | 
| 23 | 
            +
                  Pullable::Directory.expects(:new).with('foo', 'bar').returns(mock(:process! => true))
         | 
| 24 | 
            +
                  Pullable::Directory.process!('foo', 'bar')
         | 
| 25 | 
            +
                end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                it 'defaults the method to merge' do
         | 
| 28 | 
            +
                  Pullable::Directory.expects(:new).with('foo', 'merge').returns(mock(:process! => true))
         | 
| 29 | 
            +
                  Pullable::Directory.process!('foo')
         | 
| 30 | 
            +
                end
         | 
| 31 | 
            +
              end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
              describe '.process!' do
         | 
| 34 | 
            +
                it 'calls update for each directory that has a .git under the root'
         | 
| 35 | 
            +
                it 'skips known weird directories'
         | 
| 36 | 
            +
                it 'skips non-git repos'
         | 
| 37 | 
            +
              end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
              describe '#update!' do
         | 
| 40 | 
            +
                it 'calls the correct system command' do
         | 
| 41 | 
            +
                  directory = described_class.new('.', 'merge')
         | 
| 42 | 
            +
                  directory.expects(:system).with('git fetch -p && git merge --ff-only origin/master > /dev/null')
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                  directory.update!
         | 
| 45 | 
            +
                end
         | 
| 46 | 
            +
              end
         | 
| 47 | 
            +
             | 
| 48 | 
            +
              describe "#command" do
         | 
| 49 | 
            +
                it 'generates the merge command' do
         | 
| 50 | 
            +
                  directory = described_class.new('.', 'merge')
         | 
| 51 | 
            +
                  directory.command.should == 'git merge --ff-only origin/master'
         | 
| 52 | 
            +
                end
         | 
| 53 | 
            +
             | 
| 54 | 
            +
                it 'generates the pull command' do
         | 
| 55 | 
            +
                  directory = described_class.new('.', 'pull')
         | 
| 56 | 
            +
                  directory.command.should == 'git pull origin master'
         | 
| 57 | 
            +
                end
         | 
| 58 | 
            +
              end
         | 
| 59 | 
            +
             | 
| 60 | 
            +
            end
         | 
    
        data/spec/pullable_spec.rb
    CHANGED
    
    | @@ -6,4 +6,19 @@ describe Pullable do | |
| 6 6 | 
             
                Pullable::VERSION.should_not be_nil
         | 
| 7 7 | 
             
              end
         | 
| 8 8 |  | 
| 9 | 
            +
              it 'calls process! with the correct arguments' do
         | 
| 10 | 
            +
                Pullable::Directory.expects(:process!).with('foo', 'bar')
         | 
| 11 | 
            +
                Pullable.process!('foo', 'bar')
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              it 'handles a blank string for the method' do
         | 
| 15 | 
            +
                Pullable::Directory.expects(:process!).with('foo', 'merge')
         | 
| 16 | 
            +
                Pullable.process!('foo', '')
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
              it 'handles a nil method' do
         | 
| 20 | 
            +
                Pullable::Directory.expects(:process!).with('foo', 'merge')
         | 
| 21 | 
            +
                Pullable.process!('foo')
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
             | 
| 9 24 | 
             
            end
         | 
    
        data/spec/spec_helper.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: pullable
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version:  | 
| 4 | 
            +
              version: 1.0.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Duncan Grazier
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2013-09- | 
| 11 | 
            +
            date: 2013-09-06 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: bundler
         | 
| @@ -24,6 +24,20 @@ dependencies: | |
| 24 24 | 
             
                - - ~>
         | 
| 25 25 | 
             
                  - !ruby/object:Gem::Version
         | 
| 26 26 | 
             
                    version: '1.3'
         | 
| 27 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 28 | 
            +
              name: mocha
         | 
| 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'
         | 
| 27 41 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 28 42 | 
             
              name: rake
         | 
| 29 43 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -52,6 +66,20 @@ dependencies: | |
| 52 66 | 
             
                - - '>='
         | 
| 53 67 | 
             
                  - !ruby/object:Gem::Version
         | 
| 54 68 | 
             
                    version: '0'
         | 
| 69 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 70 | 
            +
              name: simplecov
         | 
| 71 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 72 | 
            +
                requirements:
         | 
| 73 | 
            +
                - - '>='
         | 
| 74 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 75 | 
            +
                    version: '0'
         | 
| 76 | 
            +
              type: :development
         | 
| 77 | 
            +
              prerelease: false
         | 
| 78 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 79 | 
            +
                requirements:
         | 
| 80 | 
            +
                - - '>='
         | 
| 81 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 82 | 
            +
                    version: '0'
         | 
| 55 83 | 
             
            description: Update your Git repositories
         | 
| 56 84 | 
             
            email:
         | 
| 57 85 | 
             
            - itsmeduncan@gmail.com
         | 
| @@ -71,8 +99,10 @@ files: | |
| 71 99 | 
             
            - Rakefile
         | 
| 72 100 | 
             
            - bin/pullable
         | 
| 73 101 | 
             
            - lib/pullable.rb
         | 
| 102 | 
            +
            - lib/pullable/directory.rb
         | 
| 74 103 | 
             
            - lib/pullable/version.rb
         | 
| 75 104 | 
             
            - pullable.gemspec
         | 
| 105 | 
            +
            - spec/lib/pullable/directory_spec.rb
         | 
| 76 106 | 
             
            - spec/pullable_spec.rb
         | 
| 77 107 | 
             
            - spec/spec_helper.rb
         | 
| 78 108 | 
             
            homepage: https://github.com/itsmeduncan/pullable
         | 
| @@ -100,5 +130,6 @@ signing_key: | |
| 100 130 | 
             
            specification_version: 4
         | 
| 101 131 | 
             
            summary: A simple tool to update your local repositories
         | 
| 102 132 | 
             
            test_files:
         | 
| 133 | 
            +
            - spec/lib/pullable/directory_spec.rb
         | 
| 103 134 | 
             
            - spec/pullable_spec.rb
         | 
| 104 135 | 
             
            - spec/spec_helper.rb
         |