gitfyncy 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rvmrc ADDED
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
+ # development environment upon cd'ing into the directory
5
+
6
+ # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
7
+ # Only full ruby name is supported here, for short names use:
8
+ # echo "rvm use 1.9.3" > .rvmrc
9
+ environment_id="ruby-1.9.3-p385"
10
+
11
+ # Uncomment the following lines if you want to verify rvm version per project
12
+ # rvmrc_rvm_version="1.18.6 (stable)" # 1.10.1 seams as a safe start
13
+ # eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
14
+ # echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
15
+ # return 1
16
+ # }
17
+
18
+ # First we attempt to load the desired environment directly from the environment
19
+ # file. This is very fast and efficient compared to running through the entire
20
+ # CLI and selector. If you want feedback on which environment was used then
21
+ # insert the word 'use' after --create as this triggers verbose mode.
22
+ if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
23
+ && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
24
+ then
25
+ \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
26
+ [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
27
+ \. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
28
+ else
29
+ # If the environment file has not yet been created, use the RVM CLI to select.
30
+ rvm --create "$environment_id" || {
31
+ echo "Failed to create RVM environment '${environment_id}'."
32
+ return 1
33
+ }
34
+ fi
35
+
36
+ # If you use bundler, this might be useful to you:
37
+ # if [[ -s Gemfile ]] && {
38
+ # ! builtin command -v bundle >/dev/null ||
39
+ # builtin command -v bundle | GREP_OPTIONS= \grep $rvm_path/bin/bundle >/dev/null
40
+ # }
41
+ # then
42
+ # printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
43
+ # gem install bundler
44
+ # fi
45
+ # if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
46
+ # then
47
+ # bundle install | GREP_OPTIONS= \grep -vE '^Using|Your bundle is complete'
48
+ # fi
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in gitfyncy.gemspec
4
+ gemspec
5
+
6
+ group :development do
7
+ gem 'pry'
8
+ gem 'pry-debugger'
9
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Ryan McGowan
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
+ # git-fyncy
2
+
3
+ The funky git aware remote syncer.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'gitfyncy'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install gitfyncy
18
+
19
+ ## Usage
20
+
21
+ Sync the current working directory to the given path on the given remote:
22
+
23
+ $ git fyncy <remote> <path>
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it
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 new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/git-fyncy ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require 'gitfyncy'
3
+
4
+ Gitfyncy::main(*ARGV)
data/gitfyncy.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'gitfyncy/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "gitfyncy"
8
+ gem.version = Gitfyncy::VERSION
9
+ gem.authors = ["Ryan McGowan"]
10
+ gem.email = ["ryan@ryanmcg.com"]
11
+ gem.description = %q{The funky git aware syncer.}
12
+ gem.summary = %q{Want to sync the working directories of your git
13
+ directory with a remote one. Look no futher.}
14
+ gem.homepage = "https://github.com/RyanMcG/git-fyncy"
15
+
16
+ gem.files = `git ls-files`.split($/)
17
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
+ gem.require_paths = ["lib"]
20
+
21
+ [['listen', '~> 1.3']].each do |dep|
22
+ gem.add_dependency(*dep)
23
+ end
24
+ end
data/lib/gitfyncy.rb ADDED
@@ -0,0 +1,76 @@
1
+ require "gitfyncy/version"
2
+ require 'listen'
3
+
4
+ module Gitfyncy
5
+ PREFIX = 'git-fyncy'
6
+
7
+ def self.slashify(path)
8
+ path[-1] == '/' ? path : path + '/'
9
+ end
10
+
11
+ RELATIVE_PATH = slashify `pwd`.rstrip
12
+
13
+ class Remote
14
+ def initialize(remote, path)
15
+ @remote = remote
16
+ @path = Gitfyncy.slashify path
17
+ end
18
+
19
+ def command(cmd)
20
+ puts "#{Gitfyncy::PREFIX}: #{cmd}"
21
+ system cmd
22
+ end
23
+
24
+ def scp(paths)
25
+ return if paths.empty?
26
+ command "rsync -zR #{paths.to_a.join ' '} #{@remote}:#{@path}"
27
+ end
28
+
29
+ def ssh_rm(paths)
30
+ return if paths.empty?
31
+ command "ssh #{@remote} 'cd #{@path}; rm -f #{paths.to_a.join ' '}'"
32
+ end
33
+ end
34
+
35
+ def self.relative_path(path)
36
+ path.slice! RELATIVE_PATH
37
+ path
38
+ end
39
+
40
+ def self.git_aware_files
41
+ `git ls-files -mo --exclude-standard`.split("\n")
42
+ end
43
+
44
+ def self.git_aware_of_path?(path)
45
+ self.git_aware_files.include? path
46
+ end
47
+
48
+ def self.pexit(error)
49
+ puts error
50
+ exit 1
51
+ end
52
+
53
+ def self.main(remote, path)
54
+ pexit 'A remote and path must be specified' unless remote && path
55
+ remote = Remote.new remote, path
56
+ controlled_paths = Set.new git_aware_files
57
+ remote.scp controlled_paths
58
+ relpath = method :relative_path
59
+ Listen.to!('.') do |modified, added, removed|
60
+ begin
61
+ changed_paths = (modified + added).map(&relpath).
62
+ select(&method(:git_aware_of_path?))
63
+ remote.scp changed_paths
64
+
65
+ controlled_removed = controlled_paths.intersection removed.map(&relpath)
66
+ controlled_paths.merge changed_paths
67
+
68
+ if remote.ssh_rm controlled_removed
69
+ controlled_paths.subtract controlled_removed
70
+ end
71
+ rescue => e
72
+ puts e.inspect
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,3 @@
1
+ module Gitfyncy
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gitfyncy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Ryan McGowan
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-08-16 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: listen
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.3'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.3'
30
+ description: The funky git aware syncer.
31
+ email:
32
+ - ryan@ryanmcg.com
33
+ executables:
34
+ - git-fyncy
35
+ extensions: []
36
+ extra_rdoc_files: []
37
+ files:
38
+ - .gitignore
39
+ - .rvmrc
40
+ - Gemfile
41
+ - LICENSE.txt
42
+ - README.md
43
+ - Rakefile
44
+ - bin/git-fyncy
45
+ - gitfyncy.gemspec
46
+ - lib/gitfyncy.rb
47
+ - lib/gitfyncy/version.rb
48
+ homepage: https://github.com/RyanMcG/git-fyncy
49
+ licenses: []
50
+ post_install_message:
51
+ rdoc_options: []
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ! '>='
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ requirements: []
67
+ rubyforge_project:
68
+ rubygems_version: 1.8.25
69
+ signing_key:
70
+ specification_version: 3
71
+ summary: Want to sync the working directories of your git directory with a remote
72
+ one. Look no futher.
73
+ test_files: []