space 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,9 +1,21 @@
|
|
1
|
+
GIT
|
2
|
+
remote: git://github.com/niw/rb-fsevent.git
|
3
|
+
revision: 8754b16bd3b880a60621e01b0f7792c009c8e8a7
|
4
|
+
specs:
|
5
|
+
rb-fsevent (0.4.3)
|
6
|
+
|
1
7
|
GEM
|
2
8
|
remote: http://rubygems.org/
|
3
9
|
specs:
|
4
10
|
ansi (1.4.2)
|
5
11
|
diff-lcs (1.1.3)
|
6
|
-
|
12
|
+
ffi (1.0.11)
|
13
|
+
guard (1.0.1)
|
14
|
+
ffi (>= 0.5.0)
|
15
|
+
thor (~> 0.14.6)
|
16
|
+
guard-rspec (0.7.0)
|
17
|
+
guard (>= 0.10.0)
|
18
|
+
hashr (0.0.20)
|
7
19
|
metaclass (0.0.1)
|
8
20
|
mocha (0.10.5)
|
9
21
|
metaclass (~> 0.0.1)
|
@@ -13,16 +25,19 @@ GEM
|
|
13
25
|
rspec-expectations (~> 2.9.0)
|
14
26
|
rspec-mocks (~> 2.9.0)
|
15
27
|
rspec-core (2.9.0)
|
16
|
-
rspec-expectations (2.9.
|
28
|
+
rspec-expectations (2.9.1)
|
17
29
|
diff-lcs (~> 1.1.3)
|
18
30
|
rspec-mocks (2.9.0)
|
31
|
+
thor (0.14.6)
|
19
32
|
|
20
33
|
PLATFORMS
|
21
34
|
ruby
|
22
35
|
|
23
36
|
DEPENDENCIES
|
24
37
|
ansi
|
38
|
+
guard-rspec
|
25
39
|
hashr
|
26
40
|
mocha
|
27
41
|
rake
|
42
|
+
rb-fsevent!
|
28
43
|
rspec
|
data/Guardfile
ADDED
data/README.md
CHANGED
data/Rakefile
CHANGED
data/bin/space
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
module Enumerable
|
2
|
-
def map_with_index(&block)
|
3
|
-
result = []
|
4
|
-
each_with_index { |element, ix| result << yield(element, ix) }
|
5
|
-
result
|
6
|
-
end
|
7
|
-
|
8
2
|
def map_slice(num, &block)
|
9
3
|
result = []
|
10
4
|
each_slice(num) { |element| result << yield(element) }
|
11
5
|
result
|
12
|
-
end
|
6
|
+
end unless method_defined?(:map_slice)
|
13
7
|
end
|
8
|
+
|
data/lib/space.rb
CHANGED
@@ -1,25 +1,15 @@
|
|
1
1
|
require 'yaml'
|
2
2
|
require 'hashr'
|
3
|
-
require 'core_ext/enumerable'
|
4
3
|
|
5
4
|
module Space
|
6
|
-
autoload :Action, 'space/action'
|
5
|
+
# autoload :Action, 'space/action'
|
7
6
|
autoload :App, 'space/app'
|
8
7
|
autoload :Config, 'space/config'
|
8
|
+
autoload :Events, 'space/events'
|
9
9
|
autoload :Helpers, 'space/helpers'
|
10
|
-
autoload :
|
11
|
-
autoload :Commands, 'space/models/commands'
|
12
|
-
autoload :Command, 'space/models/command'
|
13
|
-
autoload :Dependency, 'space/models/dependency'
|
14
|
-
autoload :Git, 'space/models/git'
|
15
|
-
autoload :Repos, 'space/models/repos'
|
16
|
-
autoload :Repo, 'space/models/repo'
|
10
|
+
autoload :Models, 'space/models'
|
17
11
|
autoload :Screen, 'space/screen'
|
18
|
-
autoload :
|
19
|
-
autoload :
|
20
|
-
|
21
|
-
TEMPLATES = {
|
22
|
-
:project => 'lib/space/templates/project.erb',
|
23
|
-
:repo => 'lib/space/templates/repository.erb'
|
24
|
-
}
|
12
|
+
autoload :Shell, 'space/shell'
|
13
|
+
autoload :Tmux, 'space/tmux'
|
25
14
|
end
|
15
|
+
|
data/lib/space/app.rb
CHANGED
@@ -2,71 +2,59 @@ require 'readline'
|
|
2
2
|
|
3
3
|
module Space
|
4
4
|
class App
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
@instance = new(name)
|
10
|
-
instance.run
|
11
|
-
end
|
12
|
-
|
13
|
-
def name
|
14
|
-
instance.name
|
15
|
-
end
|
5
|
+
autoload :Command, 'space/app/command'
|
6
|
+
autoload :Handler, 'space/app/handler'
|
7
|
+
autoload :Logger, 'space/app/logger'
|
8
|
+
autoload :Parser, 'space/app/parser'
|
16
9
|
|
17
|
-
|
18
|
-
|
10
|
+
class << self
|
11
|
+
def logger
|
12
|
+
@logger ||= Logger.new
|
19
13
|
end
|
20
14
|
end
|
21
15
|
|
22
16
|
include Readline
|
23
17
|
|
24
|
-
|
18
|
+
attr_reader :name, :project, :screen
|
25
19
|
|
26
20
|
def initialize(name)
|
27
|
-
@
|
28
|
-
@
|
29
|
-
@
|
30
|
-
@bundle = Bundle.new(config.paths.first)
|
31
|
-
@path = File.expand_path('.')
|
32
|
-
end
|
21
|
+
@name = name
|
22
|
+
@project = Models::Project.new(name)
|
23
|
+
@screen = Screen.new(project)
|
33
24
|
|
34
|
-
|
35
|
-
# "#{repos.name} >".strip + ' '
|
36
|
-
'> '
|
37
|
-
end
|
38
|
-
|
39
|
-
def repos
|
40
|
-
@repos ||= Repos.all
|
25
|
+
project.subscribe(screen)
|
41
26
|
end
|
42
27
|
|
43
28
|
def run
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
break if line.nil?
|
48
|
-
handle(line) unless line.empty?
|
49
|
-
end
|
50
|
-
puts
|
29
|
+
refresh
|
30
|
+
screen.display(:dashboard)
|
31
|
+
cli_loop
|
51
32
|
end
|
52
33
|
|
53
|
-
|
54
|
-
Action.run(self, line)
|
55
|
-
screen.render
|
56
|
-
end
|
34
|
+
private
|
57
35
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
36
|
+
def refresh
|
37
|
+
screen.display(:progress)
|
38
|
+
project.refresh
|
39
|
+
end
|
62
40
|
|
63
|
-
|
64
|
-
|
65
|
-
|
41
|
+
def cli_loop
|
42
|
+
loop do
|
43
|
+
line = readline(prompt, true)
|
44
|
+
break if line.nil?
|
45
|
+
handle(line) unless line.empty?
|
46
|
+
end
|
47
|
+
end
|
66
48
|
|
67
|
-
|
68
|
-
|
69
|
-
|
49
|
+
def handle(line)
|
50
|
+
screen.display(:progress)
|
51
|
+
Handler.new(project).run(line)
|
52
|
+
screen.display(:dashboard)
|
53
|
+
end
|
54
|
+
|
55
|
+
def prompt
|
56
|
+
"#{project.repos.scoped? ? project.repos.scope.map { |r| r.name }.join(', ') : project.name} > "
|
57
|
+
end
|
70
58
|
end
|
71
59
|
end
|
72
60
|
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Space
|
2
|
+
class App
|
3
|
+
class Command
|
4
|
+
autoload :Execute, 'space/app/command/builtin'
|
5
|
+
autoload :Refresh, 'space/app/command/builtin'
|
6
|
+
autoload :Scope, 'space/app/command/builtin'
|
7
|
+
autoload :Unscope, 'space/app/command/builtin'
|
8
|
+
|
9
|
+
autoload :Local, 'space/app/command/development'
|
10
|
+
autoload :Remote, 'space/app/command/development'
|
11
|
+
|
12
|
+
attr_reader :project, :scope, :args
|
13
|
+
|
14
|
+
def initialize(project, scope, *args)
|
15
|
+
@project = project
|
16
|
+
@scope = scope
|
17
|
+
@args = args
|
18
|
+
end
|
19
|
+
|
20
|
+
def run
|
21
|
+
raise 'not implemented'
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def repos
|
27
|
+
@repos ||= project.repos.select_by_names(scope)
|
28
|
+
end
|
29
|
+
|
30
|
+
def in_scope
|
31
|
+
repos.each { |repo| yield repo }
|
32
|
+
end
|
33
|
+
|
34
|
+
def system(cmd)
|
35
|
+
puts cmd
|
36
|
+
super
|
37
|
+
end
|
38
|
+
|
39
|
+
def confirm
|
40
|
+
puts "\n--- hit any key to continue ---\n"
|
41
|
+
STDIN.getc
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Space
|
2
|
+
class App
|
3
|
+
class Command
|
4
|
+
class Execute < Command
|
5
|
+
def run
|
6
|
+
Bundler.with_clean_env do
|
7
|
+
in_scope do |repo|
|
8
|
+
repo.buffering do
|
9
|
+
puts
|
10
|
+
repo.execute(*args)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
confirm
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class Refresh < Command
|
19
|
+
def run
|
20
|
+
Bundler.with_clean_env do
|
21
|
+
project.bundler.refresh
|
22
|
+
in_scope do |repo|
|
23
|
+
repo.refresh
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class Scope < Command
|
30
|
+
def run
|
31
|
+
project.repos.scope = repos
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
class Unscope < Command
|
36
|
+
def run
|
37
|
+
project.repos.scope = nil
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module Space
|
2
|
+
class App
|
3
|
+
class Command
|
4
|
+
class Local < Command
|
5
|
+
def run
|
6
|
+
Shell::Watcher.suspend do
|
7
|
+
repos.each do |repo|
|
8
|
+
system "bundle config --global local.#{repo.name} #{repo.path}"
|
9
|
+
end
|
10
|
+
confirm
|
11
|
+
end
|
12
|
+
project.bundler.refresh
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class Remote < Command
|
17
|
+
def run
|
18
|
+
Shell::Watcher.suspend do
|
19
|
+
repos.each do |repo|
|
20
|
+
system "bundle config --delete local.#{repo.name}"
|
21
|
+
end
|
22
|
+
confirm
|
23
|
+
end
|
24
|
+
project.bundler.refresh
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# class Install < Command
|
29
|
+
# def run
|
30
|
+
# in_scope do |repo|
|
31
|
+
# repo.execute 'bundle install'
|
32
|
+
# repo.refresh
|
33
|
+
# end
|
34
|
+
# end
|
35
|
+
# end
|
36
|
+
|
37
|
+
# class Update < Command
|
38
|
+
# def run
|
39
|
+
# in_scope do |repo|
|
40
|
+
# repo.execute 'bundle update'
|
41
|
+
# repo.execute 'git commit -am "bump dependencies"'
|
42
|
+
# repo.refresh
|
43
|
+
# end
|
44
|
+
# end
|
45
|
+
# end
|
46
|
+
|
47
|
+
# class Checkout < Command
|
48
|
+
# def run
|
49
|
+
# # check if branch exists, git co (-b)
|
50
|
+
# end
|
51
|
+
# end
|
52
|
+
|
53
|
+
# class PullDeps < Command
|
54
|
+
# def run
|
55
|
+
# # pull all dependencies
|
56
|
+
# end
|
57
|
+
# end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Space
|
2
|
+
class App
|
3
|
+
class Handler
|
4
|
+
ALIASES = {
|
5
|
+
'' => 'scope',
|
6
|
+
'-' => 'unscope',
|
7
|
+
'r' => 'refresh'
|
8
|
+
}
|
9
|
+
attr_reader :project
|
10
|
+
|
11
|
+
def initialize(project)
|
12
|
+
@project = project
|
13
|
+
end
|
14
|
+
|
15
|
+
def run(line)
|
16
|
+
scope, type = parse(line)
|
17
|
+
command = command_for(scope, type)
|
18
|
+
command.run
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def command_for(scope, type)
|
24
|
+
const = const_for(type)
|
25
|
+
args = [project, scope]
|
26
|
+
args << type if const == Command::Execute
|
27
|
+
const.new(*args)
|
28
|
+
end
|
29
|
+
|
30
|
+
def parse(line)
|
31
|
+
Parser.new(project.names).parse(line)
|
32
|
+
end
|
33
|
+
|
34
|
+
def const_for(type)
|
35
|
+
Command.const_get(const_name(type))
|
36
|
+
rescue NameError
|
37
|
+
Command::Execute
|
38
|
+
end
|
39
|
+
|
40
|
+
def const_name(type)
|
41
|
+
type = (type || '').strip
|
42
|
+
type = ALIASES[type] if ALIASES.key?(type)
|
43
|
+
type.capitalize
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|