easyoperate 0.4.1 → 0.5.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/README.rdoc CHANGED
@@ -9,6 +9,10 @@
9
9
  vim-rails:
10
10
  path: ~/vim/vim-rails/ # Local path
11
11
 
12
+ skip: true # skip
13
+
14
+ pushable: true # pushable
15
+
12
16
  repo: git://github.com/tpope/vim-rails.git # Remote path
13
17
 
14
18
  autorun: 'puts "Thanks to Tim Pope";cp_autoload;cp_plugin'
data/bin/eo CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  #
3
3
  # Copyright (c) 2008. GPL3.
4
- # Author: Jinzhu Zhang
4
+ # Author: Zhang Jinzhu
5
5
 
6
6
  $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib"))
7
7
 
data/easyoperate.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{easyoperate}
5
- s.version = "0.4.1"
5
+ s.version = "0.5.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Jinzhu Zhang"]
9
- s.date = %q{2009-02-02}
9
+ s.date = %q{2009-02-13}
10
10
  s.default_executable = %q{eo}
11
11
  s.description = %q{Eo_oE}
12
12
  s.email = %q{wosmvp@gmail.com}
@@ -27,11 +27,8 @@ Gem::Specification.new do |s|
27
27
  s.specification_version = 2
28
28
 
29
29
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
30
- s.add_development_dependency(%q<echoe>, [">= 0"])
31
30
  else
32
- s.add_dependency(%q<echoe>, [">= 0"])
33
31
  end
34
32
  else
35
- s.add_dependency(%q<echoe>, [">= 0"])
36
33
  end
37
34
  end
data/lib/eo/eo.rb CHANGED
@@ -16,25 +16,24 @@ class Eo
16
16
  format_display(@formated_scm)
17
17
  end
18
18
 
19
- def show(args)
19
+ def show(args,opt={})
20
20
  puts "\e[33mAll Repo match < #{args} > :\e[0m"
21
- repos = pick(args,false) # single:false => allow choose many
21
+ repos = pick(:key => args,:plural => true,:skip => opt[:skip])
22
22
  format_display(repos) if repos
23
23
  end
24
24
 
25
25
  def open(args)
26
- repos = pick(args)
26
+ repos = pick(:key => args)
27
27
  system([Config['open'],Repos[repos.first].path].join(' ')) if repos
28
28
  end
29
29
 
30
30
  def choose(args)
31
- repos = pick(args)
31
+ repos = pick(:key => args)
32
32
 
33
33
  if repos && repos = repos.first # Get First Array
34
34
  return false unless exist_path(repos)
35
35
  loop do
36
- printf("\e[01;34m#{repos} (h:help)>> \e[0m")
37
- input = (STDIN.gets || exit).rstrip
36
+ input = (readline("\e[01;34m#{repos} (h:help)>> \e[0m",true) || exit).rstrip
38
37
 
39
38
  break if input =~ /\A\s*q\s*\Z/
40
39
  exit if input =~ /\A\s*Q\s*\Z/
@@ -43,8 +42,8 @@ class Eo
43
42
  end
44
43
  end
45
44
 
46
- def init(args)
47
- repos = pick(args,false)
45
+ def init(args,opt={})
46
+ repos = pick(:key => args,:plural => true,:skip => opt[:skip])
48
47
 
49
48
  repos.each do |x|
50
49
  if Repos[x].path && File.exist?(Repos[x].path)
@@ -56,8 +55,17 @@ class Eo
56
55
  end
57
56
  end
58
57
 
59
- def update(args)
60
- repos = pick(args,false)
58
+ def push(args)
59
+ repos = pick(:key => args,:plural => true,:pushable => true)
60
+ repos.each do |x|
61
+ puts "\e[32m %-18s: Pushing\e[0m" % [x]
62
+ Dir.chdir(Repos[x].path) if Repos[x].path
63
+ Repos[x].push if Repos[x].respond_to?(:push)
64
+ end
65
+ end
66
+
67
+ def update(args,opt={})
68
+ repos = pick(:key => args,:plural => true,:skip => opt[:skip])
61
69
 
62
70
  repos.each do |x|
63
71
  puts "\e[32m Updating #{Repos[x]._name_}:\e[0m"
@@ -68,15 +76,18 @@ class Eo
68
76
 
69
77
  protected
70
78
  #Pick one or more repositories to operate,if single is true only pick one
71
- def pick(args,single=true)
72
- repos = Repos.keys.grep(/#{args}/)
79
+ def pick(opt={}) #args,single=true
80
+ repos = Repos.keys.grep(/#{opt[:key]}/)
73
81
 
74
82
  if repos.empty?
75
- puts("\e[31mNo Result About < #{args} >\e[0m")
83
+ puts("\e[31mNo Result About < #{opt[:key]} >\e[0m")
76
84
  return false
77
85
  end
78
86
 
79
- return single ? choose_one(repos) : repos
87
+ repos = repos.select {|x| !Repos[x].skip} if opt[:skip]
88
+ repos = repos.select {|x| Repos[x].pushable} if opt[:pushable]
89
+
90
+ return opt[:plural] ? repos : choose_one(repos)
80
91
  end
81
92
 
82
93
  def choose_one(args)
@@ -90,8 +101,7 @@ class Eo
90
101
  end
91
102
 
92
103
  def choose_range(size)
93
- printf "\e[33mPlease Input A Valid Number (1-#{size}) (q:quit): \e[0m"
94
- num = STDIN.gets || exit
104
+ num = (readline("\e[33mPlease Input A Valid Number (1-#{size}) (q:quit): \e[0m",true) || exit)
95
105
  return false if num =~ /q/i
96
106
  num = num.strip.empty? ? 1 : num.to_i
97
107
  return (1..size).member?(num) ? num : choose_range(size)
data/lib/eo/repository.rb CHANGED
@@ -1,11 +1,11 @@
1
1
  $LOAD_PATH.unshift("#{ENV['HOME']}/.eo/",File.join(File.dirname(__FILE__)))
2
2
 
3
3
  class Repository
4
- attr_accessor :repo,:path,:_name_,:autorun
4
+ attr_accessor :repo,:path,:_name_,:autorun,:skip,:pushable
5
5
 
6
6
  def initialize(opt={})
7
7
 
8
- ['repo','_name_','autorun'].each do |x|
8
+ ['repo','_name_','autorun','skip','pushable'].each do |x|
9
9
  eval "self.#{x} = opt.delete('#{x}')"
10
10
  end
11
11
 
data/lib/eo/scm/git.rb CHANGED
@@ -15,6 +15,10 @@ module Scm
15
15
  end
16
16
  end
17
17
 
18
+ def push
19
+ system("git push")
20
+ end
21
+
18
22
  def now_commit
19
23
  return `git log --pretty=format:%H -1`
20
24
  end
data/lib/eo/scm/svn.rb CHANGED
@@ -9,9 +9,7 @@ module Scm
9
9
  system("svn update")
10
10
  new_commit = now_commit
11
11
  if new_commit != old_commit && self.autorun
12
- self.autorun.split(';').each do |x|
13
- eval x
14
- end
12
+ self.autorun.split(';').each { |x| eval x }
15
13
  end
16
14
  end
17
15
 
data/lib/eo.rb CHANGED
@@ -1,4 +1,5 @@
1
- %w(yaml eo/repository eo/gem eo/eo).each {|f| require f}
1
+ %w(yaml eo/repository eo/gem eo/eo readline).each {|f| require f}
2
+ include Readline
2
3
 
3
4
  class Eo
4
5
  Repos = Hash.new
@@ -22,12 +23,16 @@ class Eo
22
23
  when /^-gs$/i then gemshow(params)
23
24
  when /^-gc$/i then gemshell(params)
24
25
  when /^-go$/i then gemopen(params)
25
- when /^-s$/i then show(params)
26
+
27
+ when /^-s\w?$/i then show(params,:skip => (args[0] =~ /^-sa$/).nil?)
28
+ when /^-i\w?$/i then init(params,:skip => (args[0] =~ /^-ia$/).nil?)
29
+ when /^-u\w?$/i then update(params,:skip => (args[0] =~ /^-ua$/).nil?)
30
+
26
31
  when /^-o$/i then open(params)
27
32
  when /^-c$/i then choose(params)
28
- when /^-i$/i then init(params)
29
- when /^-u$/i then update(params)
33
+
30
34
  when /^-t$/i then type
35
+ when /^-p$/i then push(params)
31
36
  when /^-v$/i then puts "\e[33mEo_oE : v#{Easyoperate::VERSION}\e[0m"
32
37
  when /^-(h|help)$/i then help
33
38
  else self.run
@@ -36,19 +41,21 @@ class Eo
36
41
 
37
42
  def run
38
43
  loop do
39
- printf("\e[33mInput Commands (q:quit h:help): \e[0m")
40
- input = (STDIN.gets || exit).rstrip.split(' ',2)
44
+ input = (readline("\e[33mInput Commands (q:quit h:help): \e[0m",true) || exit).rstrip.split(' ',2)
41
45
 
42
46
  case input[0].to_s
43
47
  when /^GS$/i then gemshow(input[1])
44
48
  when /^GC$/i then gemshell(input[1])
45
49
  when /^GO$/i then gemopen(input[1])
46
- when /^S$/i then show(input[1])
50
+
51
+ when /^s\w?/i then show(input[1],:skip => (input[0] =~ /^sa$/i).nil?)
52
+ when /^i\w?/i then init(input[1],:skip => (input[0] =~ /^ia$/i).nil?)
53
+ when /^u\w?/i then update(input[1],:skip =>(input[0] =~ /^ua$/i).nil?)
54
+
47
55
  when /^O$/i then open(input[1])
48
56
  when /^C$/i then choose(input[1])
49
- when /^U$/i then update(input[1])
50
- when /^I$/i then init(input[1])
51
57
  when /^T$/i then type
58
+ when /^P$/i then push(input[1])
52
59
  when /^Q$/i then exit
53
60
  when /^V$/i then
54
61
  puts "\e[33mEo_oE : v" + Easyoperate::VERSION + "\e[0m"
@@ -65,6 +72,7 @@ class Eo
65
72
  | I /args/ : Initialize matched Repository <Regexp>
66
73
  | U /args/ : Update matched Repository <Regexp>
67
74
  | T : Show All Support Scm
75
+ | P : Push All matched/pushable repositories <Regexp>
68
76
  | S /args/ : Show matched repositories <Regexp>
69
77
  | O /args/ : Open The repository's path <Regexp>
70
78
  | C /args/ : Choose One Repository <Regexp>
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Easyoperate
2
- VERSION = '0.4.1'
2
+ VERSION = '0.5.1'
3
3
  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.4.1
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jinzhu Zhang
@@ -9,19 +9,10 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-02-02 00:00:00 +08:00
12
+ date: 2009-02-13 00:00:00 +08:00
13
13
  default_executable:
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: echoe
17
- type: :development
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: "0"
24
- version:
14
+ dependencies: []
15
+
25
16
  description: Eo_oE
26
17
  email: wosmvp@gmail.com
27
18
  executables: