ruby-unison 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6919aa01e1a40fe744780a86118d97aca7cd177f
4
+ data.tar.gz: 794fce879dfa209194e655623c32b254d7dc9d1a
5
+ SHA512:
6
+ metadata.gz: 7185b9f64e76d0f550168bee867c6ed7660187309289526b8dc80c38a54ce3570f06a9ff3fbaab3a00ec95a62bf3c54638da468306bfcccaff9b28de210ffd20
7
+ data.tar.gz: 9c915753d486d98d23be6784ce806de556ea92c0487c1cb30ffb232e4d288ad26e435bbcb34a7cabea33e3eabbfd7bc85ba94c6b60d05f39e624b81ff639c2b0
@@ -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/Gemfile CHANGED
@@ -1,14 +1,4 @@
1
- source "http://rubygems.org"
2
- # Add dependencies required to use your gem here.
3
- # Example:
4
- # gem "activesupport", ">= 2.3.5"
1
+ source 'https://rubygems.org'
5
2
 
6
- # Add dependencies to develop your gem here.
7
- # Include everything needed to run rake, tests, features, etc.
8
- group :development do
9
- gem "rspec", ">= 2.5.0"
10
- gem "yard", ">= 0.6.0"
11
- gem "bundler", ">= 1.0.0"
12
- gem "jeweler", ">= 1.6.0"
13
- gem "rcov", ">= 0"
14
- end
3
+ # Specify your gem's dependencies in ruby-unison.gemspec
4
+ gemspec
data/README.md CHANGED
@@ -5,9 +5,19 @@ ruby-unison defines UnisonCommand class to execute unison in unison.rb.
5
5
 
6
6
  ## Installation
7
7
 
8
- gem install ruby-unison
8
+ Add this line to your application's Gemfile:
9
9
 
10
- ## Examples
10
+ gem 'ruby-unison'
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install ruby-unison
19
+
20
+ ## Examples of usage
11
21
 
12
22
  ### Basic usage
13
23
 
@@ -46,8 +56,3 @@ ruby-unison defines UnisonCommand class to execute unison in unison.rb.
46
56
  - Commit and push until you are happy with your contribution
47
57
  - Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
48
58
  - Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
49
-
50
- ## Copyright
51
-
52
- Copyright (c) 2011 Takayuki YAMAGUCHI. See LICENSE.txt for
53
- further details.
data/Rakefile CHANGED
@@ -1,42 +1 @@
1
- # encoding: utf-8
2
-
3
- require 'rubygems'
4
- require 'bundler'
5
- begin
6
- Bundler.setup(:default, :development)
7
- rescue Bundler::BundlerError => e
8
- $stderr.puts e.message
9
- $stderr.puts "Run `bundle install` to install missing gems"
10
- exit e.status_code
11
- end
12
- require 'rake'
13
-
14
- require 'jeweler'
15
- Jeweler::Tasks.new do |gem|
16
- # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
- gem.name = "ruby-unison"
18
- gem.homepage = "http://github.com/ytaka/ruby-unison"
19
- gem.license = "GPLv3"
20
- gem.summary = "ruby-unison"
21
- gem.description = "Ruby interface of the command of file synchronizer unison"
22
- gem.email = "d@ytak.info"
23
- gem.authors = ["Takayuki YAMAGUCHI"]
24
- # dependencies defined in Gemfile
25
- end
26
- Jeweler::RubygemsDotOrgTasks.new
27
-
28
- require 'rspec/core'
29
- require 'rspec/core/rake_task'
30
- RSpec::Core::RakeTask.new(:spec) do |spec|
31
- spec.pattern = FileList['spec/**/*_spec.rb']
32
- end
33
-
34
- RSpec::Core::RakeTask.new(:rcov) do |spec|
35
- spec.pattern = 'spec/**/*_spec.rb'
36
- spec.rcov = true
37
- end
38
-
39
- task :default => :spec
40
-
41
- require 'yard'
42
- YARD::Rake::YardocTask.new
1
+ require "bundler/gem_tasks"
@@ -51,6 +51,8 @@ class UnisonCommand
51
51
  :retry => :number,
52
52
  :root => :array,
53
53
  :rootalias => :array,
54
+ :rshargs => :string,
55
+ :rshcmd => :string,
54
56
  :rsrc => ['true', 'false', 'default'],
55
57
  :rsync => :bool,
56
58
  :selftest => :bool,
@@ -80,6 +82,7 @@ class UnisonCommand
80
82
  end
81
83
 
82
84
  attr_accessor :profile, :root1, :root2, :option, :command
85
+ attr_reader :status
83
86
 
84
87
  # +args+ accepts the following three pattern:
85
88
  # - root1, root2, opts = \{\}
@@ -115,6 +118,7 @@ class UnisonCommand
115
118
  raise ArgumentError, "Invalid"
116
119
  end
117
120
  @command = UNISON_DEFAULT_COMMAND
121
+ @status = nil
118
122
  end
119
123
 
120
124
  def get_command
@@ -161,6 +165,22 @@ class UnisonCommand
161
165
  end
162
166
  private :get_command
163
167
 
168
+ def get_execute_result
169
+ $?
170
+ end
171
+ private :get_execute_result
172
+
173
+ def get_exit_status
174
+ @status = get_execute_result
175
+
176
+ if @status.respond_to?(:exitstatus)
177
+ @status.exitstatus
178
+ else
179
+ @status
180
+ end
181
+ end
182
+ private :get_exit_status
183
+
164
184
  # The method returns :success when all files are synchronized,
165
185
  # :skipped when some files are skipped,
166
186
  # :non_fatal_error when non fatal error occurs, and
@@ -170,11 +190,12 @@ class UnisonCommand
170
190
  def execute(dry_run = false)
171
191
  cmd = get_command
172
192
  if dry_run
193
+ @status = nil
173
194
  return cmd
174
195
  end
175
196
  # Search exit code of unison command.
176
197
  Kernel.system(*cmd)
177
- case $?
198
+ case get_exit_status
178
199
  when 0
179
200
  :success
180
201
  when 1
@@ -184,7 +205,11 @@ class UnisonCommand
184
205
  when 3
185
206
  :fatal_error
186
207
  else
187
- raise StandardError, "Invalid exit code of unison."
208
+ raise StandardError, "Invalid exit code of unison: #{status.inspect.strip}."
188
209
  end
189
210
  end
211
+
212
+ def version
213
+ `#{@command} -version`.split[2]
214
+ end
190
215
  end
@@ -0,0 +1,3 @@
1
+ class UnisonCommand
2
+ VERSION = "0.0.3"
3
+ end
@@ -1,63 +1,25 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'unison/version'
5
5
 
6
- Gem::Specification.new do |s|
7
- s.name = %q{ruby-unison}
8
- s.version = "0.0.1"
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ruby-unison"
8
+ spec.version = UnisonCommand::VERSION
9
+ spec.authors = ["Takayuki YAMAGUCHI"]
10
+ spec.email = ["d@ytak.info"]
11
+ spec.description = "Ruby interface of the command 'unison'"
12
+ spec.summary = "Ruby interface of the command of file synchronizer unison (http://www.cis.upenn.edu/~bcpierce/unison/). ruby-unison defines UnisonCommand class to execute unison in ruby script."
13
+ spec.homepage = "https://github.com/ytaka/ruby-unison"
14
+ spec.license = "GPLv3"
9
15
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Takayuki YAMAGUCHI"]
12
- s.date = %q{2011-05-12}
13
- s.description = %q{Ruby interface of the command of file synchronizer unison}
14
- s.email = %q{d@ytak.info}
15
- s.extra_rdoc_files = [
16
- "LICENSE.txt",
17
- "README.md"
18
- ]
19
- s.files = [
20
- ".document",
21
- ".rspec",
22
- "Gemfile",
23
- "Gemfile.lock",
24
- "LICENSE.txt",
25
- "README.md",
26
- "Rakefile",
27
- "VERSION",
28
- "lib/unison.rb",
29
- "ruby-unison.gemspec",
30
- "spec/spec_helper.rb",
31
- "spec/unison_spec.rb"
32
- ]
33
- s.homepage = %q{http://github.com/ytaka/ruby-unison}
34
- s.licenses = ["GPLv3"]
35
- s.require_paths = ["lib"]
36
- s.rubygems_version = %q{1.6.2}
37
- s.summary = %q{ruby-unison}
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
38
20
 
39
- if s.respond_to? :specification_version then
40
- s.specification_version = 3
41
-
42
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
43
- s.add_development_dependency(%q<rspec>, [">= 2.5.0"])
44
- s.add_development_dependency(%q<yard>, [">= 0.6.0"])
45
- s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
46
- s.add_development_dependency(%q<jeweler>, [">= 1.6.0"])
47
- s.add_development_dependency(%q<rcov>, [">= 0"])
48
- else
49
- s.add_dependency(%q<rspec>, [">= 2.5.0"])
50
- s.add_dependency(%q<yard>, [">= 0.6.0"])
51
- s.add_dependency(%q<bundler>, [">= 1.0.0"])
52
- s.add_dependency(%q<jeweler>, [">= 1.6.0"])
53
- s.add_dependency(%q<rcov>, [">= 0"])
54
- end
55
- else
56
- s.add_dependency(%q<rspec>, [">= 2.5.0"])
57
- s.add_dependency(%q<yard>, [">= 0.6.0"])
58
- s.add_dependency(%q<bundler>, [">= 1.0.0"])
59
- s.add_dependency(%q<jeweler>, [">= 1.6.0"])
60
- s.add_dependency(%q<rcov>, [">= 0"])
61
- end
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec"
24
+ spec.add_development_dependency "yard"
62
25
  end
63
-
@@ -6,15 +6,6 @@ describe UnisonCommand do
6
6
  uc.execute(true).should == ["unison", "pref", "root1", "root2"]
7
7
  end
8
8
 
9
- it "should execute unison command" do
10
- Kernel.should_receive(:system).with("unison", "pref", "root1", "root2")
11
- uc = UnisonCommand.new("pref", "root1", "root2")
12
- # Because exit code is invalid, an error occurs.
13
- lambda do
14
- uc.execute
15
- end.should raise_error
16
- end
17
-
18
9
  it "should return unison command with a boolean option" do
19
10
  uc = UnisonCommand.new("pref", "root1", "root2", :auto => true)
20
11
  uc.execute(true).should == ["unison", "pref", "root1", "root2", "-auto"]
@@ -82,4 +73,71 @@ describe UnisonCommand do
82
73
  uc.command = "/usr/local/bin/unison"
83
74
  uc.execute(true).should == ["/usr/local/bin/unison", "root1", "root2"]
84
75
  end
76
+
77
+ it "should return :success for run with exit code of 0" do
78
+ Kernel.should_receive(:system).with("unison", "root1", "root2")
79
+ uc = UnisonCommand.new("root1", "root2")
80
+ uc.stub(:get_exit_status).and_return(0)
81
+ uc.execute.should == :success
82
+ end
83
+
84
+ it "should return :skipped for a run with exit code of 1" do
85
+ Kernel.should_receive(:system).with("unison", "root1", "root2")
86
+ uc = UnisonCommand.new("root1", "root2")
87
+ uc.stub(:get_exit_status).and_return(1)
88
+ uc.execute.should == :skipped
89
+ end
90
+
91
+ it "should return :non_fatal_error for a run with exit code of 2" do
92
+ Kernel.should_receive(:system).with("unison", "root1", "root2")
93
+ uc = UnisonCommand.new("root1", "root2")
94
+ uc.stub(:get_exit_status).and_return(2)
95
+ uc.execute.should == :non_fatal_error
96
+ end
97
+
98
+ it "should return :fatal_error for a run with exit code of 3" do
99
+ Kernel.should_receive(:system).with("unison", "root1", "root2")
100
+ uc = UnisonCommand.new("root1", "root2")
101
+ uc.stub(:get_exit_status).and_return(3)
102
+ uc.execute.should == :fatal_error
103
+ end
104
+
105
+ it "should return raise exception when an unknown exit code is returned" do
106
+ Kernel.should_receive(:system).with("unison", "root1", "root2")
107
+ uc = UnisonCommand.new("root1", "root2")
108
+ uc.stub(:get_exit_status).and_return(4)
109
+ lambda do
110
+ uc.execute
111
+ end.should raise_error
112
+ end
113
+
114
+ it "should handle Process::Status for $?" do
115
+ Kernel.should_receive(:system).with("unison", "root1", "root2")
116
+ uc = UnisonCommand.new("root1", "root2")
117
+ mock = Object.new
118
+ mock.stub(:exitstatus).and_return(0)
119
+ uc.stub(:get_execute_result).and_return(mock)
120
+ uc.execute.should == :success
121
+ end
122
+
123
+ it "should return status of last execution" do
124
+ Kernel.should_receive(:system).with("unison", "root1", "root2")
125
+ uc = UnisonCommand.new("root1", "root2")
126
+ mock = Object.new
127
+ mock.stub(:exitstatus).and_return(0)
128
+ uc.stub(:get_execute_result).and_return(mock)
129
+ uc.execute
130
+ uc.status.should == mock
131
+ end
132
+
133
+ it "should return nil as status of last execution" do
134
+ uc = UnisonCommand.new("root1", "root2")
135
+ uc.execute(true)
136
+ uc.status.should be_nil
137
+ end
138
+
139
+ it "should return version of unison" do
140
+ uc = UnisonCommand.new("root1", "root2")
141
+ uc.version.should match(/^[0-9.]+$/)
142
+ end
85
143
  end
metadata CHANGED
@@ -1,125 +1,116 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: ruby-unison
3
- version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.0.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
6
5
  platform: ruby
7
- authors:
6
+ authors:
8
7
  - Takayuki YAMAGUCHI
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
-
13
- date: 2011-05-12 00:00:00 +09:00
14
- default_executable:
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
17
- name: rspec
18
- requirement: &id001 !ruby/object:Gem::Requirement
19
- none: false
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: 2.5.0
24
- type: :development
25
- prerelease: false
26
- version_requirements: *id001
27
- - !ruby/object:Gem::Dependency
28
- name: yard
29
- requirement: &id002 !ruby/object:Gem::Requirement
30
- none: false
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: 0.6.0
11
+ date: 2013-07-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
35
20
  type: :development
36
21
  prerelease: false
37
- version_requirements: *id002
38
- - !ruby/object:Gem::Dependency
39
- name: bundler
40
- requirement: &id003 !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- version: 1.0.0
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
46
34
  type: :development
47
35
  prerelease: false
48
- version_requirements: *id003
49
- - !ruby/object:Gem::Dependency
50
- name: jeweler
51
- requirement: &id004 !ruby/object:Gem::Requirement
52
- none: false
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- version: 1.6.0
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
57
48
  type: :development
58
49
  prerelease: false
59
- version_requirements: *id004
60
- - !ruby/object:Gem::Dependency
61
- name: rcov
62
- requirement: &id005 !ruby/object:Gem::Requirement
63
- none: false
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- version: "0"
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: yard
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
68
62
  type: :development
69
63
  prerelease: false
70
- version_requirements: *id005
71
- description: Ruby interface of the command of file synchronizer unison
72
- email: d@ytak.info
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Ruby interface of the command 'unison'
70
+ email:
71
+ - d@ytak.info
73
72
  executables: []
74
-
75
73
  extensions: []
76
-
77
- extra_rdoc_files:
78
- - LICENSE.txt
79
- - README.md
80
- files:
74
+ extra_rdoc_files: []
75
+ files:
81
76
  - .document
77
+ - .gitignore
82
78
  - .rspec
83
79
  - Gemfile
84
- - Gemfile.lock
85
80
  - LICENSE.txt
86
81
  - README.md
87
82
  - Rakefile
88
- - VERSION
89
83
  - lib/unison.rb
84
+ - lib/unison/version.rb
90
85
  - ruby-unison.gemspec
91
86
  - spec/spec_helper.rb
92
87
  - spec/unison_spec.rb
93
- has_rdoc: true
94
- homepage: http://github.com/ytaka/ruby-unison
95
- licenses:
88
+ homepage: https://github.com/ytaka/ruby-unison
89
+ licenses:
96
90
  - GPLv3
91
+ metadata: {}
97
92
  post_install_message:
98
93
  rdoc_options: []
99
-
100
- require_paths:
94
+ require_paths:
101
95
  - lib
102
- required_ruby_version: !ruby/object:Gem::Requirement
103
- none: false
104
- requirements:
105
- - - ">="
106
- - !ruby/object:Gem::Version
107
- hash: -3840236895340394348
108
- segments:
109
- - 0
110
- version: "0"
111
- required_rubygems_version: !ruby/object:Gem::Requirement
112
- none: false
113
- requirements:
114
- - - ">="
115
- - !ruby/object:Gem::Version
116
- version: "0"
96
+ required_ruby_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - '>='
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - '>='
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
117
106
  requirements: []
118
-
119
107
  rubyforge_project:
120
- rubygems_version: 1.6.2
108
+ rubygems_version: 2.0.3
121
109
  signing_key:
122
- specification_version: 3
123
- summary: ruby-unison
124
- test_files: []
125
-
110
+ specification_version: 4
111
+ summary: Ruby interface of the command of file synchronizer unison (http://www.cis.upenn.edu/~bcpierce/unison/).
112
+ ruby-unison defines UnisonCommand class to execute unison in ruby script.
113
+ test_files:
114
+ - spec/spec_helper.rb
115
+ - spec/unison_spec.rb
116
+ has_rdoc:
@@ -1,30 +0,0 @@
1
- GEM
2
- remote: http://rubygems.org/
3
- specs:
4
- diff-lcs (1.1.2)
5
- git (1.2.5)
6
- jeweler (1.6.0)
7
- bundler (~> 1.0.0)
8
- git (>= 1.2.5)
9
- rake
10
- rake (0.8.7)
11
- rcov (0.9.9)
12
- rspec (2.5.0)
13
- rspec-core (~> 2.5.0)
14
- rspec-expectations (~> 2.5.0)
15
- rspec-mocks (~> 2.5.0)
16
- rspec-core (2.5.2)
17
- rspec-expectations (2.5.0)
18
- diff-lcs (~> 1.1.2)
19
- rspec-mocks (2.5.0)
20
- yard (0.6.8)
21
-
22
- PLATFORMS
23
- ruby
24
-
25
- DEPENDENCIES
26
- bundler (>= 1.0.0)
27
- jeweler (>= 1.6.0)
28
- rcov
29
- rspec (>= 2.5.0)
30
- yard (>= 0.6.0)
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.0.1