hfam 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3c7927638ebb87bcd2baa0c67a12268473b0ff1f
4
- data.tar.gz: ba3b2e762d2544c4e4aa4a6fa8263ee0eed29e8f
3
+ metadata.gz: f8ffbaf7379c27828847ba8cedc0aa708ec97dc4
4
+ data.tar.gz: c37cb86a42234f1332c31f78bcf035f7eefe23aa
5
5
  SHA512:
6
- metadata.gz: 49204cc66e69d1c0f6e39a64f90ff9c3691d96eabe9a2512625449c1671d0c1c08bdf122f4327d682504d7efd8808fe88f277715520f7294860db80ccabb82fe
7
- data.tar.gz: 9dd55b586d1e960bf0da63329b25e66fccc2d012066c66bd3023b55cac9734666ec21bf5c7571da375772abe6369f7117d8a82530055bc9dd099572367dcfdc4
6
+ metadata.gz: 714122a472c5cdcdbfeeb60982e9ee2751b66f08439569b2f1e24240e1199658a6573a8ed2d7d15d42b3bc3dbac370011243ffcfd8e8fa519f5385eabd09debb
7
+ data.tar.gz: 9d1bd61f378c7040dbdf4680d05514d423a473e70801c386d46d1c8c0fbee16bd8f4691d188c87b29de4c9907da057fdf151fb0caaa9d6c3e082fd3442742511
data/README.md CHANGED
@@ -69,7 +69,7 @@ In `$HOME/dotfiles/.hfamconfig`
69
69
  symlink "gitconfig" # you can add a comment using '#'
70
70
  ```
71
71
 
72
- And then
72
+ Then
73
73
 
74
74
  ```shell
75
75
  ?> hfam
@@ -78,6 +78,20 @@ Symlink: ln -s /Users/zoidberg/dotfiles/gitconfig /Users/zoidberg/.gitconfig
78
78
  /Users/zoidberg/.gitconfig -> /Users/zoidberg/dotfiles/gitconfig
79
79
  ```
80
80
 
81
+ The `symlink` command accepts another argument to specify the destination's directory of the symlink. This arguments is named `dest`.
82
+
83
+ Example:
84
+
85
+ ```ruby
86
+ symlink "gitignore", dest: "/Users/zoidberg/apps/my_app/.gitignore"
87
+ ```
88
+
89
+ Then
90
+
91
+ ```shell
92
+ ?> hfam
93
+ Symlink: ln -s /Users/mehdi/dotfiles/gitignore /Users/zoidberg/apps/my_app/.gitignore
94
+ ```
81
95
 
82
96
  > /!\ If the source file is not a dotfile, the prefix `.` is automatically prepended to the target file
83
97
  > ```shell
@@ -97,7 +111,7 @@ In `$HOME/dotfiles/.hfamconfig`
97
111
  source "zshrc"
98
112
  ```
99
113
 
100
- And then
114
+ Then
101
115
 
102
116
  ```shell
103
117
  ?> hfam
@@ -13,7 +13,7 @@ module HFAM
13
13
  # preprend the dest file with a '.' if the src file is not a hidden file
14
14
  file = src.split('/').last
15
15
  file = ::FileUtils.hidden_file?(file) ? file : ".#{file}"
16
- dest = command[2] || "#{::HFAM::HOME}/#{file}"
16
+ dest = "#{command[2]}/#{file}"
17
17
 
18
18
  # https://wiki.ubuntu.com/DashAsBinSh#My_production_system_has_broken_and_I_just_want_to_get_it_back_up.21
19
19
  # Sometime the default shell /bin/sh is a symlink to another shell
@@ -25,7 +25,7 @@ module HFAM
25
25
 
26
26
  (cmd = "#{real_shell_path} -c '#{cmd} #{dest}'") && result = `#{cmd}`
27
27
 
28
- ::HFAM::Logger.success("Source: Command result: #{result}")
28
+ ::HFAM::Logger.success(result)
29
29
  ::HFAM::Logger.success("Source: #{cmd}")
30
30
 
31
31
  rescue ::Errno::EACCES => e
@@ -12,7 +12,7 @@ module HFAM
12
12
  # preprend the dest file with a '.' if the src file is not a hidden file
13
13
  file = src.split('/').last
14
14
  file = ::FileUtils.hidden_file?(file) ? file : ".#{file}"
15
- dest = command[2] || "#{::HFAM::HOME}/#{file}"
15
+ dest = "#{command[2]}/#{file}"
16
16
 
17
17
  # ln -s with --force option
18
18
  ::FileUtils.ln_sf(src, dest)
@@ -9,13 +9,13 @@ module HFAM
9
9
  raw_commands = eval(::File.open(::HFAM::HFAMCONFIG_PATH).read)
10
10
  end
11
11
 
12
- def symlink(file)
13
- @payload.commands << [:symlink, "#{DEFAULT_DOTFILE_PATH}/#{file}"]
12
+ def symlink(file, options = {})
13
+ @payload.commands << [:symlink, "#{DEFAULT_DOTFILE_PATH}/#{file}", dest_path(file, options)]
14
14
  end
15
15
 
16
- def source(file)
16
+ def source(file, options = {})
17
17
  symlink(file)
18
- @payload.commands << [:source, "#{DEFAULT_DOTFILE_PATH}/#{file}"]
18
+ @payload.commands << [:source, "#{DEFAULT_DOTFILE_PATH}/#{file}", dest_path(file, options)]
19
19
  end
20
20
 
21
21
  def route
@@ -25,5 +25,9 @@ module HFAM
25
25
  def method_missing(method, *args, &block)
26
26
  @payload.commands << [:unknown, { command: method, args: args }]
27
27
  end
28
+
29
+ def dest_path(file, options = {})
30
+ options.include?(:dest) ? options[:dest] : ::HFAM::HOME
31
+ end
28
32
  end
29
33
  end
@@ -1,3 +1,3 @@
1
1
  module HFAM
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hfam
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - mehdi_farsi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-13 00:00:00.000000000 Z
11
+ date: 2015-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler