guard-depend 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 821b438dfe03bb7111eaa0cf6b45f088659ceb78
4
+ data.tar.gz: 746b749a2995ef1d31011f7d40d127115852eed0
5
+ SHA512:
6
+ metadata.gz: af2e9a246d265125720e9bc2e2a7cbd5509709cc0a2685ee4b37d10f449964fa73dd39238b436d93fa6ec38b2b15c65dc3bc803de090f5b9295df621e886edfb
7
+ data.tar.gz: 31fd55091e2c023b51fa54792d2d3c43e3741162127689217cb20872f45670be703674d6760af524c5beb8837b716687f8f373deff740cb4447d70abfcb9e74c
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/
5
+ tmp/
6
+ .idea/
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,24 @@
1
+ case RbConfig::CONFIG['target_os']
2
+ when /windows|bccwin|cygwin|djgpp|mingw|mswin|wince/i
3
+ notification :gntp, :host => 'localhost'
4
+ when /linux/i
5
+ notification :notifysend
6
+ when /mac|darwin/i
7
+ notification :growl
8
+ end
9
+
10
+ guard 'bundler' do
11
+ watch('Gemfile')
12
+ watch(/^.+\.gemspec/)
13
+ end
14
+
15
+ guard 'rspec',
16
+ :all_on_start => true,
17
+ :all_after_pass => true,
18
+ :notification => true,
19
+ :cmd => 'bundle exec rspec' do
20
+ watch('.rspec') { 'spec' }
21
+ watch(%r{^spec/.+_spec\.rb$})
22
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
23
+ watch('spec/spec_helper.rb') { 'spec' }
24
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Alexander Groß
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,29 @@
1
+ # Guard::Depend
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'guard-depend'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install guard-depend
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it ( http://github.com/<my-github-username>/guard-depend/fork )
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,41 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'rbconfig'
4
+ require 'guard/depend/version'
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = 'guard-depend'
8
+ s.version = Guard::Depend::VERSION
9
+ s.platform = Gem::Platform::RUBY
10
+ s.authors = ['Alexander Groß']
11
+ s.email = ['agross@therightstuff.de']
12
+ s.homepage = 'http://grossweber.com'
13
+ s.license = 'MIT'
14
+ s.description = %q{Run commands only if build output is not up to date.}
15
+ s.summary = %q{guard-depend is useful for projects that produce build output like binaries. guard-depend will only run the command you sify if the build output does not exists or is not up to date with regard to the watched files.}
16
+
17
+ s.add_dependency 'rake'
18
+ s.add_dependency 'guard', '~> 2.5'
19
+
20
+ s.add_development_dependency 'bundler', '~> 1.5'
21
+ s.add_development_dependency 'rspec'
22
+ s.add_development_dependency 'guard-bundler'
23
+ s.add_development_dependency 'guard-rspec'
24
+
25
+ case RbConfig::CONFIG['target_os']
26
+ when /windows|bccwin|cygwin|djgpp|mingw|mswin|wince/i
27
+ s.add_development_dependency 'ruby_gntp'
28
+ s.add_development_dependency 'wdm'
29
+ when /linux/i
30
+ s.add_development_dependency 'rb-inotify'
31
+ when /mac|darwin/i
32
+ s.add_development_dependency 'rb-fsevent'
33
+ s.add_development_dependency 'growl'
34
+ end
35
+
36
+ git = ENV['TEAMCITY_GIT_PATH'] || 'git'
37
+ s.files = `"#{git}" ls-files -z`.split("\x0")
38
+ s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
39
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
40
+ s.require_paths = ['lib']
41
+ end
@@ -0,0 +1,74 @@
1
+ require 'guard'
2
+ require 'guard/plugin'
3
+
4
+ module Guard
5
+ class Depend < Plugin
6
+ require 'guard/depend/options'
7
+ require 'guard/depend/runner'
8
+
9
+ def initialize(options = {})
10
+ super
11
+ @options = Options.with_defaults(options)
12
+ @runner = Runner.new
13
+ end
14
+
15
+ def start
16
+ UI.info 'Guard::Depend is running'
17
+ run_all if @options[:run_on_start]
18
+ end
19
+
20
+ def stop
21
+ end
22
+
23
+ def reload
24
+ end
25
+
26
+ def run_all
27
+ @runner.run(@options[:cmd])
28
+ end
29
+
30
+ def run_on_changes(paths = [])
31
+ run_if_outdated(paths)
32
+ end
33
+
34
+ private
35
+ def run_if_outdated(paths = [])
36
+ return false if paths.empty?
37
+
38
+ outdated = out_of_date?(paths, @options[:output_paths])
39
+ unless outdated
40
+ UI.debug("Output is not outdated with regard to #{paths}")
41
+ return
42
+ end
43
+
44
+ @runner.run(@options[:cmd])
45
+ end
46
+
47
+ def out_of_date?(input, output)
48
+ output = output.call if output.respond_to?(:call)
49
+
50
+ return true if input.nil? || input.empty? || output.nil? || output.empty?
51
+
52
+ input = input.max_by {|f| input_mtime(f) }
53
+ output = output.min_by {|f| output_mtime(f) }
54
+
55
+ input_time = input_mtime(input)
56
+ output_time = output_mtime(output)
57
+
58
+ UI.debug("Newest input file: #{input_time} #{input}")
59
+ UI.debug("Oldest output file: #{output_time} #{output}")
60
+
61
+ return input_time > output_time
62
+ end
63
+
64
+ def input_mtime(file)
65
+ return Time.new(9999, 12, 31) unless File.readable?(file)
66
+ File.mtime(file)
67
+ end
68
+
69
+ def output_mtime(file)
70
+ return Time.new(0, 1, 1) unless File.readable?(file)
71
+ File.mtime(file)
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,28 @@
1
+ module Guard
2
+ class Depend
3
+ module Options
4
+ DEFAULTS = {
5
+ run_on_start: false,
6
+ output_paths: [],
7
+ cmd: nil
8
+ }
9
+
10
+ class << self
11
+ def with_defaults(options = {})
12
+ _deep_merge(DEFAULTS, options)
13
+ end
14
+
15
+ private
16
+ def _deep_merge(hash1, hash2)
17
+ hash1.merge(hash2) do |key, oldval, newval|
18
+ if oldval.instance_of?(Hash) && newval.instance_of?(Hash)
19
+ _deep_merge(oldval, newval)
20
+ else
21
+ newval
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,29 @@
1
+ require 'rake'
2
+
3
+ module Guard
4
+ class Depend
5
+ class Runner
6
+ def run(cmd)
7
+ cmd = [cmd].flatten
8
+ command = cmd.join(' ')
9
+
10
+ begin
11
+ UI.info("Running '#{command}'")
12
+ Notifier.notify(command, title: 'Running', image: :success)
13
+
14
+ sh(*cmd)
15
+
16
+ Notifier.notify("#{command} succeeded", title: 'Success', image: :success)
17
+ rescue Exception => e
18
+ UI.error("Failed to run '#{command}'. Exception was: #{e.class}: #{e.message}")
19
+ UI.debug(e.backtrace.join("\n"))
20
+
21
+ Notifier.notify("#{command} failed with #{e}", title: 'Failed', image: :failed)
22
+ end
23
+ end
24
+
25
+ private
26
+ include FileUtils
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,9 @@
1
+ guard :depend,
2
+ # The path to the output generated by cmd.
3
+ output_paths: -> () { Dir['build/bin/*.dll'] },
4
+ # The command to run if the output is outdated or does not exist.
5
+ cmd: %w(bundle exec rake compile),
6
+ # Whether to run at startup.
7
+ run_on_start: false do
8
+ watch(%r{^source/.*\.cs$}i)
9
+ end
@@ -0,0 +1,5 @@
1
+ module Guard
2
+ module Depend
3
+ VERSION = '0.0.1'
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ RSpec.configure do |config|
2
+ end
metadata ADDED
@@ -0,0 +1,172 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: guard-depend
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Alexander Groß
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
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: guard
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.5'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.5'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.5'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.5'
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
+ - !ruby/object:Gem::Dependency
70
+ name: guard-bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: guard-rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: ruby_gntp
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: wdm
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: Run commands only if build output is not up to date.
126
+ email:
127
+ - agross@therightstuff.de
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - ".gitignore"
133
+ - Gemfile
134
+ - Guardfile
135
+ - LICENSE.txt
136
+ - README.md
137
+ - Rakefile
138
+ - guard-depend.gemspec
139
+ - lib/guard/depend.rb
140
+ - lib/guard/depend/options.rb
141
+ - lib/guard/depend/runner.rb
142
+ - lib/guard/depend/templates/Guardfile
143
+ - lib/guard/depend/version.rb
144
+ - spec/spec_helper.rb
145
+ homepage: http://grossweber.com
146
+ licenses:
147
+ - MIT
148
+ metadata: {}
149
+ post_install_message:
150
+ rdoc_options: []
151
+ require_paths:
152
+ - lib
153
+ required_ruby_version: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - ">="
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ required_rubygems_version: !ruby/object:Gem::Requirement
159
+ requirements:
160
+ - - ">="
161
+ - !ruby/object:Gem::Version
162
+ version: '0'
163
+ requirements: []
164
+ rubyforge_project:
165
+ rubygems_version: 2.0.14
166
+ signing_key:
167
+ specification_version: 4
168
+ summary: guard-depend is useful for projects that produce build output like binaries.
169
+ guard-depend will only run the command you sify if the build output does not exists
170
+ or is not up to date with regard to the watched files.
171
+ test_files:
172
+ - spec/spec_helper.rb