hfam 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +35 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +20 -0
- data/LICENSE +22 -0
- data/README.md +130 -0
- data/Rakefile +2 -0
- data/bin/hfam +11 -0
- data/hfam.gemspec +45 -0
- data/lib/core_ext/fileutils.rb +5 -0
- data/lib/core_ext/string.rb +26 -0
- data/lib/hfam.rb +15 -0
- data/lib/hfam/application.rb +22 -0
- data/lib/hfam/argument_parser.rb +26 -0
- data/lib/hfam/command.rb +2 -0
- data/lib/hfam/command/base.rb +6 -0
- data/lib/hfam/command_set.rb +19 -0
- data/lib/hfam/commands/source.rb +37 -0
- data/lib/hfam/commands/symlink.rb +28 -0
- data/lib/hfam/constants.rb +24 -0
- data/lib/hfam/dsl.rb +29 -0
- data/lib/hfam/logger.rb +20 -0
- data/lib/hfam/payload.rb +24 -0
- data/lib/hfam/version.rb +3 -0
- metadata +100 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3c7927638ebb87bcd2baa0c67a12268473b0ff1f
|
4
|
+
data.tar.gz: ba3b2e762d2544c4e4aa4a6fa8263ee0eed29e8f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 49204cc66e69d1c0f6e39a64f90ff9c3691d96eabe9a2512625449c1671d0c1c08bdf122f4327d682504d7efd8808fe88f277715520f7294860db80ccabb82fe
|
7
|
+
data.tar.gz: 9dd55b586d1e960bf0da63329b25e66fccc2d012066c66bd3023b55cac9734666ec21bf5c7571da375772abe6369f7117d8a82530055bc9dd099572367dcfdc4
|
data/.gitignore
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
|
12
|
+
## Specific to RubyMotion:
|
13
|
+
.dat*
|
14
|
+
.repl_history
|
15
|
+
build/
|
16
|
+
|
17
|
+
## Documentation cache and generated files:
|
18
|
+
/.yardoc/
|
19
|
+
/_yardoc/
|
20
|
+
/doc/
|
21
|
+
/rdoc/
|
22
|
+
|
23
|
+
## Environment normalisation:
|
24
|
+
/.bundle/
|
25
|
+
/vendor/bundle
|
26
|
+
/lib/bundler/man/
|
27
|
+
|
28
|
+
# for a library or gem, you might want to ignore these files since the code is
|
29
|
+
# intended to run in multiple environments; otherwise, check them in:
|
30
|
+
# Gemfile.lock
|
31
|
+
# .ruby-version
|
32
|
+
# .ruby-gemset
|
33
|
+
|
34
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
35
|
+
.rvmrc
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Mehdi FARSI
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
# HFAM
|
2
|
+
|
3
|
+
<b>H</b>idden <b>F</b>iles <b>A</b>re <b>M</b>anageable - Manage, source and reload you dotfiles in a specific directory
|
4
|
+
|
5
|
+
1. You create/clone your `dotfiles` directory defined in `$HOME/`.
|
6
|
+
2. You edit a `$HOME/dotfiles/.hfamconfig` with its intuitive DSL.
|
7
|
+
3. You call `hfam`.
|
8
|
+
|
9
|
+
The main advantage of this tool is that you can easily move your `dotfiles` from a machine to another one. Then, with only one command, you can configure your environment.
|
10
|
+
|
11
|
+
###Prerequisites
|
12
|
+
|
13
|
+
you need to install `ruby`:
|
14
|
+
|
15
|
+
```shell
|
16
|
+
?> \curl -sSL https://get.rvm.io | bash -s stable
|
17
|
+
?> rvm install ruby-head
|
18
|
+
```
|
19
|
+
|
20
|
+
Check if `ruby` is installed:
|
21
|
+
|
22
|
+
```shell
|
23
|
+
?> ruby --version
|
24
|
+
```
|
25
|
+
|
26
|
+
###Install
|
27
|
+
|
28
|
+
```shell
|
29
|
+
?> gem install hfam
|
30
|
+
```
|
31
|
+
|
32
|
+
I recommend you to put all your `dotfiles` in a Git repository named `dotfiles`.
|
33
|
+
|
34
|
+
clone your repo and add a file named `.hfamconfig`.
|
35
|
+
|
36
|
+
###Usage
|
37
|
+
|
38
|
+
Example
|
39
|
+
|
40
|
+
```asciidoc
|
41
|
+
~/
|
42
|
+
|- dotfiles/
|
43
|
+
|- gitconfig
|
44
|
+
|- zshrc
|
45
|
+
|- .hfamconfig
|
46
|
+
```
|
47
|
+
|
48
|
+
|
49
|
+
`hfam` works with a `.hfamconfig` file. This config file provide an intuitive DSL for managing your dotfiles.
|
50
|
+
|
51
|
+
> Only the files defined in `.hfamconfig` will be treated.
|
52
|
+
|
53
|
+
For the following examples, let's say that the following environment variables are set with the following values:
|
54
|
+
|
55
|
+
- `HOME=/Users/zoidberg`
|
56
|
+
- `SHELL=/bin/zsh`
|
57
|
+
|
58
|
+
Now, let's have look to the `.hfamconfig` DSL.
|
59
|
+
|
60
|
+
####Symlink
|
61
|
+
|
62
|
+
The `symlink` command creates a symlink with the source file passed as argument. The symlink target is defined in `$HOME/.target`.
|
63
|
+
|
64
|
+
Example:
|
65
|
+
|
66
|
+
In `$HOME/dotfiles/.hfamconfig`
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
symlink "gitconfig" # you can add a comment using '#'
|
70
|
+
```
|
71
|
+
|
72
|
+
And then
|
73
|
+
|
74
|
+
```shell
|
75
|
+
?> hfam
|
76
|
+
Symlink: ln -s /Users/zoidberg/dotfiles/gitconfig /Users/zoidberg/.gitconfig
|
77
|
+
?> ls -l $HOME/.gitconfig
|
78
|
+
/Users/zoidberg/.gitconfig -> /Users/zoidberg/dotfiles/gitconfig
|
79
|
+
```
|
80
|
+
|
81
|
+
|
82
|
+
> /!\ If the source file is not a dotfile, the prefix `.` is automatically prepended to the target file
|
83
|
+
> ```shell
|
84
|
+
> ?> ls -l $HOME/.gitconfig
|
85
|
+
> lrwxr-xr-x 1 lol cat 27B Nov 11 16:35 .gitconfig -> /Users/zoidberg/dotfiles/gitconfig
|
86
|
+
> ```
|
87
|
+
|
88
|
+
####Source
|
89
|
+
|
90
|
+
The `source` command creates a symlink using the file passed as argument and source the symlink target. The symlink target file is defined at `$HOME/.target`.
|
91
|
+
|
92
|
+
Example:
|
93
|
+
|
94
|
+
In `$HOME/dotfiles/.hfamconfig`
|
95
|
+
|
96
|
+
```ruby
|
97
|
+
source "zshrc"
|
98
|
+
```
|
99
|
+
|
100
|
+
And then
|
101
|
+
|
102
|
+
```shell
|
103
|
+
?> hfam
|
104
|
+
Symlink: ln -s /Users/zoidberg/dotfiles/zshrc /Users/zoidberg/.zshrc
|
105
|
+
Source: /bin/zsh -c 'source /Users/zoidberg/.zshrc'
|
106
|
+
?>
|
107
|
+
```
|
108
|
+
|
109
|
+
|
110
|
+
> /!\ The SHELL env variable is used to defined the current shell.
|
111
|
+
> If the default shell is `dash`, then it uses the '.' command to source the file.
|
112
|
+
> Else, it uses the `source` command.
|
113
|
+
> If the SHELL is a symlink to another shell, then it reach the real shell targeted by the symlink:
|
114
|
+
> [for further information](https://wiki.ubuntu.com/DashAsBinSh#My_production_system_has_broken_and_I_just_want_to_get_it_back_up.21)
|
115
|
+
|
116
|
+
## Development
|
117
|
+
|
118
|
+
After checking out the repo, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
119
|
+
|
120
|
+
## Contributing
|
121
|
+
|
122
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/mehdi-farsi/activerecord-search.
|
123
|
+
|
124
|
+
We have a lot of idea that we put in the issue list. Feel free to have a look to it.
|
125
|
+
|
126
|
+
## License
|
127
|
+
|
128
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
129
|
+
|
130
|
+
> Please, feel free to star the project if you like it ! :)
|
data/Rakefile
ADDED
data/bin/hfam
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# PATH_TO_GEMSET/hfam-VERSION/lib
|
4
|
+
hfam_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
|
5
|
+
|
6
|
+
# add hfam_dir to LOAD_PATH
|
7
|
+
$LOAD_PATH.unshift(hfam_dir) unless $LOAD_PATH.include?(hfam_dir)
|
8
|
+
|
9
|
+
require "hfam"
|
10
|
+
|
11
|
+
HFAM::Application.new.run
|
data/hfam.gemspec
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'hfam'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "hfam"
|
8
|
+
spec.version = HFAM::VERSION
|
9
|
+
spec.authors = ["mehdi_farsi"]
|
10
|
+
spec.date = Time.now.strftime("%F")
|
11
|
+
spec.email = ["mehdifarsi.pro@gmail.com"]
|
12
|
+
|
13
|
+
spec.summary = %q{Hidden Files Are Manageable}
|
14
|
+
spec.description = %q{Manage and reload you dotfiles in a centralized directory}
|
15
|
+
spec.homepage = "https://github.com/mehdi-farsi/hfam"
|
16
|
+
spec.license = "MIT"
|
17
|
+
|
18
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
23
|
+
|
24
|
+
|
25
|
+
spec.required_ruby_version = '>= 1.9.3'
|
26
|
+
spec.post_install_message = <<-EOF
|
27
|
+
Thanks for installing!
|
28
|
+
|
29
|
+
You can follow me on:
|
30
|
+
- Twitter: @farsi_mehdi
|
31
|
+
- Github: mehdi-farsi
|
32
|
+
|
33
|
+
This project permits to help to solve a common problem. My reward is to see you using it.
|
34
|
+
|
35
|
+
So please, feel free to 'star' the project on GitHub:
|
36
|
+
|
37
|
+
https://github.com/mehdi-farsi/activerecord-search
|
38
|
+
|
39
|
+
Many Thanks !
|
40
|
+
EOF
|
41
|
+
|
42
|
+
|
43
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
44
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
45
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class String
|
2
|
+
def black; "\e[30m#{self}\e[0m" end
|
3
|
+
def red; "\e[31m#{self}\e[0m" end
|
4
|
+
def green; "\e[32m#{self}\e[0m" end
|
5
|
+
def brown; "\e[33m#{self}\e[0m" end
|
6
|
+
def orange; "\e[1;33m#{self}\e[0m" end
|
7
|
+
def blue; "\e[34m#{self}\e[0m" end
|
8
|
+
def magenta; "\e[35m#{self}\e[0m" end
|
9
|
+
def cyan; "\e[36m#{self}\e[0m" end
|
10
|
+
def gray; "\e[37m#{self}\e[0m" end
|
11
|
+
|
12
|
+
def bg_black; "\e[40m#{self}\e[0m" end
|
13
|
+
def bg_red; "\e[41m#{self}\e[0m" end
|
14
|
+
def bg_green; "\e[42m#{self}\e[0m" end
|
15
|
+
def bg_brown; "\e[43m#{self}\e[0m" end
|
16
|
+
def bg_blue; "\e[44m#{self}\e[0m" end
|
17
|
+
def bg_magenta; "\e[45m#{self}\e[0m" end
|
18
|
+
def bg_cyan; "\e[46m#{self}\e[0m" end
|
19
|
+
def bg_gray; "\e[47m#{self}\e[0m" end
|
20
|
+
|
21
|
+
def bold; "\e[1m#{self}\e[22m" end
|
22
|
+
def italic; "\e[3m#{self}\e[23m" end
|
23
|
+
def underline; "\e[4m#{self}\e[24m" end
|
24
|
+
def blink; "\e[5m#{self}\e[25m" end
|
25
|
+
def reverse_color; "\e[7m#{self}\e[27m" end
|
26
|
+
end
|
data/lib/hfam.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require "hfam/application.rb"
|
2
|
+
require "hfam/argument_parser.rb"
|
3
|
+
require "hfam/command.rb"
|
4
|
+
require "hfam/command/base.rb"
|
5
|
+
require "hfam/commands/symlink.rb"
|
6
|
+
require "hfam/commands/source.rb"
|
7
|
+
require "hfam/command_set.rb"
|
8
|
+
require "hfam/constants.rb"
|
9
|
+
require "hfam/dsl.rb"
|
10
|
+
require "hfam/logger.rb"
|
11
|
+
require "hfam/payload.rb"
|
12
|
+
require "hfam/version"
|
13
|
+
|
14
|
+
require "core_ext/fileutils.rb"
|
15
|
+
require "core_ext/string.rb"
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module HFAM
|
2
|
+
class Application
|
3
|
+
def initialize
|
4
|
+
@payload = ::HFAM::Payload.new
|
5
|
+
|
6
|
+
@payload.metadata = ArgumentParser.new.parse
|
7
|
+
|
8
|
+
@command_set = CommandSet.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def run
|
12
|
+
if @payload.metadata.include? :help
|
13
|
+
puts @payload.metadata[:help]
|
14
|
+
return
|
15
|
+
end
|
16
|
+
|
17
|
+
dsl = ::HFAM::DSL.new(@payload).tokenize
|
18
|
+
|
19
|
+
@command_set.dispatch_commands(@payload)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require "optparse"
|
2
|
+
|
3
|
+
module HFAM
|
4
|
+
class ArgumentParser
|
5
|
+
def parse
|
6
|
+
options = {}
|
7
|
+
|
8
|
+
o = ::OptionParser.new do |opts|
|
9
|
+
opts.banner = ::HFAM::HELP
|
10
|
+
|
11
|
+
|
12
|
+
opts.on("-h") do |h|
|
13
|
+
options[:help] = ::HFAM::HELP
|
14
|
+
end
|
15
|
+
end
|
16
|
+
begin
|
17
|
+
o.parse!
|
18
|
+
rescue ::OptionParser::InvalidOption => e
|
19
|
+
$stderr.puts e
|
20
|
+
$stderr.puts o.banner
|
21
|
+
exit
|
22
|
+
end
|
23
|
+
options
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/hfam/command.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
module HFAM
|
2
|
+
class CommandSet
|
3
|
+
def initialize
|
4
|
+
@commands = {
|
5
|
+
symlink: ::HFAM::Command::Symlink.new,
|
6
|
+
source: ::HFAM::Command::Source.new
|
7
|
+
}
|
8
|
+
end
|
9
|
+
|
10
|
+
def dispatch_commands(payload)
|
11
|
+
payload.commands.each_with_index do |command, index|
|
12
|
+
::HFAM::Logger.error("hfamconfig:#{index + 1} : unknown command '#{command[1][:command]}' with args #{command[1][:args]}") and next if command[0] == :unknown
|
13
|
+
|
14
|
+
@commands[command[0]].run(command)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require "fileutils"
|
2
|
+
require "pathname"
|
3
|
+
|
4
|
+
module HFAM
|
5
|
+
module Command
|
6
|
+
class Source < Base
|
7
|
+
|
8
|
+
def run(command)
|
9
|
+
src = command[1]
|
10
|
+
|
11
|
+
::HFAM::Logger.error("No such file or directory: #{src}") and return unless File.exist? src
|
12
|
+
|
13
|
+
# preprend the dest file with a '.' if the src file is not a hidden file
|
14
|
+
file = src.split('/').last
|
15
|
+
file = ::FileUtils.hidden_file?(file) ? file : ".#{file}"
|
16
|
+
dest = command[2] || "#{::HFAM::HOME}/#{file}"
|
17
|
+
|
18
|
+
# https://wiki.ubuntu.com/DashAsBinSh#My_production_system_has_broken_and_I_just_want_to_get_it_back_up.21
|
19
|
+
# Sometime the default shell /bin/sh is a symlink to another shell
|
20
|
+
# Pathname#realpath permits to reach the target of a symlink
|
21
|
+
real_shell_path = ::Pathname.new(ENV['SHELL']).realpath.to_s
|
22
|
+
|
23
|
+
# /bin/dash doesn't implement the builtin 'source'. Instead, it uses the '.' command
|
24
|
+
cmd = real_shell_path.split('/').last == "dash" ? '.' : "source"
|
25
|
+
|
26
|
+
(cmd = "#{real_shell_path} -c '#{cmd} #{dest}'") && result = `#{cmd}`
|
27
|
+
|
28
|
+
::HFAM::Logger.success("Source: Command result: #{result}")
|
29
|
+
::HFAM::Logger.success("Source: #{cmd}")
|
30
|
+
|
31
|
+
rescue ::Errno::EACCES => e
|
32
|
+
l::HFAM::Logger.error("Unable to source #{dest} (Permission Denied)")
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require "fileutils"
|
2
|
+
|
3
|
+
module HFAM
|
4
|
+
module Command
|
5
|
+
class Symlink < Base
|
6
|
+
|
7
|
+
def run(command)
|
8
|
+
src = command[1]
|
9
|
+
|
10
|
+
::HFAM::Logger.error("No such file or directory: #{src}") and return unless File.exist? src
|
11
|
+
|
12
|
+
# preprend the dest file with a '.' if the src file is not a hidden file
|
13
|
+
file = src.split('/').last
|
14
|
+
file = ::FileUtils.hidden_file?(file) ? file : ".#{file}"
|
15
|
+
dest = command[2] || "#{::HFAM::HOME}/#{file}"
|
16
|
+
|
17
|
+
# ln -s with --force option
|
18
|
+
::FileUtils.ln_sf(src, dest)
|
19
|
+
|
20
|
+
::HFAM::Logger.success("Symlink: ln -s #{src} #{dest}")
|
21
|
+
|
22
|
+
rescue ::Errno::EACCES => e
|
23
|
+
l::HFAM::Logger.error("Unable to generate symlink #{src} #{dest} (Permission Denied)")
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module HFAM
|
2
|
+
HOME = "#{ENV['HOME']}"
|
3
|
+
DEFAULT_DOTFILE_PATH = "#{ENV['HOME']}/dotfiles"
|
4
|
+
HFAMCONFIG_PATH = "#{DEFAULT_DOTFILE_PATH}/.hfamconfig"
|
5
|
+
|
6
|
+
HELP = <<-SHELL
|
7
|
+
HFAM - Hidden Files Are Manageable
|
8
|
+
|
9
|
+
Centralize your dotfiles in one directory and manage them using some basic operations (symlink, source, ...)
|
10
|
+
This tool attempts to locate a ~/dotfiles/.hfamconfig file. Then it executes a set of commands
|
11
|
+
listed in the config file.
|
12
|
+
|
13
|
+
For further information: https://github.com/mehdi-farsi/hfam
|
14
|
+
|
15
|
+
USAGE:
|
16
|
+
|
17
|
+
hfam [-h]
|
18
|
+
|
19
|
+
OPTIONS:
|
20
|
+
|
21
|
+
-h # help
|
22
|
+
|
23
|
+
SHELL
|
24
|
+
end
|
data/lib/hfam/dsl.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
module HFAM
|
2
|
+
# Should respond to method :tokenize and :route
|
3
|
+
class DSL
|
4
|
+
def initialize(payload)
|
5
|
+
@payload = payload
|
6
|
+
end
|
7
|
+
|
8
|
+
def tokenize
|
9
|
+
raw_commands = eval(::File.open(::HFAM::HFAMCONFIG_PATH).read)
|
10
|
+
end
|
11
|
+
|
12
|
+
def symlink(file)
|
13
|
+
@payload.commands << [:symlink, "#{DEFAULT_DOTFILE_PATH}/#{file}"]
|
14
|
+
end
|
15
|
+
|
16
|
+
def source(file)
|
17
|
+
symlink(file)
|
18
|
+
@payload.commands << [:source, "#{DEFAULT_DOTFILE_PATH}/#{file}"]
|
19
|
+
end
|
20
|
+
|
21
|
+
def route
|
22
|
+
@command_set.run_command
|
23
|
+
end
|
24
|
+
|
25
|
+
def method_missing(method, *args, &block)
|
26
|
+
@payload.commands << [:unknown, { command: method, args: args }]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/hfam/logger.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
module HFAM
|
2
|
+
module Logger
|
3
|
+
class << self
|
4
|
+
def success(message)
|
5
|
+
puts message.green
|
6
|
+
true
|
7
|
+
end
|
8
|
+
|
9
|
+
def warn(message)
|
10
|
+
puts message.orange
|
11
|
+
true
|
12
|
+
end
|
13
|
+
|
14
|
+
def error(message)
|
15
|
+
$stderr.puts message.red
|
16
|
+
true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/hfam/payload.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
module HFAM
|
2
|
+
class Payload < Hash
|
3
|
+
|
4
|
+
def initialize
|
5
|
+
super
|
6
|
+
|
7
|
+
self[:metadata] = Hash.new
|
8
|
+
self[:commands] = Array.new { |value| [:unknown, value] }
|
9
|
+
end
|
10
|
+
|
11
|
+
def metadata
|
12
|
+
self[:metadata]
|
13
|
+
end
|
14
|
+
|
15
|
+
def metadata=(h)
|
16
|
+
self[:metadata] = h.dup
|
17
|
+
end
|
18
|
+
|
19
|
+
def commands
|
20
|
+
self[:commands]
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
data/lib/hfam/version.rb
ADDED
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hfam
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- mehdi_farsi
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-11-13 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.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: Manage and reload you dotfiles in a centralized directory
|
42
|
+
email:
|
43
|
+
- mehdifarsi.pro@gmail.com
|
44
|
+
executables:
|
45
|
+
- hfam
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ".gitignore"
|
50
|
+
- Gemfile
|
51
|
+
- Gemfile.lock
|
52
|
+
- LICENSE
|
53
|
+
- README.md
|
54
|
+
- Rakefile
|
55
|
+
- bin/hfam
|
56
|
+
- hfam.gemspec
|
57
|
+
- lib/core_ext/fileutils.rb
|
58
|
+
- lib/core_ext/string.rb
|
59
|
+
- lib/hfam.rb
|
60
|
+
- lib/hfam/application.rb
|
61
|
+
- lib/hfam/argument_parser.rb
|
62
|
+
- lib/hfam/command.rb
|
63
|
+
- lib/hfam/command/base.rb
|
64
|
+
- lib/hfam/command_set.rb
|
65
|
+
- lib/hfam/commands/source.rb
|
66
|
+
- lib/hfam/commands/symlink.rb
|
67
|
+
- lib/hfam/constants.rb
|
68
|
+
- lib/hfam/dsl.rb
|
69
|
+
- lib/hfam/logger.rb
|
70
|
+
- lib/hfam/payload.rb
|
71
|
+
- lib/hfam/version.rb
|
72
|
+
homepage: https://github.com/mehdi-farsi/hfam
|
73
|
+
licenses:
|
74
|
+
- MIT
|
75
|
+
metadata: {}
|
76
|
+
post_install_message: " Thanks for installing!\n \n You can follow me on:\n -
|
77
|
+
Twitter: @farsi_mehdi\n - Github: mehdi-farsi\n \n This project permits to
|
78
|
+
help to solve a common problem. My reward is to see you using it.\n \n So please,
|
79
|
+
feel free to 'star' the project on GitHub:\n \n https://github.com/mehdi-farsi/activerecord-search\n
|
80
|
+
\ \n Many Thanks !\n"
|
81
|
+
rdoc_options: []
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 1.9.3
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
requirements: []
|
95
|
+
rubyforge_project:
|
96
|
+
rubygems_version: 2.4.8
|
97
|
+
signing_key:
|
98
|
+
specification_version: 4
|
99
|
+
summary: Hidden Files Are Manageable
|
100
|
+
test_files: []
|