easyoperate 0.2.0 → 0.2.1
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/History.txt +4 -2
- data/bin/eo +3 -2
- data/example/eorc +9 -4
- data/lib/easyoperate.rb +1 -1
- data/lib/eo/eo.rb +11 -7
- data/lib/eo/repository.rb +12 -8
- metadata +1 -1
data/History.txt
CHANGED
data/bin/eo
CHANGED
@@ -4,8 +4,6 @@
|
|
4
4
|
# Author: Jinzhu Zhang
|
5
5
|
|
6
6
|
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib"))
|
7
|
-
require "easyoperate"
|
8
|
-
require "eo"
|
9
7
|
|
10
8
|
# easy debug
|
11
9
|
if ARGV.delete('-d')
|
@@ -14,4 +12,7 @@ else
|
|
14
12
|
def debugger;end
|
15
13
|
end
|
16
14
|
|
15
|
+
require "easyoperate"
|
16
|
+
require "eo"
|
17
|
+
|
17
18
|
Eo.execute(ARGV)
|
data/example/eorc
CHANGED
@@ -1,10 +1,15 @@
|
|
1
1
|
# hack hack hack, rename to ~/.eorc
|
2
2
|
vim-rails:
|
3
|
-
path: ~/vim/vim-rails/
|
4
|
-
repo: git://github.com/tpope/vim-rails.git
|
3
|
+
path: ~/vim/vim-rails/ # Local path
|
4
|
+
repo: git://github.com/tpope/vim-rails.git # Remote path
|
5
5
|
autorun: 'puts "Thanks to Tim Pope";cp_autoload;cp_plugin' # Splited by ;
|
6
|
-
scm: #
|
7
|
-
|
6
|
+
scm: # default is git,you can define you scm-type in ~/.eo/scm
|
7
|
+
# you can get all scm-type with eo -t
|
8
|
+
cmd: # define your methods
|
8
9
|
cp_autoload: `cp autoload/rails.vim ~/.vim/autoload/`
|
9
10
|
cp_plugin: `cp plugin/rails.vim '~/.vim/plugin/`
|
10
11
|
example: 'puts "Hi,This is example method"'
|
12
|
+
|
13
|
+
arch-linux-system:
|
14
|
+
cmd:
|
15
|
+
update: system('sudo pacman -Suy')
|
data/lib/easyoperate.rb
CHANGED
data/lib/eo/eo.rb
CHANGED
@@ -12,7 +12,7 @@ class Eo
|
|
12
12
|
end
|
13
13
|
|
14
14
|
YAML.load_file(Config_file).each_pair do |key,value|
|
15
|
-
Repos[key] = Repository.new(value.merge(
|
15
|
+
Repos[key] = Repository.new(value.merge!("_name_" => key))
|
16
16
|
end
|
17
17
|
|
18
18
|
class << self
|
@@ -86,7 +86,7 @@ class Eo
|
|
86
86
|
repos = pick(args,false)
|
87
87
|
|
88
88
|
repos.each do |x|
|
89
|
-
if File.exist?(
|
89
|
+
if File.exist?(Repos[x].path)
|
90
90
|
puts "\e[32m %-18s: already Initialized\e[0m" % [x]
|
91
91
|
next
|
92
92
|
end
|
@@ -99,7 +99,7 @@ class Eo
|
|
99
99
|
repos = pick(args,false)
|
100
100
|
|
101
101
|
repos.each do |x|
|
102
|
-
puts "\e[32m Updating #{Repos[x].
|
102
|
+
puts "\e[32m Updating #{Repos[x]._name_}:\e[0m"
|
103
103
|
next if !exist_path(x)
|
104
104
|
Repos[x].update
|
105
105
|
end
|
@@ -140,11 +140,15 @@ class Eo
|
|
140
140
|
end
|
141
141
|
|
142
142
|
def exist_path(repos)
|
143
|
-
if
|
144
|
-
|
143
|
+
if Repos[repos].path
|
144
|
+
if File.exist?(Repos[repos].path)
|
145
|
+
Dir.chdir(Repos[repos].path)
|
146
|
+
else
|
147
|
+
puts "\n l.l,Have You init \e[33m#{repos}\e[0m Repository?\n\n"
|
148
|
+
return false
|
149
|
+
end
|
145
150
|
else
|
146
|
-
|
147
|
-
return false
|
151
|
+
return true
|
148
152
|
end
|
149
153
|
end
|
150
154
|
|
data/lib/eo/repository.rb
CHANGED
@@ -5,26 +5,29 @@ class Repository
|
|
5
5
|
|
6
6
|
def initialize(opt={})
|
7
7
|
|
8
|
-
['repo','
|
8
|
+
['repo','_name_','autorun'].each do |x|
|
9
9
|
eval "self.#{x} = opt.delete('#{x}')"
|
10
10
|
end
|
11
11
|
|
12
|
+
self.path = File.expand_path(opt['path']) if opt['path']
|
13
|
+
|
12
14
|
begin
|
13
15
|
scm = opt['scm'] || 'git'
|
14
16
|
require "scm/#{scm.downcase}"
|
15
17
|
extend eval "Scm::#{scm.capitalize}"
|
16
18
|
rescue LoadError
|
17
19
|
puts <<-DOC.gsub(/^(\s*\|)/,'')
|
18
|
-
|\e[33m#{
|
20
|
+
|\e[33m#{self._name_}\e[0m
|
19
21
|
| \e[31mSorry,doesn't support < #{scm} > now.\e[0m
|
20
22
|
| \e[31mYou can define your Scm-Type in ~/.eo/scm.\e[0m
|
21
|
-
|
23
|
+
DOC
|
22
24
|
exit 0
|
23
25
|
end
|
24
26
|
|
25
|
-
if opt['cmd']
|
27
|
+
if opt['cmd'] # Define Your Methods
|
26
28
|
opt['cmd'].each do |key,value|
|
27
|
-
|
29
|
+
# Hack, Can't use defined_method to replace a extend method
|
30
|
+
eval("def self.#{key}; #{value} ; end")
|
28
31
|
(@defined_methods ||= [] ) << [key,value]
|
29
32
|
end
|
30
33
|
end
|
@@ -32,14 +35,15 @@ class Repository
|
|
32
35
|
|
33
36
|
def help
|
34
37
|
if @defined_methods
|
35
|
-
|
38
|
+
puts "Your Defined Methods :"
|
36
39
|
@defined_methods.each do |x|
|
37
|
-
puts " %-18s
|
40
|
+
puts " %-18s %s" % [x.first, x.last]
|
38
41
|
end
|
42
|
+
puts "\n"
|
39
43
|
end
|
40
44
|
|
41
45
|
puts <<-DOC.gsub(/^\s*\|/,'')
|
42
|
-
|Usage:
|
46
|
+
|Usage :
|
43
47
|
| update Update
|
44
48
|
| shell/sh Goto shell
|
45
49
|
| help/h Show this help message
|