polka 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +3 -2
- data/lib/polka.rb +7 -1
- data/lib/polka/operations/parsed_copying.rb +15 -2
- data/lib/polka/version.rb +1 -1
- data/spec/polka/operations/parsed_copying_spec.rb +30 -7
- metadata +8 -8
data/README.md
CHANGED
@@ -6,6 +6,8 @@ Polka sets up your dotfiles
|
|
6
6
|
|
7
7
|
In your dotfile directory create a file called `Dotfile`. My Dotfile looks like this:
|
8
8
|
|
9
|
+
configure personal_file: "~/Dropbox/polka_personal.yml"
|
10
|
+
|
9
11
|
symlink ".gemrc", ".vimrc", ".zshrc", ".zsh_custom", ".vim"
|
10
12
|
symlink ".gitignore_global", as: ".gitignore"
|
11
13
|
copy ".gitconfig.erb"
|
@@ -26,5 +28,4 @@ In `.gitconfig.erb`:
|
|
26
28
|
name = <%= personal['name'] %>
|
27
29
|
email = <%= personal['email'] %>
|
28
30
|
|
29
|
-
`personal.yml` should be added to your `.gitignore`, ldo.
|
30
|
-
|
31
|
+
`personal.yml` is expected to be in your dotfile directory and should be added to your `.gitignore`, ldo. Alternatively, you can configure an alternate path (see example).
|
data/lib/polka.rb
CHANGED
@@ -30,12 +30,25 @@ module Polka
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def context
|
33
|
-
|
33
|
+
context = Hash.new do |_, k|
|
34
|
+
Polka.log " Warning: ".yellow + "personal['#{k}'] not found for #{context_name} in #{yaml_file}."
|
35
|
+
Polka.ask " Please provide personal['#{k}'] for #{context_name}: "
|
36
|
+
end
|
37
|
+
|
38
|
+
if File.exists?(yaml_file)
|
39
|
+
yaml_hash = YAML.load_file(yaml_file)[context_name]
|
40
|
+
context = context.merge(yaml_hash) if yaml_hash
|
41
|
+
end
|
42
|
+
|
43
|
+
return context
|
34
44
|
end
|
35
45
|
|
36
46
|
def yaml_file
|
37
47
|
filename = Polka.config[:personal_file] || File.join(File.dirname(@file), "personal.yml")
|
38
|
-
File.expand_path(filename)
|
48
|
+
filename = File.expand_path(filename)
|
49
|
+
Polka.log("Warning! ".yellow + "Could not find personal file at #{filename}") unless File.exists?(filename)
|
50
|
+
|
51
|
+
filename
|
39
52
|
end
|
40
53
|
|
41
54
|
def context_name
|
data/lib/polka/version.rb
CHANGED
@@ -1,22 +1,38 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Polka::Operations::ParsedCopying, :integrated_with_files do
|
4
|
+
subject(:copier) { Polka::Operations::ParsedCopying }
|
5
|
+
let(:input_file) { File.join(dotfile_dir, "to_be_parsed.erb") }
|
6
|
+
let(:output_file) { File.join(home_dir, "parsable") }
|
7
|
+
let(:personal_file) { File.join(dotfile_dir, "personal.yml") }
|
4
8
|
set_up_testdirs
|
5
9
|
|
6
10
|
before do
|
7
|
-
File.open(
|
11
|
+
File.open(input_file, "w") { |f| f.write("hello <%= personal['name'] %>") }
|
8
12
|
end
|
9
13
|
|
10
14
|
def write_personal_file(filename)
|
11
|
-
File.open(filename, "w") { |f| f.write("
|
15
|
+
File.open(filename, "w") { |f| f.write("to_be_parsed:\n name: ray stanz") }
|
16
|
+
end
|
17
|
+
|
18
|
+
def parsed_content
|
19
|
+
File.open(output_file) { |f| f.read }
|
12
20
|
end
|
13
21
|
|
14
22
|
it "parses the erb file and copys the result without the extension" do
|
15
|
-
personal_file = File.join(dotfile_dir, "personal.yml")
|
16
23
|
write_personal_file(personal_file)
|
17
24
|
|
18
|
-
|
19
|
-
|
25
|
+
copier.call(input_file, output_file + ".erb")
|
26
|
+
parsed_content.should == "hello ray stanz"
|
27
|
+
end
|
28
|
+
|
29
|
+
it "prompts for input if a personal reference is missing from personal.yml" do
|
30
|
+
write_personal_file(personal_file)
|
31
|
+
|
32
|
+
File.open(input_file, "w") { |f| f.write("hello <%= personal['not_name'] %>") }
|
33
|
+
Polka.stub(:ask) { "johnny" }
|
34
|
+
copier.call(input_file, output_file)
|
35
|
+
parsed_content.should == "hello johnny"
|
20
36
|
end
|
21
37
|
|
22
38
|
it "uses the personal.yml provided in the config" do
|
@@ -27,7 +43,14 @@ describe Polka::Operations::ParsedCopying, :integrated_with_files do
|
|
27
43
|
|
28
44
|
Polka.stub(:config) { { personal_file: another_dir + "/polka_personal.yml" } }
|
29
45
|
|
30
|
-
|
31
|
-
|
46
|
+
copier.call(input_file, output_file)
|
47
|
+
parsed_content.should == "hello ray stanz"
|
48
|
+
end
|
49
|
+
|
50
|
+
it "doesn't produce errors if personal file is missing" do
|
51
|
+
Polka.stub(:config) { { personal_file: "does_not_exist" } }
|
52
|
+
Polka.stub(:ask) { "what" }
|
53
|
+
Polka.stub(:log)
|
54
|
+
expect { copier.call(input_file, output_file) }.to_not raise_error
|
32
55
|
end
|
33
56
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: polka
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-09-
|
12
|
+
date: 2012-09-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
16
|
-
requirement: &
|
16
|
+
requirement: &70261072235760 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.16.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70261072235760
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: colorize
|
27
|
-
requirement: &
|
27
|
+
requirement: &70261072235260 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - =
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 0.5.8
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70261072235260
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &70261072234800 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '2.11'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70261072234800
|
47
47
|
description: Easy Dotfile Management
|
48
48
|
email:
|
49
49
|
- michi.huber@gmail.com
|