easyoperate 0.2.2 → 0.3.0

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 CHANGED
@@ -1,3 +1,7 @@
1
+ == 0.3.0 2008-12-26
2
+
3
+ * Show All Install Gems, Goto Gem's Path ...
4
+
1
5
  == 0.2.1 2008-12-22
2
6
 
3
7
  * Define repository special update,init command ...
data/README.rdoc CHANGED
@@ -12,29 +12,38 @@
12
12
  repo: git://github.com/tpope/vim-rails.git # Remote path
13
13
 
14
14
  autorun: 'puts "Thanks to Tim Pope";cp_autoload;cp_plugin'
15
- # Splited by ';' , when init or update,this will autorun,
16
- # first print "Thanks to Tim Pope"
17
- # then copy autoload/rails.vim to ~/.vim/autoload/
18
- # then copy plugin/rails.vim to ~/.vim/plugin/
15
+ # Splited by ';' , when init or update,this will autorun,
16
+ # first print "Thanks to Tim Pope"
17
+ # then copy autoload/rails.vim to ~/.vim/autoload/
18
+ # then copy plugin/rails.vim to ~/.vim/plugin/
19
19
 
20
- scm: # Default is git,your can define your scm-type in ~/.eo/scm
20
+ scm: # Default is git,your can define your scm-type in ~/.eo/scm
21
21
 
22
- cmd: # Where you can define your methods
22
+ cmd: # Where you can define your methods
23
23
  cp_autoload: `cp autoload/rails.vim ~/.vim/autoload/`
24
24
  cp_plugin: `cp plugin/rails.vim '~/.vim/plugin/`
25
25
  example: 'puts "Hi,This is example method"'
26
- # you can run example when choose vim-rails use $ eo -c vim-rails,
27
- # will print "Hi,This is example method"
26
+ # you can run 'example' when choose vim-rails use $ eo -c vim-rails,
27
+ # will print "Hi,This is example method"
28
+
29
+ arch-linux:
30
+ cmd:
31
+ init: system('sudo pacman -S $(cat ~/pkglist)')
32
+ # Install all software list in ~/pkglist
33
+
34
+ update: system('sudo pacman -Suy')
35
+ # Synchronizing package databases,Then upgrade System
36
+
28
37
 
29
38
  ### Other Commands:
30
39
  $ eo -i vim-rails => initialise vim-rails:
31
- clone source from github to the path your specify
40
+ clone source from github to the path your specify
32
41
  $ eo -c vim-rails => Select vim-rails
33
42
  $ eo -u vim-rails => Update vim-rails
34
- run 'git pull' in vim-rails's path
43
+ run 'git pull' in vim-rails's path
35
44
  $ eo -u => Update all repository in ~/.eorc <Regexp>
36
45
 
37
- == More Help ?
46
+ == More Help ?!
38
47
 
39
48
  <Shell>
40
49
  $ eo -h for help
data/example/eorc CHANGED
@@ -10,6 +10,9 @@ vim-rails:
10
10
  cp_plugin: `cp plugin/rails.vim '~/.vim/plugin/`
11
11
  example: 'puts "Hi,This is example method"'
12
12
 
13
- arch-linux-system:
14
- cmd:
15
- update: system('sudo pacman -Suy')
13
+ arch-linux:
14
+ cmd:
15
+ init: system('sudo pacman -S $(cat ~/pkglist)')
16
+ # Install all software list in ~/pkglist
17
+ update: system('sudo pacman -Suy')
18
+ # Synchronizing package databases,Then upgrade System
data/lib/easyoperate.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Easyoperate
2
- VERSION = '0.2.2'
2
+ VERSION = '0.3.0'
3
3
  end
data/lib/eo/eo.rb CHANGED
@@ -20,15 +20,17 @@ class Eo
20
20
  loop do
21
21
  printf("\e[33mInput Commands (q:quit h:help): \e[0m")
22
22
  input = STDIN.gets.split(' ',2)
23
- input[1] ? input[1].strip! : next
23
+ input[1].strip!
24
24
 
25
25
  case input[0].to_s
26
- when /S/i then show(input[1])
27
- when /C/i then choose(input[1])
28
- when /U/i then update(input[1])
29
- when /I/i then init(input[1])
30
- when /T/i then type
31
- when /Q/i then exit
26
+ when /GS/i then gemshow(input[1])
27
+ when /GC/i then gemchoose(input[1])
28
+ when /S/i then show(input[1])
29
+ when /C/i then choose(input[1])
30
+ when /U/i then update(input[1])
31
+ when /I/i then init(input[1])
32
+ when /T/i then type
33
+ when /Q/i then exit
32
34
  else help
33
35
  end
34
36
  end
@@ -37,11 +39,13 @@ class Eo
37
39
  def help
38
40
  puts <<-DOC.gsub(/^(\s*\|)/,'')
39
41
  |Usage:
40
- | S /args/ : Show matched repositories <Regexp>
41
- | C /args/ : Choose One Repository <Regexp>
42
- | U /args/ : Update matched Repository <Regexp>
43
42
  | I /args/ : Initialize matched Repository <Regexp>
43
+ | U /args/ : Update matched Repository <Regexp>
44
44
  | T : Show All Support Scm
45
+ | S /args/ : Show matched repositories <Regexp>
46
+ | C /args/ : Choose One Repository <Regexp>
47
+ | GS /args/ : Show matched Gems <Regexp>
48
+ | GC /args/ : Choose One Gem <Regexp>
45
49
  | Q : Quit
46
50
  | H : Show this help message.
47
51
  |e.g:\n \e[32m s v.*m\e[0m
@@ -61,6 +65,29 @@ class Eo
61
65
  format_display(@formated_scm)
62
66
  end
63
67
 
68
+ def gemshow(args)
69
+ puts "\e[33mAll Gems match < #{args} > :\e[0m"
70
+ format_display(scangem(args))
71
+ end
72
+
73
+ def gemchoose(args)
74
+ gem = choose_one(scangem(args))
75
+ if gem
76
+ filepath = `gem content #{gem} | sed -n 1p`
77
+ Dir.chdir(filepath.match(/(.*?\w-\d.*?\/)/).to_s)
78
+ system('sh')
79
+ end
80
+ end
81
+
82
+ def scangem(args)
83
+ result = []
84
+ gemlist = `gem list | grep '#{args}'`
85
+ gemlist.scan(/^(\w.*?)\s/) do
86
+ result << $1
87
+ end
88
+ return result
89
+ end
90
+
64
91
  def show(*args)
65
92
  repos = pick(args,false)
66
93
  puts "\e[33mAll Repo match < #{args} > :\e[0m"
@@ -106,6 +133,7 @@ class Eo
106
133
  end
107
134
 
108
135
  protected
136
+ #Pick one or more repositories to operate,if single is true only pick one
109
137
  def pick(args,single=true)
110
138
  repos = Repos.keys.grep(/#{args}/)
111
139
  if single
@@ -142,6 +170,7 @@ class Eo
142
170
  def exist_path(repos)
143
171
  if Repos[repos].path
144
172
  if File.exist?(Repos[repos].path)
173
+ # Switch current path to the repository's path
145
174
  Dir.chdir(Repos[repos].path)
146
175
  else
147
176
  puts "\n l.l,Have You init \e[33m#{repos}\e[0m Repository?\n\n"
data/lib/eo.rb CHANGED
@@ -5,23 +5,27 @@ class Eo
5
5
  def self.execute(args)
6
6
 
7
7
  case args.first
8
- when "-s" then self.show(args[1,args.size])
9
- when "-c" then self.choose(args[1,args.size])
10
- when "-i" then self.init(args[1,args.size])
11
- when "-u" then self.update(args[1,args.size])
12
- when "-t" then self.type
13
- when "-v" then puts "\e[33mEo_oE : v" + Easyoperate::VERSION + "\e[0m"
14
- when "-h" then
8
+ when "-gs" then self.gemshow(args[1,args.size])
9
+ when "-gc" then self.gemchoose(args[1,args.size])
10
+ when "-s" then self.show(args[1,args.size])
11
+ when "-c" then self.choose(args[1,args.size])
12
+ when "-i" then self.init(args[1,args.size])
13
+ when "-u" then self.update(args[1,args.size])
14
+ when "-t" then self.type
15
+ when "-v" then puts "\e[33mEo_oE : v" + Easyoperate::VERSION + "\e[0m"
16
+ when "-h" then
15
17
  puts <<-DOC.gsub(/^(\s*\|)/,'')
16
18
  |Usage: #{File.basename($0)} [options] [ARGS]
17
19
 
18
20
  |Options are:
21
+ | -i Initialize Repository. <Regexp>
22
+ | -t Show All Support Scm
19
23
  | -u Update Repository. <Regexp>
20
24
  | -s Show All Repositories. <Regexp>
25
+ | -c Choose Repository. <Regexp>
26
+ | -gs Show All Gems. <Regexp>
27
+ | -gc Choose Gem. <Regexp>
21
28
  | -v Show version information.
22
- | -c Choose Repository.
23
- | -t Show All Support Scm
24
- | -i Initialize Repository. <Regexp>
25
29
  DOC
26
30
  else self.run
27
31
  end
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.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jinzhu Zhang
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-12-23 00:00:00 +08:00
12
+ date: 2008-12-26 00:00:00 +08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency