kropka 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6629680bf5db580266ed70a66a4bf2037819e299
4
+ data.tar.gz: 625bc61d6049277ce8b563c3fd3ee57a09b564e1
5
+ SHA512:
6
+ metadata.gz: f34fc4eaf524607b4675e99cb8fb42526c072fefe986cc2b13f58be192d19931ab9f5c52e610fc6644d6a94c96b80bd1f18a4f90e4d5858d250e41a88ee4f68f
7
+ data.tar.gz: e7660d01e1793552e7f1353081f35d61265d66b63f27be9e9a32014e1ec78730c3dd5c311a4740f45ffdb35462086f077a5433099e795b1e70d5a8beb5112760
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Tomek Wałkuski
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # Kropka
2
+
3
+ Manage your dotfiles
4
+
5
+ ## Installation
6
+
7
+ ``` bash
8
+ $ gem install kropka
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ Write your recipe:
14
+
15
+ ``` ruby
16
+ # recipe.rb
17
+
18
+ Kropka::Recipe.new do
19
+ source "path/to/source/file"
20
+ target "path/to/target/file"
21
+ end
22
+ ```
23
+
24
+ and apply it:
25
+
26
+ ``` bash
27
+ $ kropka apply recipe.rb
28
+ Copied path/to/source/file to path/to/target/file
29
+ ```
30
+
31
+ ## Example
32
+
33
+ * [tomekw/dotfiles](https://github.com/tomekw/dotfiles)
34
+
35
+ ## Contributing
36
+
37
+ 1. Fork it
38
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
39
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
40
+ 4. Push to the branch (`git push origin my-new-feature`)
41
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/kropka ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative "../lib/kropka"
4
+
5
+ Kropka::CLI.start
data/kropka.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # encoding: utf-8
2
+
3
+ lib = File.expand_path("../lib", __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+
6
+ require "kropka/version"
7
+
8
+ Gem::Specification.new do |spec|
9
+ spec.name = "kropka"
10
+ spec.version = Kropka::VERSION
11
+ spec.authors = ["Tomek Wałkuski"]
12
+ spec.email = ["ja@jestem.tw"]
13
+ spec.description = %q{Manage your dotfiles}
14
+ spec.summary = %q{Manage your dotfiles}
15
+ spec.homepage = "https://github.com/tomekw/kropka"
16
+ spec.license = "MIT"
17
+ spec.files = `git ls-files`.split($/)
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^spec/})
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_dependency "thor"
23
+
24
+ spec.add_development_dependency "bundler"
25
+ spec.add_development_dependency "rake"
26
+ spec.add_development_dependency "rspec"
27
+ end
data/lib/kropka/cli.rb ADDED
@@ -0,0 +1,18 @@
1
+ require "thor"
2
+
3
+ module Kropka
4
+ class CLI < Thor
5
+ desc "apply [RECIPE]", "Apply recipe RECIPE"
6
+ def apply(recipe_file)
7
+ Kropka.load_recipe(recipe_file)
8
+
9
+ Recipe.instance.apply!
10
+ end
11
+
12
+ map "-v" => :version
13
+ desc "version", "Display installed Kropka version"
14
+ def version
15
+ puts "Kropka #{ Kropka::VERSION }"
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,24 @@
1
+ require "fileutils"
2
+
3
+ module Kropka
4
+ class File
5
+ def initialize(&block)
6
+ instance_eval(&block) if block_given?
7
+ end
8
+
9
+ def copy!
10
+ FileUtils.cp(@source, @target)
11
+ puts "Copied #{@source} to #{@target}"
12
+ end
13
+
14
+ private
15
+
16
+ def source(source)
17
+ @source = source
18
+ end
19
+
20
+ def target(target)
21
+ @target = target
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,29 @@
1
+ module Kropka
2
+ class Recipe
3
+ def self.instance
4
+ @@instance
5
+ end
6
+
7
+ def initialize(&block)
8
+ self.files = []
9
+
10
+ instance_eval(&block) if block_given?
11
+
12
+ @@instance = self
13
+ end
14
+
15
+ def apply!
16
+ files.map(&:copy!)
17
+ end
18
+
19
+ attr_reader :files
20
+
21
+ private
22
+
23
+ def file(&block)
24
+ self.files << File.new(&block) if block_given?
25
+ end
26
+
27
+ attr_writer :files
28
+ end
29
+ end
@@ -0,0 +1,3 @@
1
+ module Kropka
2
+ VERSION = "0.0.1"
3
+ end
data/lib/kropka.rb ADDED
@@ -0,0 +1,16 @@
1
+ require_relative "kropka/cli"
2
+ require_relative "kropka/file"
3
+ require_relative "kropka/recipe"
4
+ require_relative "kropka/version"
5
+
6
+ module Kropka
7
+ def self.load_recipe(file)
8
+ module_eval(read(file))
9
+ end
10
+
11
+ private
12
+
13
+ def self.read(file)
14
+ ::File.read(file)
15
+ end
16
+ end
@@ -0,0 +1,6 @@
1
+ Kropka::Recipe.new do
2
+ file do
3
+ source "spec/fixtures/sandbox/source/foo.txt"
4
+ target "spec/fixtures/sandbox/target/bar.txt"
5
+ end
6
+ end
@@ -0,0 +1 @@
1
+ Hello world
File without changes
@@ -0,0 +1,15 @@
1
+ require "spec_helper"
2
+
3
+ describe "copying files" do
4
+ let(:recipe_file_path) { Sandbox.recipe_file_path }
5
+
6
+ before { Kropka.load_recipe(recipe_file_path) }
7
+
8
+ it "copies file from source to target" do
9
+ expect do
10
+ Kropka::Recipe.instance.apply!
11
+ end.to change {
12
+ ::File.exists?(::File.join(Sandbox.target_files_path, "bar.txt"))
13
+ }.to(true)
14
+ end
15
+ end
@@ -0,0 +1,8 @@
1
+ require "rspec"
2
+ require "support/sandbox"
3
+ require "kropka"
4
+
5
+ RSpec.configure do |config|
6
+ config.before(:suite) { Sandbox.reset }
7
+ config.after(:suite) { Sandbox.reset }
8
+ end
@@ -0,0 +1,25 @@
1
+ require "fileutils"
2
+
3
+ module Sandbox
4
+ def self.recipe_file_path
5
+ ::File.join(sandbox_path, "recipe.rb")
6
+ end
7
+
8
+ def self.source_files_path
9
+ ::File.join(sandbox_path, "source")
10
+ end
11
+
12
+ def self.target_files_path
13
+ ::File.join(sandbox_path, "target")
14
+ end
15
+
16
+ def self.reset
17
+ FileUtils.rm_rf(::File.join(target_files_path, "bar.txt"))
18
+ end
19
+
20
+ private
21
+
22
+ def self.sandbox_path
23
+ ::File.join(%w(spec fixtures sandbox))
24
+ end
25
+ end
metadata ADDED
@@ -0,0 +1,126 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kropka
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Tomek Wałkuski
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-06-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Manage your dotfiles
70
+ email:
71
+ - ja@jestem.tw
72
+ executables:
73
+ - kropka
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - .gitignore
78
+ - .rspec
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - bin/kropka
84
+ - kropka.gemspec
85
+ - lib/kropka.rb
86
+ - lib/kropka/cli.rb
87
+ - lib/kropka/file.rb
88
+ - lib/kropka/recipe.rb
89
+ - lib/kropka/version.rb
90
+ - spec/fixtures/sandbox/recipe.rb
91
+ - spec/fixtures/sandbox/source/foo.txt
92
+ - spec/fixtures/sandbox/target/.keep
93
+ - spec/kropka/file_spec.rb
94
+ - spec/spec_helper.rb
95
+ - spec/support/sandbox.rb
96
+ homepage: https://github.com/tomekw/kropka
97
+ licenses:
98
+ - MIT
99
+ metadata: {}
100
+ post_install_message:
101
+ rdoc_options: []
102
+ require_paths:
103
+ - lib
104
+ required_ruby_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - '>='
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ required_rubygems_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - '>='
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ requirements: []
115
+ rubyforge_project:
116
+ rubygems_version: 2.0.3
117
+ signing_key:
118
+ specification_version: 4
119
+ summary: Manage your dotfiles
120
+ test_files:
121
+ - spec/fixtures/sandbox/recipe.rb
122
+ - spec/fixtures/sandbox/source/foo.txt
123
+ - spec/fixtures/sandbox/target/.keep
124
+ - spec/kropka/file_spec.rb
125
+ - spec/spec_helper.rb
126
+ - spec/support/sandbox.rb