space 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/space +6 -0
- data/lib/core_ext/string/deansi.rb +7 -0
- data/lib/core_ext/string/demodulize.rb +5 -0
- data/lib/space.rb +4 -4
- data/lib/space/action.rb +43 -0
- data/lib/space/action/builtin.rb +43 -0
- data/lib/space/action/development.rb +56 -0
- data/lib/space/{app → action}/handler.rb +17 -9
- data/lib/space/{app → action}/parser.rb +4 -7
- data/lib/space/app.rb +14 -30
- data/lib/space/events.rb +27 -20
- data/lib/space/events/sources.rb +34 -0
- data/lib/space/events/subscription.rb +23 -0
- data/lib/space/logger.rb +34 -0
- data/lib/space/model.rb +7 -0
- data/lib/space/{models → model}/project.rb +4 -10
- data/lib/space/{models → model}/project/bundler.rb +7 -8
- data/lib/space/model/project/bundler/config.rb +30 -0
- data/lib/space/model/repo.rb +38 -0
- data/lib/space/{models → model}/repo/bundle.rb +6 -7
- data/lib/space/{models → model}/repo/dependency.rb +1 -1
- data/lib/space/{models → model}/repo/git.rb +14 -16
- data/lib/space/{models → model}/repos.rb +18 -9
- data/lib/space/{models → model}/repos/collection.rb +1 -1
- data/lib/space/{models → model}/repos/scope.rb +1 -1
- data/lib/space/screen.rb +28 -11
- data/lib/space/screen/dashboard.rb +21 -5
- data/lib/space/screen/progress.rb +16 -5
- data/lib/space/screen/view.rb +2 -6
- data/lib/space/source.rb +51 -0
- data/lib/space/source/command.rb +70 -0
- data/lib/space/source/watch.rb +64 -0
- data/lib/space/source/watcher.rb +32 -0
- data/lib/space/version.rb +1 -1
- metadata +27 -24
- data/lib/space/app/command.rb +0 -45
- data/lib/space/app/command/builtin.rb +0 -43
- data/lib/space/app/command/development.rb +0 -60
- data/lib/space/app/logger.rb +0 -21
- data/lib/space/events/buffer.rb +0 -18
- data/lib/space/events/event.rb +0 -14
- data/lib/space/models.rb +0 -7
- data/lib/space/models/repo.rb +0 -57
- data/lib/space/shell.rb +0 -56
- data/lib/space/shell/command.rb +0 -63
- data/lib/space/shell/watch.rb +0 -50
- data/lib/space/shell/watcher.rb +0 -40
data/lib/space/app/logger.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'logger'
|
2
|
-
require 'fileutils'
|
3
|
-
|
4
|
-
module Space
|
5
|
-
class App
|
6
|
-
class Logger < ::Logger
|
7
|
-
def initialize
|
8
|
-
truncate
|
9
|
-
super('/tmp/space.log')
|
10
|
-
end
|
11
|
-
|
12
|
-
def truncate
|
13
|
-
File.open(filename, 'w+') { |f| f.write('-' * 80 + "\n") }
|
14
|
-
end
|
15
|
-
|
16
|
-
def filename
|
17
|
-
'/tmp/space.log'
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
data/lib/space/events/buffer.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
module Space
|
2
|
-
module Events
|
3
|
-
class Buffer < Array
|
4
|
-
def push(event)
|
5
|
-
# if any? { |e| e.source == event.source }
|
6
|
-
# App.logger.debug("REJECT event #{event.event.inspect} on #{event.source.class.name.split("\\n").last}")
|
7
|
-
# else
|
8
|
-
super
|
9
|
-
# end
|
10
|
-
end
|
11
|
-
|
12
|
-
def flush
|
13
|
-
each { |event| event.source.notify(*event) }
|
14
|
-
clear
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
data/lib/space/events/event.rb
DELETED
data/lib/space/models.rb
DELETED
data/lib/space/models/repo.rb
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
module Space
|
2
|
-
module Models
|
3
|
-
class Repo
|
4
|
-
autoload :Bundle, 'space/models/repo/bundle'
|
5
|
-
autoload :Dependency, 'space/models/repo/dependency'
|
6
|
-
autoload :Git, 'space/models/repo/git'
|
7
|
-
|
8
|
-
include Events
|
9
|
-
|
10
|
-
attr_reader :project, :path, :git, :bundle
|
11
|
-
|
12
|
-
def initialize(project, path)
|
13
|
-
@project = project
|
14
|
-
@path = File.expand_path(path)
|
15
|
-
@git = Git.new(self)
|
16
|
-
@bundle = Bundle.new(self, project.repos)
|
17
|
-
end
|
18
|
-
|
19
|
-
def name
|
20
|
-
@name ||= File.basename(path)
|
21
|
-
end
|
22
|
-
|
23
|
-
def number
|
24
|
-
@number ||= project.number(name)
|
25
|
-
end
|
26
|
-
|
27
|
-
def ref
|
28
|
-
git.commit
|
29
|
-
end
|
30
|
-
|
31
|
-
def deps
|
32
|
-
bundle.deps
|
33
|
-
end
|
34
|
-
|
35
|
-
def refresh
|
36
|
-
git.refresh
|
37
|
-
bundle.refresh
|
38
|
-
end
|
39
|
-
|
40
|
-
def execute(cmd)
|
41
|
-
chdir do
|
42
|
-
puts "in #{path}".ansi(:bold, :yellow)
|
43
|
-
system(cmd)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def chdir(&block)
|
48
|
-
Dir.chdir(path, &block)
|
49
|
-
end
|
50
|
-
|
51
|
-
def subscribe(*args)
|
52
|
-
super
|
53
|
-
[git, bundle].each { |object| object.subscribe(self) }
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
data/lib/space/shell.rb
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
module Space
|
2
|
-
module Shell
|
3
|
-
autoload :Command, 'space/shell/command'
|
4
|
-
autoload :Watch, 'space/shell/watch'
|
5
|
-
autoload :Watcher, 'space/shell/watcher'
|
6
|
-
|
7
|
-
module ClassMethods
|
8
|
-
def commands(commands = nil)
|
9
|
-
commands ? @commands = commands : @commands
|
10
|
-
end
|
11
|
-
|
12
|
-
def watch(*paths)
|
13
|
-
paths.empty? ? (@paths || []) : (@paths = paths)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
include Watcher
|
18
|
-
|
19
|
-
class << self
|
20
|
-
def included(base)
|
21
|
-
base.extend(ClassMethods)
|
22
|
-
end
|
23
|
-
|
24
|
-
def all
|
25
|
-
@all ||= []
|
26
|
-
end
|
27
|
-
|
28
|
-
def refresh
|
29
|
-
all.map(&:refresh)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
attr_reader :path
|
34
|
-
|
35
|
-
def initialize(path = '.')
|
36
|
-
@path = File.expand_path(path)
|
37
|
-
Shell.all << self
|
38
|
-
super
|
39
|
-
end
|
40
|
-
|
41
|
-
def result(command)
|
42
|
-
commands[command].result
|
43
|
-
end
|
44
|
-
|
45
|
-
def commands
|
46
|
-
@commands ||= self.class.commands.inject({}) do |commands, (key, command)|
|
47
|
-
commands.merge(key => Command.new(self, command))
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def refresh
|
52
|
-
commands.each { |key, command| command.run }
|
53
|
-
# notify(:refresh, self.class.name)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
data/lib/space/shell/command.rb
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
require 'ansi/code'
|
2
|
-
|
3
|
-
module Space
|
4
|
-
module Shell
|
5
|
-
class Command
|
6
|
-
class << self
|
7
|
-
def execute(command)
|
8
|
-
`#{command}`
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
attr_reader :context, :command, :result
|
13
|
-
|
14
|
-
def initialize(context, command)
|
15
|
-
@context = context
|
16
|
-
@command = command
|
17
|
-
end
|
18
|
-
|
19
|
-
def run
|
20
|
-
Watcher.suspend do
|
21
|
-
App.logger.debug "RUNNING #{command} [#{context.path}]"
|
22
|
-
notifying do
|
23
|
-
@result = chain.call
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
private
|
29
|
-
|
30
|
-
def notifying(&block)
|
31
|
-
old = result
|
32
|
-
yield.tap do |new|
|
33
|
-
notify unless old == new
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def notify
|
38
|
-
context.notify(command, result)
|
39
|
-
end
|
40
|
-
|
41
|
-
def chain
|
42
|
-
runner = -> { clean(self.class.execute(command)) }
|
43
|
-
filters.reverse.inject(runner) { |runner, filter| -> { filter.call(&runner) } }
|
44
|
-
end
|
45
|
-
|
46
|
-
def filters
|
47
|
-
[method(:chdir), ::Bundler.method(:with_clean_env) ]
|
48
|
-
end
|
49
|
-
|
50
|
-
def chdir(&block)
|
51
|
-
Dir.chdir(context.path) { |path| block.call }
|
52
|
-
end
|
53
|
-
|
54
|
-
def clean(string)
|
55
|
-
strip_ansi(string.chomp)
|
56
|
-
end
|
57
|
-
|
58
|
-
def strip_ansi(string)
|
59
|
-
string.gsub(ANSI::Code::PATTERN, '')
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
data/lib/space/shell/watch.rb
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
require 'rb-fsevent'
|
2
|
-
|
3
|
-
module Space
|
4
|
-
module Shell
|
5
|
-
class Watch
|
6
|
-
LATENCY = 0
|
7
|
-
NO_DEFER = FALSE
|
8
|
-
|
9
|
-
attr_reader :path, :callback, :mutex
|
10
|
-
|
11
|
-
def initialize(path, &block)
|
12
|
-
@path = File.expand_path(path)
|
13
|
-
@callback = block
|
14
|
-
@mutex = Mutex.new
|
15
|
-
self
|
16
|
-
end
|
17
|
-
|
18
|
-
def run
|
19
|
-
Thread.new do
|
20
|
-
App.logger.debug("WATCHING #{path}")
|
21
|
-
watch
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
def watch
|
28
|
-
fsevent.watch(path, file: file?, latency: LATENCY, no_defer: NO_DEFER) do |paths|
|
29
|
-
App.logger.debug("WATCH triggered: #{paths.inspect}")
|
30
|
-
fsevent.stop
|
31
|
-
mutex.synchronize do
|
32
|
-
callback.call(paths)
|
33
|
-
end
|
34
|
-
fsevent.run
|
35
|
-
end
|
36
|
-
fsevent.run
|
37
|
-
rescue Exception => e
|
38
|
-
puts e.message, e.backtrace
|
39
|
-
end
|
40
|
-
|
41
|
-
def file?
|
42
|
-
File.file?(path)
|
43
|
-
end
|
44
|
-
|
45
|
-
def fsevent
|
46
|
-
@fsevent ||= FSEvent.new
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
data/lib/space/shell/watcher.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
module Space
|
2
|
-
module Shell
|
3
|
-
module Watcher
|
4
|
-
class << self
|
5
|
-
def suspend
|
6
|
-
@suspended = true
|
7
|
-
yield.tap do
|
8
|
-
@suspended = false
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
def suspended?
|
13
|
-
!!@suspended
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def initialize(*args)
|
18
|
-
watch
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
def watch
|
24
|
-
targets.each do |path|
|
25
|
-
Watch.new(path, &method(:trigger)).run
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def trigger(paths)
|
30
|
-
refresh unless Watcher.suspended?
|
31
|
-
end
|
32
|
-
|
33
|
-
def targets
|
34
|
-
self.class.watch.map do |path|
|
35
|
-
path[0, 1] == '~' ? path : "#{self.path}/#{path}"
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|