beg 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +135 -0
- data/Guardfile +8 -0
- data/Rakefile +3 -0
- data/beg.gemspec +17 -0
- data/bin/beg +4 -0
- data/junk/inner +19 -0
- data/junk/outer +21 -0
- data/lib/beg.rb +38 -0
- data/test/beg_test.rb +49 -0
- data/test/test_helper.rb +3 -0
- metadata +93 -0
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
*.gem
|
data/Gemfile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
source :rubygems
|
2
|
+
group :development do
|
3
|
+
gem 'minitest'
|
4
|
+
gem 'pry', github: 'pry'
|
5
|
+
gem 'pry-de' # Pull in pry-full plus a few choice bits. More to come
|
6
|
+
gem 'guard'
|
7
|
+
gem 'guard-minitest'
|
8
|
+
gem 'rb-inotify', require: false # No harm when installed on OS X
|
9
|
+
gem 'rb-fsevent', require: false # No harm when installed on Linux!
|
10
|
+
gem 'turn'
|
11
|
+
gem 'rake'
|
12
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
GIT
|
2
|
+
remote: git://github.com/pry/pry.git
|
3
|
+
revision: 14f7f86b8bff218f6a8b13c801b07ffb485648cb
|
4
|
+
specs:
|
5
|
+
pry (0.9.11)
|
6
|
+
coderay (~> 1.0.5)
|
7
|
+
method_source (~> 0.8)
|
8
|
+
slop (~> 3.3.1)
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: http://rubygems.org/
|
12
|
+
specs:
|
13
|
+
ansi (1.4.3)
|
14
|
+
awesome_print (1.1.0)
|
15
|
+
binding_of_caller (0.6.8)
|
16
|
+
bond (0.4.2)
|
17
|
+
coderay (1.0.8)
|
18
|
+
columnize (0.3.6)
|
19
|
+
debugger (1.1.4)
|
20
|
+
columnize (>= 0.3.1)
|
21
|
+
debugger-linecache (~> 1.1.1)
|
22
|
+
debugger-ruby_core_source (~> 1.1.3)
|
23
|
+
debugger-linecache (1.1.2)
|
24
|
+
debugger-ruby_core_source (>= 1.1.1)
|
25
|
+
debugger-ruby_core_source (1.1.4)
|
26
|
+
diff-lcs (1.1.3)
|
27
|
+
diffy (2.1.0)
|
28
|
+
eventmachine (1.0.0)
|
29
|
+
ffi (1.1.5)
|
30
|
+
grit (2.5.0)
|
31
|
+
diff-lcs (~> 1.1)
|
32
|
+
mime-types (~> 1.15)
|
33
|
+
posix-spawn (~> 0.3.6)
|
34
|
+
guard (1.5.3)
|
35
|
+
listen (>= 0.4.2)
|
36
|
+
lumberjack (>= 1.0.2)
|
37
|
+
pry (>= 0.9.10)
|
38
|
+
thor (>= 0.14.6)
|
39
|
+
guard-minitest (0.5.0)
|
40
|
+
guard (>= 0.4)
|
41
|
+
highline (1.6.15)
|
42
|
+
interception (0.3)
|
43
|
+
jist (1.1.0)
|
44
|
+
json
|
45
|
+
json (1.7.5)
|
46
|
+
listen (0.5.3)
|
47
|
+
lumberjack (1.0.2)
|
48
|
+
method_source (0.8.1)
|
49
|
+
mime-types (1.19)
|
50
|
+
minitest (4.2.0)
|
51
|
+
nokogiri (1.5.5)
|
52
|
+
plymouth (0.3.3)
|
53
|
+
pry-exception_explorer (~> 0.1.7)
|
54
|
+
posix-spawn (0.3.6)
|
55
|
+
pry-awesome_print (9.6.5)
|
56
|
+
awesome_print (~> 1.1.0)
|
57
|
+
pry-de (0.0.4)
|
58
|
+
guard
|
59
|
+
pry-full
|
60
|
+
pry-debugger (0.2.0)
|
61
|
+
debugger (~> 1.1.3)
|
62
|
+
pry (~> 0.9.9)
|
63
|
+
pry-developer_tools (0.1.1)
|
64
|
+
pry (>= 0.9.8.pre, < 0.11)
|
65
|
+
pry-doc (0.4.4)
|
66
|
+
pry (>= 0.9.9.6)
|
67
|
+
yard (~> 0.8.1)
|
68
|
+
pry-editline (1.1.1)
|
69
|
+
pry-exception_explorer (0.1.9)
|
70
|
+
pry-stack_explorer (>= 0.3.9)
|
71
|
+
pry-full (0.6)
|
72
|
+
bond
|
73
|
+
jist
|
74
|
+
plymouth
|
75
|
+
pry-awesome_print
|
76
|
+
pry-debugger
|
77
|
+
pry-developer_tools
|
78
|
+
pry-doc
|
79
|
+
pry-editline
|
80
|
+
pry-exception_explorer
|
81
|
+
pry-git
|
82
|
+
pry-highlight
|
83
|
+
pry-pretty-numeric
|
84
|
+
pry-remote-em
|
85
|
+
pry-rescue
|
86
|
+
pry-stack_explorer
|
87
|
+
pry-syntax-hacks
|
88
|
+
pry-theme
|
89
|
+
pry-git (0.2.3)
|
90
|
+
diffy
|
91
|
+
grit
|
92
|
+
pry (>= 0.9.8)
|
93
|
+
pry-highlight (0.0.1)
|
94
|
+
coderay
|
95
|
+
json
|
96
|
+
nokogiri
|
97
|
+
pry
|
98
|
+
pry-pretty-numeric (0.1.1)
|
99
|
+
pry
|
100
|
+
pry-remote-em (0.7.3)
|
101
|
+
eventmachine
|
102
|
+
highline
|
103
|
+
pry (~> 0.9)
|
104
|
+
pry-rescue (0.13.pre.4)
|
105
|
+
interception (>= 0.3)
|
106
|
+
pry
|
107
|
+
pry-stack_explorer (0.4.7)
|
108
|
+
binding_of_caller (~> 0.6.8)
|
109
|
+
pry-syntax-hacks (0.0.6)
|
110
|
+
pry (>= 0.9.8)
|
111
|
+
pry-theme (0.1.3)
|
112
|
+
json
|
113
|
+
rake (0.9.2.2)
|
114
|
+
rb-fsevent (0.9.2)
|
115
|
+
rb-inotify (0.8.8)
|
116
|
+
ffi (>= 0.5.0)
|
117
|
+
slop (3.3.3)
|
118
|
+
thor (0.16.0)
|
119
|
+
turn (0.9.6)
|
120
|
+
ansi
|
121
|
+
yard (0.8.3)
|
122
|
+
|
123
|
+
PLATFORMS
|
124
|
+
ruby
|
125
|
+
|
126
|
+
DEPENDENCIES
|
127
|
+
guard
|
128
|
+
guard-minitest
|
129
|
+
minitest
|
130
|
+
pry!
|
131
|
+
pry-de
|
132
|
+
rake
|
133
|
+
rb-fsevent
|
134
|
+
rb-inotify
|
135
|
+
turn
|
data/Guardfile
ADDED
data/Rakefile
ADDED
data/beg.gemspec
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
Gem::Specification.new do |gem|
|
3
|
+
gem.name = 'beg'
|
4
|
+
gem.homepage = 'http://github.com/rking/beg'
|
5
|
+
gem.summary = "'bundle exec guard' plus bonus features (mostly TΟDO)"
|
6
|
+
gem.description = 'Run a guard-like loop without a Guardfile'
|
7
|
+
gem.version = '0.0.1'
|
8
|
+
gem.license = 'CC0'
|
9
|
+
gem.email = 'beg@sharpsaw.org'
|
10
|
+
gem.authors = %w(☈king)
|
11
|
+
|
12
|
+
gem.files = `git ls-files`.split $/
|
13
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename f }
|
14
|
+
gem.test_files = gem.files.grep %r{^(test|spec|features)/}
|
15
|
+
gem.require_paths = %w(lib)
|
16
|
+
%w(pry-de guard).each do |dep| gem.add_dependency dep end
|
17
|
+
end
|
data/bin/beg
ADDED
data/junk/inner
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
alias actual_puts puts
|
4
|
+
def puts line
|
5
|
+
actual_puts "[Child pid: #$$ pgrp: #{Process.getpgrp}] #{line}"
|
6
|
+
end
|
7
|
+
# Heh, these may try to write an fd they can't write.
|
8
|
+
# trap :TTOU do puts 'TTOU' end
|
9
|
+
# trap :TTIN do puts 'TTOU' end
|
10
|
+
$stdin = open '/dev/tty'
|
11
|
+
fail unless $stdin
|
12
|
+
require 'termios'
|
13
|
+
p [ :getpgrp, Process.getpgrp, :pid, $$ ]
|
14
|
+
r = Termios.tcsetpgrp $stdin, Process.getpgrp
|
15
|
+
p [ :r, r ]
|
16
|
+
p [ :tcgetpgrp, Termios.tcgetpgrp($stdin) ]
|
17
|
+
puts "Now hit ^j, ^c or ^z…"
|
18
|
+
x = $stdin.readline
|
19
|
+
puts "Got #{x}"
|
data/junk/outer
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
alias actual_puts puts
|
3
|
+
def puts line
|
4
|
+
actual_puts "[Parent] #{line}"
|
5
|
+
end
|
6
|
+
trap :CHLD do
|
7
|
+
puts '(SIGCHLD)'
|
8
|
+
end
|
9
|
+
|
10
|
+
trap :TSTP do
|
11
|
+
puts 'Odd. (SIGTSTP)'
|
12
|
+
end
|
13
|
+
|
14
|
+
puts 'Expecting the next command to be controllable from here.'
|
15
|
+
kid_pid = spawn './inner', pgroup: true, in: __FILE__
|
16
|
+
puts 'After spawn'
|
17
|
+
$stdin.close
|
18
|
+
|
19
|
+
Process.wait kid_pid
|
20
|
+
puts $stdin.readline
|
21
|
+
puts 'At last line of "outer"'
|
data/lib/beg.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
class Beg
|
2
|
+
attr_accessor :argv
|
3
|
+
|
4
|
+
def self.cli argv
|
5
|
+
Beg.new(argv).run
|
6
|
+
end
|
7
|
+
|
8
|
+
def initialize argv = []; @argv = argv end
|
9
|
+
|
10
|
+
def run
|
11
|
+
if File.exists? 'Guardfile'
|
12
|
+
run_with_guardfile
|
13
|
+
else
|
14
|
+
run_poor_man_style
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def run_with_guardfile
|
19
|
+
verbose_system %w(bundle exec guard) + @argv
|
20
|
+
end
|
21
|
+
|
22
|
+
def run_poor_man_style
|
23
|
+
loop do
|
24
|
+
verbose_system ['inotifywait'] + Dir.glob('**/*.rb')
|
25
|
+
verbose_system %w(bundle exec rake test)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def verbose_system cmd
|
30
|
+
str = color 36, cmd.join(' ')
|
31
|
+
puts "Running: " + str
|
32
|
+
system *cmd
|
33
|
+
end
|
34
|
+
|
35
|
+
def color num, str
|
36
|
+
"\e[%dm%s\e[0m" % [num, str]
|
37
|
+
end
|
38
|
+
end
|
data/test/beg_test.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'beg'
|
3
|
+
|
4
|
+
class BegTest < MiniTest::Unit::TestCase
|
5
|
+
def with_fake_system_interaction returns
|
6
|
+
beg = Beg.new
|
7
|
+
def beg.loop; yield end # Just go through once, thanks. ☺
|
8
|
+
calls = { verbose_system: [], dir_glob: [] }
|
9
|
+
beg.stub :verbose_system, -> *args {
|
10
|
+
calls[:verbose_system] << args
|
11
|
+
} do
|
12
|
+
File.stub :exists?, -> *arg {
|
13
|
+
calls[:file_exists] = arg
|
14
|
+
r = returns[:file_exists]
|
15
|
+
returns[:file_exists][arg[0]]
|
16
|
+
} do
|
17
|
+
Dir.stub :glob, -> *args {
|
18
|
+
calls[:dir_glob] << args
|
19
|
+
returns[:dir_glob]
|
20
|
+
} do
|
21
|
+
yield beg
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
calls
|
26
|
+
end
|
27
|
+
def test_poor_mans
|
28
|
+
calls = with_fake_system_interaction \
|
29
|
+
file_exists: {'Guardfile' => false},
|
30
|
+
dir_glob: ['lib/foo.rb'] do |beg|
|
31
|
+
beg.run
|
32
|
+
end
|
33
|
+
watch_cmd, test_cmd = calls[:verbose_system]
|
34
|
+
assert_equal 'Guardfile', calls[:file_exists][0]
|
35
|
+
assert_equal [%w(inotifywait lib/foo.rb)], watch_cmd
|
36
|
+
assert_equal [%w(bundle exec rake test)], test_cmd
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_with_guardfile
|
40
|
+
calls = with_fake_system_interaction \
|
41
|
+
file_exists: {'Guardfile' => true} do |beg|
|
42
|
+
beg.argv = ['--someflag']
|
43
|
+
beg.run
|
44
|
+
end
|
45
|
+
watch_cmd, test_cmd = calls[:verbose_system]
|
46
|
+
assert_equal 'Guardfile', calls[:file_exists][0]
|
47
|
+
assert_equal [%w(bundle exec guard --someflag)], calls[:verbose_system][0]
|
48
|
+
end
|
49
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: beg
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- ☈king
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-12-06 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: pry-de
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: guard
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: Run a guard-like loop without a Guardfile
|
47
|
+
email: beg@sharpsaw.org
|
48
|
+
executables:
|
49
|
+
- beg
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- .gitignore
|
54
|
+
- Gemfile
|
55
|
+
- Gemfile.lock
|
56
|
+
- Guardfile
|
57
|
+
- Rakefile
|
58
|
+
- beg.gemspec
|
59
|
+
- bin/beg
|
60
|
+
- junk/inner
|
61
|
+
- junk/outer
|
62
|
+
- lib/beg.rb
|
63
|
+
- test/beg_test.rb
|
64
|
+
- test/test_helper.rb
|
65
|
+
homepage: http://github.com/rking/beg
|
66
|
+
licenses:
|
67
|
+
- CC0
|
68
|
+
post_install_message:
|
69
|
+
rdoc_options: []
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
none: false
|
80
|
+
requirements:
|
81
|
+
- - ! '>='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
requirements: []
|
85
|
+
rubyforge_project:
|
86
|
+
rubygems_version: 1.8.24
|
87
|
+
signing_key:
|
88
|
+
specification_version: 3
|
89
|
+
summary: ! '''bundle exec guard'' plus bonus features (mostly TΟDO)'
|
90
|
+
test_files:
|
91
|
+
- test/beg_test.rb
|
92
|
+
- test/test_helper.rb
|
93
|
+
has_rdoc:
|