wosmvp-yac 1.0.0 → 1.0.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.
Files changed (3) hide show
  1. data/lib/yac.rb +15 -10
  2. data/yac.gemspec +1 -1
  3. metadata +1 -1
data/lib/yac.rb CHANGED
@@ -117,8 +117,9 @@ module Yac
117
117
  def rename(args)
118
118
  (colorful("Usage:\nyac mv [orign_name] [new_name]\n\nTry `yac -h` for more help","warn");exit) unless args.size == 2
119
119
  file = search_name(args[0],"Rename")
120
- new_name = file.sub(/^((?:.*)?(?:main|private)\/)(.*)(\..*)/,'\1'+args[1]+'\3')
120
+ new_name = add_file(args[1].sub(/^(@)?/,file =~ /^#{@main_path}/ ? "@":""),file.sub(/.*(\..*)/,'\1'))
121
121
  if confirm("You Are Renaming #{file} To #{new_name}")
122
+ prepare_dir(new_name)
122
123
  `mv "#{file}" "#{new_name}"`
123
124
  @working_git.add
124
125
  @working_git.commit_all("#{clean_filename(file)} Renamed to #{clean_filename(new_name)}")
@@ -127,21 +128,25 @@ module Yac
127
128
 
128
129
  protected
129
130
  def add_single(args)
131
+ file = add_file(args)
132
+ if confirm("You Are Adding #{file}")
133
+ edit_text(file)
134
+ @working_git.add
135
+ @working_git.commit_all("#{clean_filename(file)} Added")
136
+ end
137
+ end
138
+
139
+ def add_file(args,suffix = ".ch")
130
140
  if args.include?('/') && args =~ /(@?)(?:(.*)\/)(.+)/
131
141
  path = $1.empty? ? @pri_path : @main_path
132
142
  all_path = %x{
133
143
  find #{path} -type d -iwholename '#{path}*#{$2}*' -not -iwholename '*.git*'| sed 's/^.*\\(private\\|main\\)\\//#{$1}/'
134
144
  }.to_a
135
- colorful("Which directory do you want to use:","notice")
136
- choosed_path = choose_one(all_path.concat([$1+$2]).uniq)
137
- args = choosed_path + "/" + $3 if choosed_path
138
- end
139
- file = full_path(args+".ch")
140
- if confirm("You Are Adding #{file}")
141
- edit_text(file)
142
- @working_git.add
143
- @working_git.commit_all("#{clean_filename(file)} Added")
145
+ colorful("Which directory do you want to use:","notice") if all_path.size >1
146
+ choosed_path = choose_one(all_path.concat([$1+$2]).uniq)
147
+ args = choosed_path + "/" + $3 if choosed_path
144
148
  end
149
+ file = full_path(args+suffix)
145
150
  end
146
151
 
147
152
  def show_single(args)
data/yac.gemspec CHANGED
@@ -1,5 +1,5 @@
1
1
  GEM = "yac"
2
- VER = "1.0.0"
2
+ VER = "1.0.1"
3
3
  DATE = %q{2008-10-28}
4
4
  AUTHOR = "Jinzhu Zhang"
5
5
  EMAIL = "wosmvp@gmail.com"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wosmvp-yac
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jinzhu Zhang