space 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -0
- data/Gemfile.lock +17 -2
- data/Guardfile +5 -0
- data/README.md +4 -0
- data/Rakefile +1 -1
- data/bin/space +2 -1
- data/lib/core_ext/{enumerable.rb → enumerable/map_slice.rb} +2 -7
- data/lib/core_ext/{string.rb → string/wrap.rb} +1 -2
- data/lib/space.rb +6 -16
- data/lib/space/app.rb +36 -48
- data/lib/space/app/command.rb +45 -0
- data/lib/space/app/command/builtin.rb +43 -0
- data/lib/space/app/command/development.rb +60 -0
- data/lib/space/app/handler.rb +47 -0
- data/lib/space/app/logger.rb +21 -0
- data/lib/space/{action → app}/parser.rb +3 -2
- data/lib/space/config.rb +14 -6
- data/lib/space/events.rb +34 -0
- data/lib/space/events/buffer.rb +18 -0
- data/lib/space/events/event.rb +14 -0
- data/lib/space/helpers.rb +30 -15
- data/lib/space/models.rb +7 -0
- data/lib/space/models/project.rb +48 -0
- data/lib/space/models/project/bundler.rb +30 -0
- data/lib/space/models/repo.rb +46 -29
- data/lib/space/models/repo/bundle.rb +39 -0
- data/lib/space/models/repo/dependency.rb +22 -0
- data/lib/space/models/repo/git.rb +52 -0
- data/lib/space/models/repos.rb +31 -26
- data/lib/space/models/repos/collection.rb +26 -0
- data/lib/space/models/repos/scope.rb +18 -0
- data/lib/space/screen.rb +19 -15
- data/lib/space/screen/dashboard.rb +28 -0
- data/lib/space/screen/progress.rb +15 -0
- data/lib/space/screen/view.rb +43 -0
- data/lib/space/shell.rb +56 -0
- data/lib/space/shell/command.rb +63 -0
- data/lib/space/shell/watch.rb +50 -0
- data/lib/space/shell/watcher.rb +40 -0
- data/lib/space/templates/{project.erb → header.erb} +0 -1
- data/lib/space/templates/{repository.erb → repo.erb} +1 -1
- data/lib/space/tmux.rb +11 -0
- data/lib/space/version.rb +1 -1
- metadata +33 -15
- data/lib/space/action.rb +0 -84
- data/lib/space/models/bundle.rb +0 -44
- data/lib/space/models/command.rb +0 -28
- data/lib/space/models/commands.rb +0 -23
- data/lib/space/models/dependency.rb +0 -18
- data/lib/space/models/git.rb +0 -23
- data/lib/space/view.rb +0 -25
@@ -0,0 +1,40 @@
|
|
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
|
data/lib/space/tmux.rb
ADDED
data/lib/space/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: space
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-04-07 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: space.
|
15
15
|
email:
|
@@ -19,28 +19,46 @@ executables:
|
|
19
19
|
extensions: []
|
20
20
|
extra_rdoc_files: []
|
21
21
|
files:
|
22
|
-
- lib/core_ext/enumerable.rb
|
23
|
-
- lib/core_ext/string.rb
|
24
|
-
- lib/space/
|
25
|
-
- lib/space/
|
22
|
+
- lib/core_ext/enumerable/map_slice.rb
|
23
|
+
- lib/core_ext/string/wrap.rb
|
24
|
+
- lib/space/app/command/builtin.rb
|
25
|
+
- lib/space/app/command/development.rb
|
26
|
+
- lib/space/app/command.rb
|
27
|
+
- lib/space/app/handler.rb
|
28
|
+
- lib/space/app/logger.rb
|
29
|
+
- lib/space/app/parser.rb
|
26
30
|
- lib/space/app.rb
|
27
31
|
- lib/space/config.rb
|
32
|
+
- lib/space/events/buffer.rb
|
33
|
+
- lib/space/events/event.rb
|
34
|
+
- lib/space/events.rb
|
28
35
|
- lib/space/helpers.rb
|
29
|
-
- lib/space/models/
|
30
|
-
- lib/space/models/
|
31
|
-
- lib/space/models/
|
32
|
-
- lib/space/models/dependency.rb
|
33
|
-
- lib/space/models/git.rb
|
36
|
+
- lib/space/models/project/bundler.rb
|
37
|
+
- lib/space/models/project.rb
|
38
|
+
- lib/space/models/repo/bundle.rb
|
39
|
+
- lib/space/models/repo/dependency.rb
|
40
|
+
- lib/space/models/repo/git.rb
|
34
41
|
- lib/space/models/repo.rb
|
42
|
+
- lib/space/models/repos/collection.rb
|
43
|
+
- lib/space/models/repos/scope.rb
|
35
44
|
- lib/space/models/repos.rb
|
45
|
+
- lib/space/models.rb
|
46
|
+
- lib/space/screen/dashboard.rb
|
47
|
+
- lib/space/screen/progress.rb
|
48
|
+
- lib/space/screen/view.rb
|
36
49
|
- lib/space/screen.rb
|
37
|
-
- lib/space/
|
38
|
-
- lib/space/
|
50
|
+
- lib/space/shell/command.rb
|
51
|
+
- lib/space/shell/watch.rb
|
52
|
+
- lib/space/shell/watcher.rb
|
53
|
+
- lib/space/shell.rb
|
54
|
+
- lib/space/templates/header.erb
|
55
|
+
- lib/space/templates/repo.erb
|
56
|
+
- lib/space/tmux.rb
|
39
57
|
- lib/space/version.rb
|
40
|
-
- lib/space/view.rb
|
41
58
|
- lib/space.rb
|
42
59
|
- Gemfile
|
43
60
|
- Gemfile.lock
|
61
|
+
- Guardfile
|
44
62
|
- LICENSE
|
45
63
|
- Rakefile
|
46
64
|
- README.md
|
@@ -66,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
66
84
|
version: '0'
|
67
85
|
requirements: []
|
68
86
|
rubyforge_project: ! '[none]'
|
69
|
-
rubygems_version: 1.8.
|
87
|
+
rubygems_version: 1.8.11
|
70
88
|
signing_key:
|
71
89
|
specification_version: 3
|
72
90
|
summary: space
|
data/lib/space/action.rb
DELETED
@@ -1,84 +0,0 @@
|
|
1
|
-
module Space
|
2
|
-
class Action
|
3
|
-
autoload :Parser, 'space/action/parser'
|
4
|
-
|
5
|
-
class << self
|
6
|
-
def run(app, line)
|
7
|
-
new(app, *Parser.new(app.repos.names).parse(line)).run
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
attr_reader :app, :repos, :command, :args
|
12
|
-
|
13
|
-
def initialize(app, repos, command, *args)
|
14
|
-
@app = app
|
15
|
-
@repos = Repos.select(repos) if repos
|
16
|
-
@command = normalize(command)
|
17
|
-
@args = args
|
18
|
-
end
|
19
|
-
|
20
|
-
def run
|
21
|
-
if respond_to?(command)
|
22
|
-
send(command)
|
23
|
-
elsif command
|
24
|
-
execute(command)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def reload
|
29
|
-
app.bundle.reset
|
30
|
-
run_scoped(true) do |repo|
|
31
|
-
repo.reset
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def scope
|
36
|
-
app.repos = repos
|
37
|
-
end
|
38
|
-
|
39
|
-
def unscope
|
40
|
-
app.repos = nil
|
41
|
-
end
|
42
|
-
|
43
|
-
def local
|
44
|
-
run_scoped do |repo|
|
45
|
-
system "bundle config --global local.#{repo.name} #{repo.path}"
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def remote
|
50
|
-
run_scoped do |repo|
|
51
|
-
system "bundle config --delete local.#{repo.name}"
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def execute(cmd)
|
56
|
-
run_scoped do |repo|
|
57
|
-
puts
|
58
|
-
repo.execute(cmd)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
def run_scoped(reloading = false)
|
63
|
-
(repos || app.repos).each { |repo| yield repo }
|
64
|
-
confirm && reload unless reloading
|
65
|
-
end
|
66
|
-
|
67
|
-
def system(cmd)
|
68
|
-
puts cmd
|
69
|
-
super
|
70
|
-
end
|
71
|
-
|
72
|
-
def confirm
|
73
|
-
puts "\n--- hit any key to continue ---\n"
|
74
|
-
STDIN.getc
|
75
|
-
end
|
76
|
-
|
77
|
-
def normalize(command)
|
78
|
-
command = (command || '').strip
|
79
|
-
command = 'unscope' if command == '-'
|
80
|
-
command = 'scope' if command.empty?
|
81
|
-
command
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
data/lib/space/models/bundle.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
module Space
|
2
|
-
class Bundle
|
3
|
-
include Commands
|
4
|
-
|
5
|
-
COMMANDS = {
|
6
|
-
:check => 'bundle check',
|
7
|
-
:list => 'bundle list',
|
8
|
-
:config => 'bundle config'
|
9
|
-
}
|
10
|
-
|
11
|
-
def initialize(path)
|
12
|
-
super(path)
|
13
|
-
end
|
14
|
-
|
15
|
-
def clean?
|
16
|
-
info =~ /dependencies are satisfied/
|
17
|
-
end
|
18
|
-
|
19
|
-
def info
|
20
|
-
result(:check).split("\n").first
|
21
|
-
end
|
22
|
-
|
23
|
-
def deps
|
24
|
-
result(:list).split("\n").map do |dep|
|
25
|
-
dep =~ /(#{App.name}.*) \(\d\.\d\.\d (.+)\)/
|
26
|
-
Dependency.new($1, $2) if Repos.names.include?($1)
|
27
|
-
end.compact
|
28
|
-
end
|
29
|
-
|
30
|
-
def local_repos
|
31
|
-
config.keys.map do |key|
|
32
|
-
key =~ /^local\.(.+)$/ && $1
|
33
|
-
end.compact
|
34
|
-
end
|
35
|
-
|
36
|
-
def config
|
37
|
-
lines = result(:config).split("\n")[2..-1]
|
38
|
-
values = lines.map_slice(3) do |name, value, _|
|
39
|
-
[name, value =~ /: "(.*)"/ && $1]
|
40
|
-
end
|
41
|
-
Hash[*values.compact.flatten]
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
data/lib/space/models/command.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'ansi/code'
|
2
|
-
|
3
|
-
module Space
|
4
|
-
class Command
|
5
|
-
attr_reader :path, :command
|
6
|
-
|
7
|
-
def initialize(path, command)
|
8
|
-
@path = File.expand_path(path)
|
9
|
-
@command = command
|
10
|
-
end
|
11
|
-
|
12
|
-
def result
|
13
|
-
@result ||= chdir { strip_ansi(`#{command}`) }
|
14
|
-
end
|
15
|
-
|
16
|
-
def reset
|
17
|
-
@result = nil
|
18
|
-
end
|
19
|
-
|
20
|
-
def chdir(&block)
|
21
|
-
Dir.chdir(path, &block)
|
22
|
-
end
|
23
|
-
|
24
|
-
def strip_ansi(string)
|
25
|
-
string.gsub(ANSI::Code::PATTERN, '')
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module Space
|
2
|
-
module Commands
|
3
|
-
attr_reader :path
|
4
|
-
|
5
|
-
def initialize(path)
|
6
|
-
@path = path
|
7
|
-
end
|
8
|
-
|
9
|
-
def result(command)
|
10
|
-
commands[command].result
|
11
|
-
end
|
12
|
-
|
13
|
-
def commands
|
14
|
-
@commands ||= Hash[*self.class::COMMANDS.map do |key, cmd|
|
15
|
-
[key, Command.new(path, cmd)]
|
16
|
-
end.flatten]
|
17
|
-
end
|
18
|
-
|
19
|
-
def reset
|
20
|
-
commands.each { |key, command| command.reset }
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
data/lib/space/models/git.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
module Space
|
2
|
-
class Git
|
3
|
-
include Commands
|
4
|
-
|
5
|
-
COMMANDS = {
|
6
|
-
:status => 'git status -s',
|
7
|
-
:branch => 'git branch --no-color',
|
8
|
-
:commit => 'git log -1 head'
|
9
|
-
}
|
10
|
-
|
11
|
-
def clean?
|
12
|
-
result(:status).empty?
|
13
|
-
end
|
14
|
-
|
15
|
-
def branch
|
16
|
-
result(:branch) =~ /^\* (.+)/ && $1.strip
|
17
|
-
end
|
18
|
-
|
19
|
-
def commit
|
20
|
-
result(:commit) =~ /^commit (\S{7})/ && $1
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
data/lib/space/view.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'erb'
|
2
|
-
|
3
|
-
module Space
|
4
|
-
class View
|
5
|
-
include Helpers
|
6
|
-
|
7
|
-
def template_name
|
8
|
-
self.class.name.downcase.split('::').last
|
9
|
-
end
|
10
|
-
|
11
|
-
def render(name, assigns)
|
12
|
-
assigns.each { |name, value| assign(name, value) }
|
13
|
-
template(name).result(binding)
|
14
|
-
end
|
15
|
-
|
16
|
-
def assign(key, value)
|
17
|
-
instance_variable_set(:"@#{key}", value)
|
18
|
-
(class << self; self; end).send(:attr_reader, key)
|
19
|
-
end
|
20
|
-
|
21
|
-
def template(name)
|
22
|
-
ERB.new(File.read(TEMPLATES[name.to_sym]), nil, '%<>-')
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|