guard-post 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +77 -0
- data/lib/guard/post.rb +58 -0
- data/lib/guard/post/templates/Guardfile +3 -0
- data/lib/guard/post/version.rb +5 -0
- metadata +57 -0
data/Rakefile
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require "rake/rdoctask"
|
3
|
+
require 'rake/gempackagetask'
|
4
|
+
|
5
|
+
spec = Gem::Specification.new do |s|
|
6
|
+
s.name = "guard-post"
|
7
|
+
s.authors = ["Lance Pollard"]
|
8
|
+
s.version = "0.5.0"
|
9
|
+
s.summary = "Watch documents update, save them to MongoDB, MySQL, etc."
|
10
|
+
s.description = "Watch documents update, save them to MongoDB, MySQL, etc."
|
11
|
+
s.homepage = "http://github.com/viatropos/guard-post"
|
12
|
+
s.license = "MIT"
|
13
|
+
s.email = "lancejpollard@gmail.com"
|
14
|
+
s.rubyforge_project = "guard-post"
|
15
|
+
s.platform = Gem::Platform::RUBY
|
16
|
+
s.files = %w(Rakefile) + Dir["{lib}/**/*"]
|
17
|
+
s.require_path = "lib"
|
18
|
+
end
|
19
|
+
|
20
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
21
|
+
pkg.gem_spec = spec
|
22
|
+
end
|
23
|
+
|
24
|
+
desc 'run unit tests'
|
25
|
+
task :test do
|
26
|
+
Dir["test/**/*"].each do |file|
|
27
|
+
next unless File.basename(file) =~ /test_/
|
28
|
+
next unless File.extname(file) == ".rb"
|
29
|
+
system "ruby #{file}"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
desc "Create .gemspec file (useful for github)"
|
34
|
+
task :gemspec do
|
35
|
+
File.open("#{spec.name}.gemspec", "w") do |f|
|
36
|
+
f.puts spec.to_ruby
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
desc "Build the gem into the current directory"
|
41
|
+
task :gem => :gemspec do
|
42
|
+
`gem build #{spec.name}.gemspec`
|
43
|
+
end
|
44
|
+
|
45
|
+
desc "Publish gem to rubygems"
|
46
|
+
task :publish => [:package] do
|
47
|
+
%x[gem push #{spec.name}-#{spec.version}.gem]
|
48
|
+
end
|
49
|
+
|
50
|
+
desc "Print a list of the files to be put into the gem"
|
51
|
+
task :manifest do
|
52
|
+
File.open("Manifest", "w") do |f|
|
53
|
+
spec.files.each do |file|
|
54
|
+
f.puts file
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
desc "Install the gem locally"
|
60
|
+
task :install => [:package] do
|
61
|
+
File.mkdir("pkg") unless File.exists?("pkg")
|
62
|
+
command = "gem install pkg/#{spec.name}-#{spec.version} --no-ri --no-rdoc"
|
63
|
+
command = "sudo #{command}" if ENV["SUDO"] == true
|
64
|
+
sh %{#{command}}
|
65
|
+
end
|
66
|
+
|
67
|
+
desc "Generate the rdoc"
|
68
|
+
Rake::RDocTask.new do |rdoc|
|
69
|
+
files = ["README.md", "lib/**/*.rb"]
|
70
|
+
rdoc.rdoc_files.add(files)
|
71
|
+
rdoc.main = "README.md"
|
72
|
+
rdoc.title = spec.summary
|
73
|
+
end
|
74
|
+
|
75
|
+
task :yank do
|
76
|
+
`gem yank #{spec.name} -v #{spec.version}`
|
77
|
+
end
|
data/lib/guard/post.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'guard'
|
2
|
+
require 'guard/guard'
|
3
|
+
require 'guard/watcher'
|
4
|
+
|
5
|
+
module ::Guard
|
6
|
+
class Post < ::Guard::Guard
|
7
|
+
def initialize(watchers = [], options = {}, &block)
|
8
|
+
super
|
9
|
+
@options = {
|
10
|
+
:all_on_start => true,
|
11
|
+
:rails => false
|
12
|
+
}.update(options)
|
13
|
+
end
|
14
|
+
|
15
|
+
def start
|
16
|
+
if @options[:rails] == true
|
17
|
+
::Guard::UI.info "-> Loading Rails...", :reset => true
|
18
|
+
require File.expand_path("../config/environment", __FILE__)
|
19
|
+
::Guard::UI.info "-> Loaded Rails '#{Rails.env.to_s}' environment", :reset => true
|
20
|
+
end
|
21
|
+
true
|
22
|
+
end
|
23
|
+
|
24
|
+
def run_all
|
25
|
+
run_on_change(Watcher.match_files(self, Dir.glob(File.join('**', '*.*'))))
|
26
|
+
end
|
27
|
+
|
28
|
+
def run_on_change(paths)
|
29
|
+
trap("SIGINT") { exit! }
|
30
|
+
changed_files = paths.reject { |f| ignored?(f) }.map do |file|
|
31
|
+
begin
|
32
|
+
expanded = ::File.expand_path(file)
|
33
|
+
::Guard::UI.info "-> updating '#{file}'...", :reset => true
|
34
|
+
update_file(file)
|
35
|
+
::Guard::UI.info "-> updated '#{file}'", :reset => true
|
36
|
+
file
|
37
|
+
rescue Exception => e
|
38
|
+
puts e.backtrace.join("\n")
|
39
|
+
puts e.inspect
|
40
|
+
end
|
41
|
+
file
|
42
|
+
end.compact
|
43
|
+
end
|
44
|
+
|
45
|
+
def update_file(file)
|
46
|
+
case @options[:update]
|
47
|
+
when ::Symbol
|
48
|
+
Object.send(@options[:update], file)
|
49
|
+
else
|
50
|
+
@options[:update].call(file)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def ignored?(path)
|
55
|
+
File.basename(path)[0] == "_"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
metadata
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: guard-post
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.5.0
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Lance Pollard
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-09-19 00:00:00 Z
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Watch documents update, save them to MongoDB, MySQL, etc.
|
17
|
+
email: lancejpollard@gmail.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- Rakefile
|
26
|
+
- lib/guard/post/templates/Guardfile
|
27
|
+
- lib/guard/post/version.rb
|
28
|
+
- lib/guard/post.rb
|
29
|
+
homepage: http://github.com/viatropos/guard-post
|
30
|
+
licenses:
|
31
|
+
- MIT
|
32
|
+
post_install_message:
|
33
|
+
rdoc_options: []
|
34
|
+
|
35
|
+
require_paths:
|
36
|
+
- lib
|
37
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: "0"
|
43
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
44
|
+
none: false
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: "0"
|
49
|
+
requirements: []
|
50
|
+
|
51
|
+
rubyforge_project: guard-post
|
52
|
+
rubygems_version: 1.8.10
|
53
|
+
signing_key:
|
54
|
+
specification_version: 3
|
55
|
+
summary: Watch documents update, save them to MongoDB, MySQL, etc.
|
56
|
+
test_files: []
|
57
|
+
|