kropka 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +24 -3
- data/ROADMAP.md +3 -0
- data/lib/kropka/directory.rb +20 -0
- data/lib/kropka/recipe.rb +9 -3
- data/lib/kropka/version.rb +1 -1
- data/lib/kropka.rb +1 -0
- data/spec/fixtures/sandbox/recipe.rb +4 -0
- data/spec/fixtures/sandbox/target/bar.txt +1 -0
- data/spec/kropka/directory_spec.rb +17 -0
- data/spec/spec_helper.rb +1 -2
- data/spec/support/sandbox.rb +1 -0
- metadata +7 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 09e86490f21de86a6b3066427d1ce19fbb9fd16d
|
4
|
+
data.tar.gz: 3a95580a6c9e7c793cb36b378e7a198217934f91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6960e0c8eabc268b69d925d81a74a7b82234d9a3899b520c7818bf49e0f47da99f97878aa3386c6d41b816012f2e6f81f41f059be50625c9e0fed9d8916a4b51
|
7
|
+
data.tar.gz: 96169e99cb114be0c058f79019ccd851a1f27bcf3760272058ede7c83cfa1b24dc2e1c11103dc5d50488a2ecbe4e3636a14eaf117bcb2875acc23646bf739117
|
data/README.md
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
|
3
3
|
Manage your dotfiles
|
4
4
|
|
5
|
+
## The name
|
6
|
+
|
7
|
+
`kropka` means `dot` in Polish language
|
8
|
+
|
9
|
+
## Rationale
|
10
|
+
|
11
|
+
Inspired by Puppet and because I can...
|
12
|
+
|
5
13
|
## Installation
|
6
14
|
|
7
15
|
``` bash
|
@@ -16,8 +24,19 @@ Write your recipe:
|
|
16
24
|
# recipe.rb
|
17
25
|
|
18
26
|
Kropka::Recipe.new do
|
19
|
-
|
20
|
-
|
27
|
+
directory do
|
28
|
+
name "directory/tree/structure"
|
29
|
+
end
|
30
|
+
|
31
|
+
file do
|
32
|
+
source "path/to/source/file1"
|
33
|
+
target "path/to/target/file1"
|
34
|
+
end
|
35
|
+
|
36
|
+
file do
|
37
|
+
source "path/to/source/file2"
|
38
|
+
target "path/to/target/file2"
|
39
|
+
end
|
21
40
|
end
|
22
41
|
```
|
23
42
|
|
@@ -25,7 +44,9 @@ and apply it:
|
|
25
44
|
|
26
45
|
``` bash
|
27
46
|
$ kropka apply recipe.rb
|
28
|
-
|
47
|
+
Created directory directory/tree/structure
|
48
|
+
Copied path/to/source/file1 to path/to/target/file1
|
49
|
+
Copied path/to/source/file2 to path/to/target/file2
|
29
50
|
```
|
30
51
|
|
31
52
|
## Example
|
data/ROADMAP.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require "fileutils"
|
2
|
+
|
3
|
+
module Kropka
|
4
|
+
class Directory
|
5
|
+
def initialize(&block)
|
6
|
+
instance_eval(&block) if block_given?
|
7
|
+
end
|
8
|
+
|
9
|
+
def create!
|
10
|
+
FileUtils.mkdir_p(@name)
|
11
|
+
puts "Created directory #{@name}"
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def name(name)
|
17
|
+
@name = name
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/kropka/recipe.rb
CHANGED
@@ -5,7 +5,8 @@ module Kropka
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def initialize(&block)
|
8
|
-
self.
|
8
|
+
self.directories = []
|
9
|
+
self.files = []
|
9
10
|
|
10
11
|
instance_eval(&block) if block_given?
|
11
12
|
|
@@ -13,17 +14,22 @@ module Kropka
|
|
13
14
|
end
|
14
15
|
|
15
16
|
def apply!
|
17
|
+
directories.map(&:create!)
|
16
18
|
files.map(&:copy!)
|
17
19
|
end
|
18
20
|
|
19
|
-
attr_reader :files
|
21
|
+
attr_reader :directories, :files
|
20
22
|
|
21
23
|
private
|
22
24
|
|
25
|
+
def directory(&block)
|
26
|
+
self.directories << Directory.new(&block) if block_given?
|
27
|
+
end
|
28
|
+
|
23
29
|
def file(&block)
|
24
30
|
self.files << File.new(&block) if block_given?
|
25
31
|
end
|
26
32
|
|
27
|
-
attr_writer :files
|
33
|
+
attr_writer :directories, :files
|
28
34
|
end
|
29
35
|
end
|
data/lib/kropka/version.rb
CHANGED
data/lib/kropka.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
Hello world
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "creating directories" do
|
4
|
+
let(:recipe_file_path) { Sandbox.recipe_file_path }
|
5
|
+
|
6
|
+
before { Kropka.load_recipe(recipe_file_path) }
|
7
|
+
|
8
|
+
it "creates directory structure" do
|
9
|
+
expect do
|
10
|
+
Kropka::Recipe.instance.apply!
|
11
|
+
end.to change {
|
12
|
+
::File.exists?(
|
13
|
+
::File.join(Sandbox.target_files_path, "directory", "tree", "structure")
|
14
|
+
)
|
15
|
+
}.to(true)
|
16
|
+
end
|
17
|
+
end
|
data/spec/spec_helper.rb
CHANGED
data/spec/support/sandbox.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kropka
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomek Wałkuski
|
@@ -79,17 +79,21 @@ files:
|
|
79
79
|
- Gemfile
|
80
80
|
- LICENSE.txt
|
81
81
|
- README.md
|
82
|
+
- ROADMAP.md
|
82
83
|
- Rakefile
|
83
84
|
- bin/kropka
|
84
85
|
- kropka.gemspec
|
85
86
|
- lib/kropka.rb
|
86
87
|
- lib/kropka/cli.rb
|
88
|
+
- lib/kropka/directory.rb
|
87
89
|
- lib/kropka/file.rb
|
88
90
|
- lib/kropka/recipe.rb
|
89
91
|
- lib/kropka/version.rb
|
90
92
|
- spec/fixtures/sandbox/recipe.rb
|
91
93
|
- spec/fixtures/sandbox/source/foo.txt
|
92
94
|
- spec/fixtures/sandbox/target/.keep
|
95
|
+
- spec/fixtures/sandbox/target/bar.txt
|
96
|
+
- spec/kropka/directory_spec.rb
|
93
97
|
- spec/kropka/file_spec.rb
|
94
98
|
- spec/spec_helper.rb
|
95
99
|
- spec/support/sandbox.rb
|
@@ -121,6 +125,8 @@ test_files:
|
|
121
125
|
- spec/fixtures/sandbox/recipe.rb
|
122
126
|
- spec/fixtures/sandbox/source/foo.txt
|
123
127
|
- spec/fixtures/sandbox/target/.keep
|
128
|
+
- spec/fixtures/sandbox/target/bar.txt
|
129
|
+
- spec/kropka/directory_spec.rb
|
124
130
|
- spec/kropka/file_spec.rb
|
125
131
|
- spec/spec_helper.rb
|
126
132
|
- spec/support/sandbox.rb
|