peridot 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +3 -0
- data/LICENSE +13 -0
- data/README.md +105 -0
- data/Rakefile +2 -0
- data/lib/peridot/attribute_storage.rb +19 -0
- data/lib/peridot/file_access.rb +39 -0
- data/lib/peridot/forwardable.rb +9 -0
- data/lib/peridot/ignores.rb +13 -0
- data/lib/peridot/tasks.rake +9 -0
- data/lib/peridot/version.rb +3 -0
- data/lib/peridot/watcher.rb +26 -0
- data/lib/peridot.rb +23 -0
- data/peridot.gemspec +17 -0
- metadata +86 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 965e2a6b1fe6c30be1856eb4c8525175844444b7
|
4
|
+
data.tar.gz: e740a77f8f4c965f43d7640804370d4bd72bf42a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ac7bb43c4b127dee95eb01fb394c11fb067ac2e0f92053a81d3a46bf51740d282f6a79ba8e32818da7b1c78f9bf916bc912135d9e3731692f00b79b7f979eb50
|
7
|
+
data.tar.gz: e6a6181016bea59ca4b71c9526f79de6b49e3fa999736cfb2642ad60158b5dbbd3d8ea6c1d2cfc7850a33d334b445a9374153fc5a746a6998fd25fed5beb1b20
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
2
|
+
Version 2, December 2004
|
3
|
+
|
4
|
+
Copyright (C) 2004 Sam Hocevar
|
5
|
+
14 rue de Plaisance, 75014 Paris, France
|
6
|
+
Everyone is permitted to copy and distribute verbatim or modified
|
7
|
+
copies of this license document, and changing it is allowed as long
|
8
|
+
as the name is changed.
|
9
|
+
|
10
|
+
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
11
|
+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
12
|
+
|
13
|
+
0. You just DO WHAT THE FUCK YOU WANT TO.
|
data/README.md
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
# Peridot
|
2
|
+
|
3
|
+
Peridot let's you manage your dotfiles with `rake` and you should love `rake`!
|
4
|
+
Seriously!
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Install it yourself via:
|
9
|
+
|
10
|
+
$ gem install peridot
|
11
|
+
|
12
|
+
## Usage
|
13
|
+
|
14
|
+
In your Rakefile require Peridot. If run inside rake, it will automagically
|
15
|
+
include Peridot module:
|
16
|
+
|
17
|
+
require 'peridot'
|
18
|
+
|
19
|
+
After this, copy the following to a fresh Rakefile:
|
20
|
+
|
21
|
+
require 'rubygems'
|
22
|
+
require 'peridot'
|
23
|
+
|
24
|
+
After this Peridot provides you with 2 standard tasks:
|
25
|
+
|
26
|
+
$ rake -T
|
27
|
+
rake dotfiles # Runs all your task in the dotfiles namespace
|
28
|
+
rake watch # Watches for changes and reruns rake
|
29
|
+
|
30
|
+
Peridot runs every task under `dotfiles` namespace if you run the `dotfiles`
|
31
|
+
task.
|
32
|
+
|
33
|
+
If you need to set up some environment for your dotfiles
|
34
|
+
(e.g. different values for git email at home/work) you do this with tasks for
|
35
|
+
each environment as Peridot relies heavily on `rake`.
|
36
|
+
|
37
|
+
task(:work) { set :git_email, 'work@startup.com' }
|
38
|
+
task(:home) { set :git_email, 'home@hotel-mama.com' }
|
39
|
+
|
40
|
+
You can than use it in an erb file like this:
|
41
|
+
|
42
|
+
email = <%= get! :git_email %>
|
43
|
+
|
44
|
+
## Features
|
45
|
+
|
46
|
+
Peridot gives you some nice methods for interacting with your dotfiles.
|
47
|
+
|
48
|
+
### Path helpers
|
49
|
+
|
50
|
+
There are `#repo_file` and `#home_file` to give you the full paths to your
|
51
|
+
files.
|
52
|
+
|
53
|
+
### ERB
|
54
|
+
|
55
|
+
There is a convenience method to generate a regular files from erb input.
|
56
|
+
|
57
|
+
generate_file(from, to)
|
58
|
+
|
59
|
+
### Watch for changes
|
60
|
+
|
61
|
+
You can add a special task `watch` to your rake command to have Peridot
|
62
|
+
watch for changes and rerun your rake command.
|
63
|
+
|
64
|
+
### Attributes
|
65
|
+
|
66
|
+
There is `#set` to aid you in setting options for later use in
|
67
|
+
your rake tasks. On the other side there is `#get` which fetches attributes
|
68
|
+
from a central storage. To raise an exception if a required attribute is
|
69
|
+
missing there is also `#get!`.
|
70
|
+
|
71
|
+
### Ignoring files
|
72
|
+
|
73
|
+
With `#ignored_files` there is a standard list of files and filetypes
|
74
|
+
which can be matched (regexp) again certain files with `#ignored?(file)`
|
75
|
+
|
76
|
+
ignored_files << 'README'
|
77
|
+
link_file from, to unless ignored?('README')
|
78
|
+
|
79
|
+
### FileUtils
|
80
|
+
|
81
|
+
All methods from `FileUtils` are included in the global namespace and can be
|
82
|
+
used for mastering your dotfiles.
|
83
|
+
|
84
|
+
## Examples in the wild
|
85
|
+
|
86
|
+
Take look at my dotfiles: https://github.com/svenwin/dotfiles/blob/master/Rakefile
|
87
|
+
|
88
|
+
## Special Thanks
|
89
|
+
|
90
|
+
* [Daniel Bayerlein(@danielbayerlein)](https://github.com/danielbayerlein) -
|
91
|
+
For support, code review and much more
|
92
|
+
* [Jim Weirich (@jimweirich)](https://github.com/jimweirich) - for creating
|
93
|
+
[Rake](https://github.com/jimweirich/rake)
|
94
|
+
|
95
|
+
## Contributing
|
96
|
+
|
97
|
+
1. Fork it
|
98
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
99
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
100
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
101
|
+
5. Create new [Pull Request](../../pull/new/master)
|
102
|
+
|
103
|
+
## Copyright
|
104
|
+
|
105
|
+
Copyright (c) 2013 Sven Winkler. See [LICENSE](./LICENSE) for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
module Peridot
|
2
|
+
class AttributeStorage
|
3
|
+
def initialize(hash = {})
|
4
|
+
@hash = hash
|
5
|
+
end
|
6
|
+
|
7
|
+
def get(key)
|
8
|
+
@hash.fetch(key)
|
9
|
+
end
|
10
|
+
|
11
|
+
def get!(key)
|
12
|
+
get(key) or raise("#{key} is not an attribute")
|
13
|
+
end
|
14
|
+
|
15
|
+
def set(key, value)
|
16
|
+
@hash.store(key, value)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module Peridot::FileAccess
|
4
|
+
include(::FileUtils)
|
5
|
+
|
6
|
+
def ignored_files
|
7
|
+
@ignored_files ||= %w(Rakefile \.erb$)
|
8
|
+
end
|
9
|
+
|
10
|
+
def ignored_files=(files)
|
11
|
+
@ignored_files = files
|
12
|
+
end
|
13
|
+
|
14
|
+
def ignored?(file)
|
15
|
+
ignored_files.any? { |ignore_file| file.match(ignore_file) }
|
16
|
+
end
|
17
|
+
|
18
|
+
def generate_file(source, target)
|
19
|
+
puts("Generating #{target}")
|
20
|
+
template = ERB.new(File.read(source))
|
21
|
+
template.filename = target
|
22
|
+
File.open(target, 'w') do |f|
|
23
|
+
f.write(template.result(binding))
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def home_file(file)
|
28
|
+
File.join(Dir.home, file)
|
29
|
+
end
|
30
|
+
|
31
|
+
def repo_file(file)
|
32
|
+
File.join(Dir.pwd, file)
|
33
|
+
end
|
34
|
+
|
35
|
+
def link_file(source, target)
|
36
|
+
rm_f(target)
|
37
|
+
ln_s(source, target)
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
task(:default) { puts 'Peridot is installed, captain ;-)' }
|
2
|
+
|
3
|
+
desc 'Runs all your task in the dotfiles namespace'
|
4
|
+
task :dotfiles do
|
5
|
+
Rake::Task.tasks.select { |t| t.invoke if t.name =~ /^dotfiles:/ }
|
6
|
+
end
|
7
|
+
|
8
|
+
desc 'Watches for changes and reruns rake'
|
9
|
+
task(:watch) { at_exit { Peridot::Watcher.new(ARGV - ['watch']).install! } }
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'listen'
|
2
|
+
|
3
|
+
module Peridot
|
4
|
+
class Watcher
|
5
|
+
def initialize(*args)
|
6
|
+
@args = args
|
7
|
+
end
|
8
|
+
|
9
|
+
def install!
|
10
|
+
puts 'Peridot is watching for changes'
|
11
|
+
@listener = ::Listen.to(Dir.pwd.to_s)
|
12
|
+
@listener.change do
|
13
|
+
@listener.pause
|
14
|
+
run_command!
|
15
|
+
@listener.unpause
|
16
|
+
end
|
17
|
+
@listener.start!
|
18
|
+
end
|
19
|
+
|
20
|
+
def run_command!
|
21
|
+
command = @args.unshift('rake').join(' ')
|
22
|
+
puts(command)
|
23
|
+
system(command)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/peridot.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'erb'
|
2
|
+
require 'peridot/attribute_storage'
|
3
|
+
require 'peridot/file_access'
|
4
|
+
require 'peridot/forwardable'
|
5
|
+
require 'peridot/ignores'
|
6
|
+
require 'peridot/version'
|
7
|
+
require 'peridot/watcher'
|
8
|
+
|
9
|
+
module Peridot
|
10
|
+
def self.included(base)
|
11
|
+
[FileAccess, Forwardable].each { |klass| base.send(:include, klass) }
|
12
|
+
|
13
|
+
base.forward(:get, :get!, :set, to: :attributes)
|
14
|
+
|
15
|
+
load('peridot/tasks.rake') if defined?(Rake)
|
16
|
+
end
|
17
|
+
|
18
|
+
def attributes
|
19
|
+
@attributes ||= AttributeStorage.new
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
include(Peridot) if $PROGRAM_NAME =~ /\/rake[\w\d\S]*$/
|
data/peridot.gemspec
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/peridot/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = %w(Sven Winkler)
|
6
|
+
gem.email = %w(sven@w5r.org)
|
7
|
+
gem.description = %q{Dotfile management with rake on steroids}
|
8
|
+
gem.summary = %q{Dotfile management with rake on steroids}
|
9
|
+
|
10
|
+
gem.files = `git ls-files`.split($\)
|
11
|
+
gem.name = 'peridot'
|
12
|
+
gem.require_paths = %w(lib)
|
13
|
+
gem.version = Peridot::VERSION
|
14
|
+
|
15
|
+
gem.add_dependency('rake')
|
16
|
+
gem.add_dependency('listen')
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: peridot
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sven
|
8
|
+
- Winkler
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-08-18 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - '>='
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - '>='
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: listen
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
description: Dotfile management with rake on steroids
|
43
|
+
email:
|
44
|
+
- sven@w5r.org
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- .gitignore
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- lib/peridot.rb
|
55
|
+
- lib/peridot/attribute_storage.rb
|
56
|
+
- lib/peridot/file_access.rb
|
57
|
+
- lib/peridot/forwardable.rb
|
58
|
+
- lib/peridot/ignores.rb
|
59
|
+
- lib/peridot/tasks.rake
|
60
|
+
- lib/peridot/version.rb
|
61
|
+
- lib/peridot/watcher.rb
|
62
|
+
- peridot.gemspec
|
63
|
+
homepage:
|
64
|
+
licenses: []
|
65
|
+
metadata: {}
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options: []
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - '>='
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
requirements: []
|
81
|
+
rubyforge_project:
|
82
|
+
rubygems_version: 2.0.5
|
83
|
+
signing_key:
|
84
|
+
specification_version: 4
|
85
|
+
summary: Dotfile management with rake on steroids
|
86
|
+
test_files: []
|