rta 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +15 -0
  2. data/bin/rta +77 -0
  3. metadata +61 -0
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZTgwODRmZTc3ODgwZDY0MDhjODcwYTk2NDk0NzI3MDNmMmNkMWRmNg==
5
+ data.tar.gz: !binary |-
6
+ ZDEzMDgwMjFiMjA3OGNkZjQ0MDIxYmU2NTBjOWNmZjZkZGM3OTdmOQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ MjlmYjI5NjNhMWFmZmIwNWJiZjRhOTFlODYyZmM3ZGM4YmUwNGE4OGYwZDY5
10
+ YTFjMTE3NDcxZjIzNjc5MDI5ZjFiN2NjMjJkODdkYzE4MTFmZGU5ZTU4NWJh
11
+ MDM0NmNlMGNlMmRmOGQ1MjQ5ZGI2OWMzMjRiNzI1ZTFmMTQ5NTg=
12
+ data.tar.gz: !binary |-
13
+ OWM0Y2ZkNmUzYmM2ZjQzZTc4NWQzZmRhODkwYTAxZjk4ZjU0YWM1MmMyYTg4
14
+ OGVhY2EzMDcyMzkwMmIxYzUyNTRhMzk2YTZmMzg2ZTVjODM0OTcxYTQ5OTFj
15
+ ZTA2OWUxNzIxODAzZTUzZWI4M2Y4ZGZlOTlmNTViNjVjZTg4NDY=
data/bin/rta ADDED
@@ -0,0 +1,77 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ require 'rb-fsevent'
4
+ require 'optparse'
5
+
6
+ options = {}
7
+ excludes = []
8
+ includes = []
9
+ verbose = false
10
+
11
+ opts = OptionParser.new do |opts|
12
+ opts.banner = "Run a command when contents in this directory change.\nUsage: #{File.basename(__FILE__)} [-n|--no-clear] <command>"
13
+ opts.on("-n", "--[no-]clear", "Don't clear the screen before execution") do |n|
14
+ options[:no_clear] = n
15
+ end
16
+ opts.on("-v", "--[no-]verbose", "Be verbose in outputing match decisions") do |v|
17
+ verbose = v
18
+ end
19
+ opts.on("-i", "--include-dir DIRECTORY", "Watch the given directory for changes only. The value should be relative to the current working directory. Can be set multiple times.") do |d|
20
+ includes.push(File.expand_path(d, Dir.pwd) + "/")
21
+ end
22
+ opts.on("-e", "--exclude-dir DIRECTORY", "Ignore the given directory when its contents change. The value should be relative to the current working directory.") do |d|
23
+ excludes.push(File.expand_path(d, Dir.pwd) + "/")
24
+ end
25
+ opts.on_tail("-h", "--help", "Show help") do
26
+ puts opts
27
+ exit
28
+ end
29
+
30
+ end
31
+ opts.parse!
32
+
33
+ command = ARGV.join(" ")
34
+ if command == ""
35
+ $stderr.puts "no command specified :("
36
+ puts opts
37
+ exit 1
38
+ end
39
+
40
+ unless options[:no_clear]
41
+ command = "clear && #{command}"
42
+ end
43
+
44
+ fsevent = FSEvent.new
45
+ active = false
46
+ fsevent.watch Dir.pwd do |directories|
47
+ skip = true
48
+ directories.each do |d|
49
+ if excludes.include? d
50
+ puts "excluding #{d}" if verbose
51
+ else
52
+ skip = false
53
+ puts "#{excludes} does not contain #{d}" if verbose
54
+ end
55
+ end
56
+
57
+ directories.each do |d|
58
+ if includes.include? d
59
+ skip = false
60
+ puts "including #{d}" if verbose
61
+ else
62
+ puts "#{includes} does not contain #{d}" if verbose
63
+ end
64
+ end
65
+
66
+ if not active and not skip
67
+ active = true
68
+ Thread.new do
69
+ system command
70
+ active = false
71
+ end
72
+ elsif verbose
73
+ puts "did not execute - command is active" if active
74
+ puts "did not execute - command was skipped" if skip
75
+ end
76
+ end
77
+ fsevent.run
metadata ADDED
@@ -0,0 +1,61 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rta
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Anthony Bishopric
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rb-fsevent
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '0.9'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '0.9'
27
+ description: The rta command is kind of like "guard-lite". If you don't want to muck
28
+ with Guardfiles and need to configure the command you run, rta is for you!
29
+ email:
30
+ - gems@anthonybishopric.com
31
+ executables:
32
+ - rta
33
+ extensions: []
34
+ extra_rdoc_files: []
35
+ files:
36
+ - bin/rta
37
+ homepage: http://anthonybishopric.com/rta
38
+ licenses:
39
+ - MIT
40
+ metadata: {}
41
+ post_install_message:
42
+ rdoc_options: []
43
+ require_paths:
44
+ - lib
45
+ required_ruby_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ! '>='
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ required_rubygems_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ requirements: []
56
+ rubyforge_project:
57
+ rubygems_version: 2.2.2
58
+ signing_key:
59
+ specification_version: 4
60
+ summary: Run a script repeatedly when the working directory changes
61
+ test_files: []