guardfile 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: 733206a1c60cefb87d8a62907be70b7ef567f4a5
4
+ data.tar.gz: b33c2d02abbae4296cf82383e246e58ca9cad08a
5
+ SHA512:
6
+ metadata.gz: 38647e4342d13b438eb6b104e272afe1479f5fe70c1f617a27d68ac369c8402d079f045c1559c986da78c57cbcb280d099eec5989c6893e18c996340c39cac87
7
+ data.tar.gz: 6192a9983d57717be1f73f5d07f6273447a80208232cd8180daad511718726c493e1c0ad9e8f241b44287e793315af2fc7085d2085d177b8e988f16d2fdc7ade
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/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in guardfile.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Bartosz Kopiński
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Bartosz Kopiński
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,62 @@
1
+ # Guardfile
2
+
3
+ Provides better DSL for Guardfiles
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'guardfile'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install guardfile
18
+
19
+ ## Usage
20
+
21
+ Sample Guardfile:
22
+
23
+ ```ruby
24
+ require 'guardfile'
25
+
26
+ with_shell do
27
+ on_change_in('Gemfile') do
28
+ `bundle install && touch tmp/restart.txt`
29
+ end
30
+ end
31
+
32
+ with_spork(all_after_pass: false, all_on_start: false, bundler: false) do
33
+ run(:rspec).on_change_in(
34
+ 'config/*.rb',
35
+ 'lib/*.rb',
36
+ 'Gemfile.lock',
37
+ 'spec/spec_helper.rb',
38
+ )
39
+ end
40
+
41
+ with_rspec(rspec_env: { RAILS_ENV: 'test' }, wait: 60) do
42
+ run('spec/*_spec.rb').on_change
43
+ run('spec/lib/*_spec.rb').on_change_in('lib/*.rb')
44
+ run('spec/views/*/*_spec.rb').on_change_in('app/views/*/*.haml')
45
+ run('spec/controllers/*_controller_spec.rb').on_change_in('app/controllers/*_controller.rb')
46
+ run('spec/controllers/').on_change_in('app/controllers/application_controller.rb')
47
+ run('spec/').on_change_in(
48
+ 'spec/factories.rb',
49
+ 'spec/spec_helper.rb',
50
+ 'spec/support/*.rb',
51
+ 'config/*.rb',
52
+ )
53
+ end
54
+ ```
55
+
56
+ ## Contributing
57
+
58
+ 1. Fork it
59
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
60
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
61
+ 4. Push to the branch (`git push origin my-new-feature`)
62
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/guardfile.gemspec ADDED
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'guardfile/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = 'guardfile'
8
+ gem.version = Guardfile::VERSION
9
+ gem.authors = ['Bartosz Kopinski']
10
+ gem.email = ['bartosz.kopinski@netguru.pl']
11
+ gem.description = 'Better Guardfile syntax'
12
+ gem.summary = 'Better Guardfile syntax'
13
+ gem.homepage = ''
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ['lib']
19
+
20
+ gem.add_dependency 'guard', '>= 2.1.1'
21
+ gem.add_development_dependency 'bundler', '>= 1.3.5'
22
+ gem.add_development_dependency 'rake'
23
+ end
data/lib/guardfile.rb ADDED
@@ -0,0 +1,2 @@
1
+ require 'guardfile/version'
2
+ require 'guardfile/dsl'
@@ -0,0 +1,57 @@
1
+ require 'guard/dsl'
2
+
3
+ require 'guardfile/dsl/action'
4
+ require 'guardfile/dsl/change'
5
+
6
+ module Guard
7
+ class Dsl
8
+ def run action
9
+ Action.new(self, action)
10
+ end
11
+
12
+ def on_change_in *patterns, &action
13
+ return Change.new(self, patterns) unless block_given?
14
+
15
+ patterns.each do |pattern|
16
+ UI.info "Watching #{pattern}"
17
+ watch(pattern_regexp(pattern)) do |match_data|
18
+ UI.info "Change in: #{fill_with_matches(pattern, match_data)}"
19
+ build_action(action.call, match_data)
20
+ end
21
+ end
22
+ end
23
+
24
+ def method_missing method, options = {}, &action
25
+ super unless method.to_s =~ /^with_(.+)$/
26
+
27
+ guard($1, options) do
28
+ rules = action.call
29
+ next unless rules.is_a? Hash
30
+ rules.each do |command, patterns|
31
+ on_change_in(*Array(patterns)){ command }
32
+ end
33
+ end
34
+ end
35
+
36
+ private
37
+
38
+ def fill_with_matches string, match_data
39
+ string.gsub(?*).each_with_index{ |_, i| match_data[i+1] }
40
+ end
41
+
42
+ def build_action command, match_data
43
+ case command
44
+ when String
45
+ fill_with_matches(command, match_data)
46
+ when Proc
47
+ command.call
48
+ else
49
+ command
50
+ end
51
+ end
52
+
53
+ def pattern_regexp pattern
54
+ /^#{Regexp.escape(pattern).gsub('\\*', '(.*)')}$/i
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,18 @@
1
+ module Guard
2
+ class Dsl
3
+ class Action
4
+ def initialize guardfile, action
5
+ @guardfile = guardfile
6
+ @action = action
7
+ end
8
+
9
+ def on_change
10
+ on_change_in(@action)
11
+ end
12
+
13
+ def on_change_in *patterns
14
+ @guardfile.on_change_in(*patterns){ @action }
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,14 @@
1
+ module Guard
2
+ class Dsl
3
+ class Change
4
+ def initialize guardfile, patterns
5
+ @guardfile = guardfile
6
+ @patterns = patterns
7
+ end
8
+
9
+ def run action
10
+ @guardfile.run(action).on_change_in(*@patterns)
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,3 @@
1
+ module Guardfile
2
+ VERSION = '0.0.1'
3
+ end
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: guardfile
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Bartosz Kopinski
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-12-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: guard
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 2.1.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 2.1.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: 1.3.5
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: 1.3.5
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
+ description: Better Guardfile syntax
56
+ email:
57
+ - bartosz.kopinski@netguru.pl
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - Gemfile
64
+ - LICENSE
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - guardfile.gemspec
69
+ - lib/guardfile.rb
70
+ - lib/guardfile/dsl.rb
71
+ - lib/guardfile/dsl/action.rb
72
+ - lib/guardfile/dsl/change.rb
73
+ - lib/guardfile/version.rb
74
+ homepage: ''
75
+ licenses: []
76
+ metadata: {}
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 2.1.10
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: Better Guardfile syntax
97
+ test_files: []
98
+ has_rdoc: