Skip to content
This repository has been archived by the owner on Mar 31, 2022. It is now read-only.

Commit

Permalink
renamed the guard and added some information to the gemspec
Browse files Browse the repository at this point in the history
  • Loading branch information
pmcjury committed Aug 3, 2012
1 parent 63101fb commit 6846863
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 51 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -18,3 +18,4 @@ test/tmp
test/version_tmp
tmp
.DS_Store
*.sublime*
4 changes: 2 additions & 2 deletions README.md
@@ -1,4 +1,4 @@
guard-rsyncx
guard-rsync-remote
============

**Usage**
Expand All @@ -8,7 +8,7 @@ bundle exec guard

**Example Guardfile**
```
guard 'rsyncx',
guard 'rsync-remote',
:source => ".",
:destination => '/export/home/{username}/tmp',
:user => '{user}',
Expand Down
14 changes: 7 additions & 7 deletions guard-rsyncx.gemspec → guard-remote-sync.gemspec
@@ -1,19 +1,19 @@
# encoding: utf-8
$:.push File.expand_path("../lib", __FILE__)
require "guard/rsyncx/version"
require "guard/remote-sync/version"

Gem::Specification.new do |s|
s.name = "guard-rsyncx"
s.version = Guard::RsyncXVersion::VERSION
s.name = "guard-remote-sync"
s.version = Guard::RemoteSyncVersion::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ["Patrick McJury"]
s.email = ["pmcjury@mcjent.com"]
s.homepage = "https://github.com/pmcjury/guard-rsyncx"
s.summary = "Guard gem for Rsync"
s.description = "Guard::RsyncX automatically rsync your files."
s.homepage = "https://github.com/pmcjury/guard-remote-sync"
s.summary = "Guard gem for Remote Syncing through rsync"
s.description = "Guard::RemoteSync to automatically rsync your files."

s.required_rubygems_version = ">= 1.3.6"
s.rubyforge_project = "guard-rsynchx"
s.rubyforge_project = "guard-remote-synch"

s.add_dependency "guard", ">= 1.1.0"

Expand Down
26 changes: 13 additions & 13 deletions lib/guard/rsyncx.rb → lib/guard/remote-sync.rb
Expand Up @@ -2,10 +2,10 @@
require 'guard/guard'

module Guard
class RsyncX < Guard
class RemoteSync < Guard

autoload :Command, 'guard/rsyncx/command'
autoload :Source, 'guard/rsyncx/source'
autoload :Command, 'guard/remote-sync/command'
autoload :Source, 'guard/remote-sync/source'

attr_accessor :command

Expand Down Expand Up @@ -45,9 +45,9 @@ def initialize(watchers = [], options = {})
# Call once when Guard starts. Please override initialize method to init stuff.
# @raise [:task_has_failed] when start has failed
def start
throw([:task_has_failed], "Guard::RsyncX options invalid") unless options_valid?
UI.info "Guard::RsyncX started in source directory '#{File.expand_path @source.directory}'"
Notifier.notify("Guard::RsyncX is running in directory #{File.expand_path @source.directory}", notifier_options)
throw([:task_has_failed], "Guard::RemoteSync options invalid") unless options_valid?
UI.info "Guard::RemoteSync started in source directory '#{File.expand_path @source.directory}'"
Notifier.notify("Guard::RemoteSync is running in directory #{File.expand_path @source.directory}", notifier_options)
@command.sync if options[:sync_on_start] && @command.test

end
Expand All @@ -56,23 +56,23 @@ def start
# @raise [:task_has_failed] when stop has failed

def stop
UI.info "Guard::RsyncX stopped."
Notifier.notify("Guard::RsyncX stopped.",notifier_options)
UI.info "Guard::RemoteSync stopped."
Notifier.notify("Guard::RemoteSync stopped.",notifier_options)
end

# Called when `reload|r|z + enter` is pressed.
# This method should be mainly used for "reload" (really!) actions like reloading passenger/spork/bundler/...
# @raise [:task_has_failed] when reload has failed
def reload
Notifier.notify("Manual Guard::RsyncX synchronize #{File.expand_path @source.directory} to #{@destination.directory}",notifier_options)
Notifier.notify("Manual Guard::RemoteSync synchronize #{File.expand_path @source.directory} to #{@destination.directory}",notifier_options)
@command.sync
end

# Called when just `enter` is pressed
# This method should be principally used for long action like running all specs/tests/...
# @raise [:task_has_failed] when run_all has failed
def run_all
Notifier.notify("Manual Guard::RsyncX synchronize #{@source.directory} to #{@destination.directory}",notifier_options)
Notifier.notify("Manual Guard::RemoteSync synchronize #{@source.directory} to #{@destination.directory}",notifier_options)
@command.sync
end

Expand Down Expand Up @@ -103,18 +103,18 @@ def run_on_additions(paths)
def options_valid?
valid = true
if options[:source].nil? && options[:cli_options].nil?
UI.error("Guard::RsyncX a source directory is required")
UI.error("Guard::RemoteSync a source directory is required")
valid = false
end
if options[:destination].nil? && options[:cli_options].nil?
UI.error("Guard::RsyncX a source directory is required")
UI.error("Guard::RemoteSync a source directory is required")
valid = false
end
valid
end

def notifier_options
{:title => "Guard::RsyncX", :image => :success}
{:title => "Guard::RemoteSync", :image => :success}
end

end
Expand Down
@@ -1,5 +1,5 @@
module Guard
class RsyncX
class RemoteSync
class Command

attr_accessor :command, :source, :destination
Expand All @@ -12,9 +12,9 @@ def initialize(source, destination, options = {})
end

def sync
UI.info "Guard::RsyncX `#{@command}`"
UI.info "Guard::RemoteSync `#{@command}`"
r = `#{@command}`
UI.info "Guard::RsyncX Status : \n #{r}" if @options[:verbose]
UI.info "Guard::RemoteSync Status : \n #{r}" if @options[:verbose]
end

def test
Expand Down
@@ -1,5 +1,5 @@
module Guard
class RsyncX
class RemoteSync
class Source

attr_accessor :directory
Expand Down
@@ -1,4 +1,4 @@
guard 'rsyncx',
guard 'remote-sync',
:source => ".",
:destination => '/export/home/{username}/tmp',
:user => '{user}',
Expand Down
@@ -1,5 +1,5 @@
module Guard
module RsyncXVersion
module RemoteSyncVersion
VERSION = "0.0.1"
end
end
@@ -1,6 +1,6 @@
require "spec_helper"

describe Guard::RsyncX::Command do
describe Guard::RemoteSync::Command do

before(:each) do
File.stub!(:directory?).and_return(true)
Expand All @@ -9,17 +9,17 @@
describe "#initialize" do

let(:source) do
Guard::RsyncX::Source.new("./source")
Guard::RemoteSync::Source.new("./source")
end

let(:destination) do
Guard::RsyncX::Source.new("./destination")
Guard::RemoteSync::Source.new("./destination")
end

context "when :cli_options is given and other options are set" do
subject { command }
let(:command) do
Guard::RsyncX::Command.new(nil, nil, {
Guard::RemoteSync::Command.new(nil, nil, {
:cli_options => "-arv --exclude '*.*'",
:progress => true,
:include => "*.txt"
Expand All @@ -33,7 +33,7 @@
context "when :progress and :delete boolean options are given" do
subject { command }
let(:command) do
Guard::RsyncX::Command.new(source, destination, {
Guard::RemoteSync::Command.new(source, destination, {
:progress => true,
:delete => true,
})
Expand All @@ -46,7 +46,7 @@
context "when :include and :exclude nil options are given" do
subject { command }
let(:command) do
Guard::RsyncX::Command.new(source, destination, {
Guard::RemoteSync::Command.new(source, destination, {
:include => "*.rb",
:exclude => "*.txt",
})
Expand All @@ -59,7 +59,7 @@
context "when :dry_run option is set to true" do
subject { command }
let(:command) do
Guard::RsyncX::Command.new(source, destination, {
Guard::RemoteSync::Command.new(source, destination, {
:dry_run => true
})
end
Expand All @@ -73,7 +73,7 @@
context "when :archive is set to true" do
subject { command }
let(:command) do
Guard::RsyncX::Command.new(source, destination, {
Guard::RemoteSync::Command.new(source, destination, {
:archive => true,
})
end
Expand All @@ -84,7 +84,7 @@
context "and :recursive is set to true" do
subject { command }
let(:command) do
Guard::RsyncX::Command.new(source, destination, {
Guard::RemoteSync::Command.new(source, destination, {
:recursive => true
})
end
Expand All @@ -95,7 +95,7 @@
context "and :verbose is set to true" do
subject { command }
let(:command) do
Guard::RsyncX::Command.new(source, destination, {
Guard::RemoteSync::Command.new(source, destination, {
:verbose => true
})
end
Expand All @@ -106,7 +106,7 @@
context "and :verbose and :recursive are set to true" do
subject { command }
let(:command) do
Guard::RsyncX::Command.new(source, destination, {
Guard::RemoteSync::Command.new(source, destination, {
:recursive => true,
:verbose => true
})
Expand All @@ -120,11 +120,11 @@
context "user and remote address for remote rsync" do
subject { command }
let(:destination) do
Guard::RsyncX::Source.new("/remote/destination")
Guard::RemoteSync::Source.new("/remote/destination")
end
context "user options is given, and remote address is given" do
let(:command) do
Guard::RsyncX::Command.new(source, destination, {
Guard::RemoteSync::Command.new(source, destination, {
:user => "test",
:remote_address => "192.168.1.1"
})
Expand All @@ -150,15 +150,15 @@

describe "#sync" do
let(:source) do
Guard::RsyncX::Source.new("./source")
Guard::RemoteSync::Source.new("./source")
end
let(:destination) do
Guard::RsyncX::Source.new("/remote/destination")
Guard::RemoteSync::Source.new("/remote/destination")
end

context "some options are passed to initialize" do
it "should send the rsync command to the system" do
command = Guard::RsyncX::Command.new(source, destination, {
command = Guard::RemoteSync::Command.new(source, destination, {
:user => "test",
:remote_address => "192.168.1.1",
:archive => true,
Expand Down
@@ -1,6 +1,6 @@
require "spec_helper"

describe Guard::RsyncX::Source do
describe Guard::RemoteSync::Source do

describe "#initialize" do

Expand Down
6 changes: 3 additions & 3 deletions spec/guard/rsyncx_spec.rb → spec/guard/remote-sync_spec.rb
@@ -1,6 +1,6 @@
require "spec_helper"

describe Guard::RsyncX do
describe Guard::RemoteSync do

before(:each) do
File.stub!(:directory?).and_return(true)
Expand Down Expand Up @@ -52,7 +52,7 @@
end
it "should call the UI::info with the following message" do
File.stub!(:expand_path).and_return(source)
::Guard::UI.should_receive(:info).with("Guard::RsyncX started in source directory '#{source}'")
::Guard::UI.should_receive(:info).with("Guard::RemoteSync started in source directory '#{source}'")
guard = described_class.new(nil, {:source => source, :destination => destination})
guard.start
end
Expand All @@ -75,7 +75,7 @@
describe "#stop" do
context "when the guard is stopped" do
it "should output the following message" do
::Guard::UI.should_receive(:info).with("Guard::RsyncX stopped.")
::Guard::UI.should_receive(:info).with("Guard::RemoteSync stopped.")
guard.stop
end
end
Expand Down
6 changes: 3 additions & 3 deletions spec/spec_helper.rb
@@ -1,8 +1,8 @@
require 'rspec'

require 'guard/rsyncx'
require 'guard/rsyncx/command'
require 'guard/rsyncx/source'
require 'guard/remote-sync'
require 'guard/remote-sync/command'
require 'guard/remote-sync/source'

include RSpec::Matchers

Expand Down

0 comments on commit 6846863

Please sign in to comment.