kropka 0.0.1 → 0.1.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6629680bf5db580266ed70a66a4bf2037819e299
4
- data.tar.gz: 625bc61d6049277ce8b563c3fd3ee57a09b564e1
3
+ metadata.gz: 09e86490f21de86a6b3066427d1ce19fbb9fd16d
4
+ data.tar.gz: 3a95580a6c9e7c793cb36b378e7a198217934f91
5
5
  SHA512:
6
- metadata.gz: f34fc4eaf524607b4675e99cb8fb42526c072fefe986cc2b13f58be192d19931ab9f5c52e610fc6644d6a94c96b80bd1f18a4f90e4d5858d250e41a88ee4f68f
7
- data.tar.gz: e7660d01e1793552e7f1353081f35d61265d66b63f27be9e9a32014e1ec78730c3dd5c311a4740f45ffdb35462086f077a5433099e795b1e70d5a8beb5112760
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
- source "path/to/source/file"
20
- target "path/to/target/file"
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
- Copied path/to/source/file to path/to/target/file
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,3 @@
1
+ 1. Add ability to execute dry run.
2
+ 2. Manage system packages (Homebrew support for now).
3
+ 3. More.
@@ -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.files = []
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
@@ -1,3 +1,3 @@
1
1
  module Kropka
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
data/lib/kropka.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require_relative "kropka/cli"
2
+ require_relative "kropka/directory"
2
3
  require_relative "kropka/file"
3
4
  require_relative "kropka/recipe"
4
5
  require_relative "kropka/version"
@@ -1,4 +1,8 @@
1
1
  Kropka::Recipe.new do
2
+ directory do
3
+ name "spec/fixtures/sandbox/target/directory/tree/structure"
4
+ end
5
+
2
6
  file do
3
7
  source "spec/fixtures/sandbox/source/foo.txt"
4
8
  target "spec/fixtures/sandbox/target/bar.txt"
@@ -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
@@ -3,6 +3,5 @@ require "support/sandbox"
3
3
  require "kropka"
4
4
 
5
5
  RSpec.configure do |config|
6
- config.before(:suite) { Sandbox.reset }
7
- config.after(:suite) { Sandbox.reset }
6
+ config.before { Sandbox.reset }
8
7
  end
@@ -14,6 +14,7 @@ module Sandbox
14
14
  end
15
15
 
16
16
  def self.reset
17
+ FileUtils.rm_rf(::File.join(target_files_path, "directory"))
17
18
  FileUtils.rm_rf(::File.join(target_files_path, "bar.txt"))
18
19
  end
19
20
 
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.1
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