easyoperate 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,9 +1,11 @@
1
+ == 0.2.1 2008-12-22
2
+
3
+ * Define repository special update,init command ...
4
+
1
5
  == 0.2.0 2008-12-22
2
6
 
3
- * 1 major enhancement:
4
7
  * Scm Plugin (Add your SCM Plugin to ~/.eo/scm )
5
8
 
6
9
  == 0.1.0 2008-12-13
7
10
 
8
- * 1 major enhancement:
9
11
  * Initial release
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/ # Local path
4
- repo: git://github.com/tpope/vim-rails.git # Remote path
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: # svn/git,default is git
7
- cmd: # Where can define your methods
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
@@ -1,3 +1,3 @@
1
1
  module Easyoperate
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.1'
3
3
  end
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(:_name_ => key))
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?(File.expand_path(Repos[x].path))
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].path}:\e[0m"
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 File.exist?(File.expand_path(Repos[repos].path))
144
- Dir.chdir(File.expand_path(Repos[repos].path))
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
- puts "\n l.l,Have You init \e[33m#{repos}\e[0m Repository?\n\n"
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','path','_name_','autorun'].each do |x|
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#{opt[:_name_]}\e[0m
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
- DOC
23
+ DOC
22
24
  exit 0
23
25
  end
24
26
 
25
- if opt['cmd'] # Define Your Methods
27
+ if opt['cmd'] # Define Your Methods
26
28
  opt['cmd'].each do |key,value|
27
- self.class.send(:define_method, key, lambda { eval(value) } )
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
- printf("Your Defined Methods :\n")
38
+ puts "Your Defined Methods :"
36
39
  @defined_methods.each do |x|
37
- puts " %-18s: %s" % [x.first, x.last]
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easyoperate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jinzhu Zhang