dotify 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -16,15 +16,7 @@ As this is a gem for use on your local system, I understand there are still many
16
16
 
17
17
  ## Installation
18
18
 
19
- Add this line to your application's Gemfile:
20
-
21
- gem 'dotify'
22
-
23
- And then execute:
24
-
25
- $ bundle
26
-
27
- Or install it yourself as:
19
+ It is highly recommended that you just install this gem manually since it is only managing files on your local system:Add this line to your application's Gemfile:
28
20
 
29
21
  $ gem install dotify
30
22
 
data/lib/dotify/cli.rb CHANGED
@@ -27,6 +27,31 @@ module Dotify
27
27
  File.expand_path("../../../templates", __FILE__)
28
28
  end
29
29
 
30
+ desc :save, "Commit Dotify files and push to Github"
31
+ method_option :message, :aliases => '-m', :type => :string, :required => false, :desc => "Git commit message to send to Github"
32
+ def save
33
+ Dir.chdir(Config.path) do
34
+ system 'git fetch'
35
+ uncommitted = `git status`.chomp.to_i != 2
36
+ if uncommitted
37
+ message = !options[:message].nil? ? options[:message] : ask("Commit message:", :blue)
38
+ system 'git add .'
39
+ system "git commit -m '#{message.gsub(/[']/, '\\\\\'')}'"
40
+ end
41
+ if `git log origin/master.. --oneline | wc -l`.chomp.to_i != 0
42
+ say 'Pushing up to Github...', :blue
43
+ system 'git push origin master'
44
+ end
45
+ end
46
+ end
47
+
48
+ desc :edit, "Edit a dotify file"
49
+ method_option :save, :aliases => '-s', :default => false, :type => :boolean, :require => true, :desc => "Save Dotify files and push to Github"
50
+ def edit(filename)
51
+ system "#{Config.editor} #{Files.dotify(filename)}"
52
+ save if options[:save] == true
53
+ end
54
+
30
55
  desc :version, "Check your Dotify version"
31
56
  def version
32
57
  if VersionChecker.out_of_date?
data/lib/dotify/config.rb CHANGED
@@ -22,6 +22,10 @@ module Dotify
22
22
  File.join(home, dirname)
23
23
  end
24
24
 
25
+ def editor
26
+ config.fetch(:editor, 'vi')
27
+ end
28
+
25
29
  def load_config!
26
30
  config = File.exists?(config_file) ? (YAML.load_file(config_file) || {}) : {}
27
31
  symbolize_keys!(config)
@@ -1,3 +1,3 @@
1
1
  module Dotify
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -14,12 +14,26 @@ describe Dotify::Config do
14
14
  end
15
15
  end
16
16
  describe "options" do
17
+ before do
18
+ Dotify::Config.stub(:config) do
19
+ { :ignore => { :dotfiles => %w[.gemrc], :dotify => %w[.gitmodule] } }
20
+ end
21
+ end
17
22
  it "should be able to show the home path" do
18
23
  Dotify::Config.home.should == Thor::Util.user_home
19
24
  end
20
25
  it "should be able to show the dotify path" do
21
26
  Dotify::Config.path.should == File.join(Dotify::Config.home, '.dotify')
22
27
  end
28
+ it "should set a default editor" do
29
+ Dotify::Config.editor.should == 'vi'
30
+ end
31
+ it "should allow a custom editor" do
32
+ Dotify::Config.stub(:config) do
33
+ { :editor => 'subl' }
34
+ end
35
+ Dotify::Config.editor.should == 'subl'
36
+ end
23
37
  end
24
38
  describe "ignore files" do
25
39
  before do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dotify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-28 00:00:00.000000000 Z
12
+ date: 2012-07-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor