dotbox 1.0.1 → 1.0.2

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: 1494797e72fbe4c6c0674e381507e7a895cd9ee8
4
+ data.tar.gz: 268e762ea6c0221fe7def07f4ee6198cb2a06fd2
5
+ SHA512:
6
+ metadata.gz: b123b224b89b3a7f0997176dd4d1a953c125769f62875198ac7021b6ee361ef08ec6487ab73ba83010441940922ff364c02294412928c807d28cee11fac2040e
7
+ data.tar.gz: 8d08bcf449d0d712094442ae8e97f44320da1b3e618a4cd1d298b5743809a2cd2f36fd2c0021814c37f749bb19eb1103a89fa7e8165f9eba174b54319269d24b
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 1.9.3
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dotbox (1.0.0)
4
+ dotbox (1.0.2)
5
5
  thor
6
6
 
7
7
  GEM
@@ -24,6 +24,7 @@ GEM
24
24
  gherkin (2.11.6)
25
25
  json (>= 1.7.6)
26
26
  json (1.7.7)
27
+ rake (10.1.0)
27
28
  rspec (2.13.0)
28
29
  rspec-core (~> 2.13.0)
29
30
  rspec-expectations (~> 2.13.0)
@@ -32,7 +33,7 @@ GEM
32
33
  rspec-expectations (2.13.0)
33
34
  diff-lcs (>= 1.1.3, < 2.0)
34
35
  rspec-mocks (2.13.0)
35
- thor (0.17.0)
36
+ thor (0.18.1)
36
37
 
37
38
  PLATFORMS
38
39
  ruby
@@ -40,4 +41,5 @@ PLATFORMS
40
41
  DEPENDENCIES
41
42
  aruba
42
43
  dotbox!
44
+ rake
43
45
  rspec
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Dotbox
2
2
 
3
+ [![Build Status](https://travis-ci.org/yesmeck/dotbox.png?branch=master)](https://travis-ci.org/yesmeck/dotbox)
4
+
3
5
  Backup your dotfiles to dropbox and restore them easily.
4
6
 
5
7
  ## Installation
@@ -38,4 +40,10 @@ $ mv /home/meck/Dropbox/Apps/Dotbox/.zshrc /home/meck.zshrc
38
40
 
39
41
  When you run `dotbox restore` it will link all files in dropbox to their original postions.
40
42
 
43
+ ## Not only dotfiles
44
+
45
+ Acturally, dotbox can take care of any files or directories under your $HOME directory. For example:
46
+ ```
47
+ $ dotbox add .oh-my-fish/custom
48
+ ```
41
49
 
data/Rakefile CHANGED
@@ -1,9 +1,12 @@
1
1
  require "bundler"
2
- require "rspec/core/rake_task"
2
+ require 'cucumber'
3
+ require 'cucumber/rake/task'
3
4
 
4
5
  Bundler::GemHelper.install_tasks
5
6
 
6
- RSpec::Core::RakeTask.new(:spec)
7
+ Cucumber::Rake::Task.new(:features) do |t|
8
+ t.cucumber_opts = "features --format pretty"
9
+ end
7
10
 
8
- task :default => :spec
9
- task :test => :spec
11
+ task :default => :features
12
+ task :test => :features
@@ -15,4 +15,5 @@ Gem::Specification.new do |s|
15
15
  s.add_dependency 'thor'
16
16
  s.add_development_dependency 'aruba'
17
17
  s.add_development_dependency 'rspec'
18
+ s.add_development_dependency 'rake'
18
19
  end
@@ -51,4 +51,10 @@ Feature: add file to dropbox
51
51
  And the link named "foo/baz" should be a link of "dropbox/Apps/Dotbox/foo/baz"
52
52
  And the record file should contain "foo/baz" => "file"
53
53
 
54
+ @announce
55
+ Scenario: add a file twice
56
+ Given a backup file named "foo/bar"
57
+ Given an empty file named "foo/bar"
58
+ When I run `dotbox add foo/bar`
59
+ Then the stdout should contain "foo/bar has been backuped."
54
60
 
@@ -14,3 +14,11 @@ Feature: restore backuped files
14
14
  And a link named "baz/bar" should exist
15
15
  And the link named "baz/bar" should be a link of "dropbox/Apps/Dotbox/baz/bar"
16
16
 
17
+ @announce
18
+ Scenario: restore a exist file
19
+ Given a backup file named "foo/bar"
20
+ Given an empty file named "foo/bar"
21
+ When I run `dotbox restore`
22
+ Then a link named "foo/bar" should exist
23
+ And a file named "foo/bar.bak" should exist
24
+
@@ -2,6 +2,7 @@ require 'dotbox'
2
2
  require 'dotbox/config'
3
3
  require 'dotbox/file'
4
4
  require 'dotbox/record'
5
+ require 'dotbox/version'
5
6
 
6
7
  module Dotbox
7
8
  class CLI < Thor
@@ -21,10 +22,14 @@ module Dotbox
21
22
  die "#{path} not exists."
22
23
  end
23
24
  Dir[path].each do |p|
24
- p = ::File.expand_path(p)
25
- file = File.new(p)
26
- file.backup
27
- @record.add file
25
+ begin
26
+ p = ::File.expand_path(p)
27
+ file = File.new(p)
28
+ file.backup
29
+ @record.add file
30
+ rescue => ex
31
+ die ex.message
32
+ end
28
33
  end
29
34
  end
30
35
  end
@@ -56,6 +61,11 @@ module Dotbox
56
61
  end
57
62
  end
58
63
 
64
+ desc :version, 'Display version number'
65
+ def version
66
+ puts Dotbox::VERSION::STRING
67
+ end
68
+
59
69
  def self.source_root
60
70
  ::File.dirname(::File.expand_path('../../../bin/dotbox', __FILE__))
61
71
  end
@@ -25,22 +25,33 @@ module Dotbox
25
25
  end
26
26
 
27
27
  def backup
28
+ if ::File.exist?(backup_path)
29
+ raise "#{@rel_path} has been backuped."
30
+ end
28
31
  FileUtils.mkdir_p ::File.dirname(backup_path)
29
- FileUtils.mv @abs_path, backup_path
30
- FileUtils.ln_s backup_path, @abs_path
32
+ FileUtils.mv @abs_path, backup_path, verbose: true
33
+ FileUtils.ln_s backup_path, @abs_path, verbose: true
31
34
  end
32
35
 
33
36
  def remove
34
37
  # must get the backup path first
35
38
  backup_path
36
- FileUtils.rm @abs_path
37
- FileUtils.mv backup_path, @abs_path
39
+ FileUtils.rm @abs_path, verbose: true
40
+ FileUtils.mv backup_path, @abs_path, verbose: true
38
41
  rm_empty_dir ::File.dirname(backup_path)
39
42
  end
40
43
 
41
44
  def restore
42
- FileUtils.mkdir_p ::File.dirname(@abs_path)
43
- FileUtils.ln_s backup_path, @abs_path
45
+ if exist?
46
+ if link? && link_of?(backup_path)
47
+ # Dont need restore
48
+ return
49
+ else
50
+ FileUtils.mv @abs_path, "#{@abs_path}.bak", verbose: true
51
+ end
52
+ end
53
+ FileUtils.mkdir_p ::File.dirname(@abs_path), verbose: true
54
+ FileUtils.ln_s backup_path, @abs_path, verbose: true
44
55
  end
45
56
 
46
57
  def backuped?
@@ -59,5 +70,9 @@ module Dotbox
59
70
  @type = directory? ? 'directory' : 'file'
60
71
  end
61
72
 
73
+ def exist?
74
+ ::File.exist?(@abs_path)
75
+ end
76
+
62
77
  end
63
78
  end
@@ -2,7 +2,7 @@ module Dotbox
2
2
  module VERSION
3
3
  MAJOR = 1
4
4
  MINOR = 0
5
- PATCH = 1
5
+ PATCH = 2
6
6
  BUILD = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.');
metadata CHANGED
@@ -1,62 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dotbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
5
- prerelease:
4
+ version: 1.0.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Wei Zhu
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-03-02 00:00:00.000000000 Z
11
+ date: 2013-07-27 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: thor
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: aruba
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rspec
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
60
67
  - !ruby/object:Gem::Version
61
68
  version: '0'
62
69
  description: Backup your dotfiles to dropbox and restore them easily.
@@ -68,6 +75,7 @@ extensions: []
68
75
  extra_rdoc_files: []
69
76
  files:
70
77
  - .gitignore
78
+ - .travis.yml
71
79
  - Gemfile
72
80
  - Gemfile.lock
73
81
  - README.md
@@ -90,27 +98,26 @@ files:
90
98
  - lib/dotbox/version.rb
91
99
  homepage: https://github.com/yesmeck/dotbox
92
100
  licenses: []
101
+ metadata: {}
93
102
  post_install_message:
94
103
  rdoc_options: []
95
104
  require_paths:
96
105
  - lib
97
106
  required_ruby_version: !ruby/object:Gem::Requirement
98
- none: false
99
107
  requirements:
100
- - - ! '>='
108
+ - - '>='
101
109
  - !ruby/object:Gem::Version
102
110
  version: '0'
103
111
  required_rubygems_version: !ruby/object:Gem::Requirement
104
- none: false
105
112
  requirements:
106
- - - ! '>='
113
+ - - '>='
107
114
  - !ruby/object:Gem::Version
108
115
  version: '0'
109
116
  requirements: []
110
117
  rubyforge_project:
111
- rubygems_version: 1.8.25
118
+ rubygems_version: 2.0.3
112
119
  signing_key:
113
- specification_version: 3
120
+ specification_version: 4
114
121
  summary: Backup your dotfiles to dropbox and restore them easily.
115
122
  test_files:
116
123
  - features/add.feature
@@ -119,4 +126,3 @@ test_files:
119
126
  - features/setup.feature
120
127
  - features/step_definitions/file_steps.rb
121
128
  - features/support/env.rb
122
- has_rdoc: