am 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 315f5f6dd4042ccb59e3857fbdaf45963aa322b3
4
- data.tar.gz: 1c91d2a92c83210ded459f4b0f86a6f4aef340ca
3
+ metadata.gz: 607457b961dba43878566b3a4bb32f656a4d3993
4
+ data.tar.gz: 04e5f824a7374a4f9569255ae44b853a8c2032b8
5
5
  SHA512:
6
- metadata.gz: bc38956ce7f0e3c1265c13bbf8ed64da4700266e0c72fa96d9b7b2f6d9f63b71dbdff05621dc7d34604f383af2f62c7a8b00f369991ed4e0f842b152fcdd5f42
7
- data.tar.gz: 11c2ad7c640b968e598d1e4c76379add8b5f6cd0b10494e81eb660571a4ae4cd194d65286b83071086178ceadbf8c205f0708f76f7297169810dfcca9e266d3d
6
+ metadata.gz: 4c78383e7b482182f52c12e265d083c16d6255305f22d587a4b33fcb68d0205e7f870f1529afcb1f8a3530fbfe91e38da6343c162ae998b0e00a17c42c7d9de5
7
+ data.tar.gz: e58d5542d42370b85ece05fc01b8d54ecc9fdb6f1e49bc8e5751c8ee72d33b4510dbb168edeffb3ff29fd6682a3f417cb2c51ec602bba74a36b7acb78eb7b154
data/README.md CHANGED
@@ -44,15 +44,9 @@ echo 'source ~/.am_config' >> ~/.bash_profile
44
44
  print current config
45
45
 
46
46
  $ am add
47
- add alias from last history command
47
+ add alias select last history command
48
48
 
49
- $ am add -l(list)
50
- add alias select from five line last history command
51
-
52
- $ am del [alias_name)
53
- delete alias from alias_name
54
-
55
- $ am del -l(list)
49
+ $ am del
56
50
  delete alias select from current config
57
51
 
58
52
  ### configure
data/lib/am/cli.rb CHANGED
@@ -39,7 +39,7 @@ module AM
39
39
  @ui.print_last_commands(commands)
40
40
  new_alias = @ui.add_command_with_number(commands)
41
41
 
42
- unless new_alias
42
+ unless Hash.try_convert(new_alias)
43
43
  add
44
44
  else
45
45
  if uniq?(new_alias)
@@ -51,14 +51,12 @@ module AM
51
51
  desc "del", "delete alias"
52
52
  def del
53
53
  unless @config.al.empty?
54
- arr = @ui.print_current_config(@config)
55
- delete_alias = @ui.del_command_with_number(arr)
56
-
57
- if delete_alias && @config.al.key?(delete_alias)
54
+ @ui.print_current_config(@config)
55
+ delete_alias = @ui.delete_command_with_number(@config)
56
+ unless delete_alias.nil?
58
57
  @config.al.delete(delete_alias)
59
58
  @config.delete_config(delete_alias)
60
59
  else
61
- warning(:empty_config_number)
62
60
  del
63
61
  end
64
62
  else
data/lib/am/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Am
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
@@ -46,11 +46,11 @@ module AM
46
46
 
47
47
  def before_sepalate
48
48
  puts ''
49
- puts '-'*60
49
+ puts '='*60
50
50
  end
51
51
 
52
52
  def after_sepalate
53
- puts '-'*60
53
+ puts '='*60
54
54
  puts ''
55
55
  end
56
56
 
data/lib/ui.rb CHANGED
@@ -10,23 +10,18 @@ module AM
10
10
  def print_current_config(config)
11
11
  aml = config.al.max_by{|c| c[0].length }[0].length #alias max length
12
12
  iml = config.al.length.to_s.length #index max length
13
- arr = [] #use delete number
14
13
 
15
- before_sepalate
16
14
  puts 'current registered alias'
17
15
  config.al.each_with_index do|(k,v),i|
18
16
  # 1: name=command
19
17
  puts " #{' '*(iml - (i+1).to_s.length)}#{(i+1).to_s} : #{k.to_s}#{' '*(aml-k.length)} = #{v.to_s}"
20
- arr << [i,k]
21
18
  end
22
19
  after_sepalate
23
- arr
24
20
  end
25
21
 
26
22
  def print_last_commands(commands)
27
23
  iml = commands.length.to_s.length #index max length
28
24
 
29
- before_sepalate
30
25
  puts 'current history commands'
31
26
  commands.each_with_index do |c,i|
32
27
  puts " #{' '*(iml - (i+1).to_s.length)}#{(i+1).to_s} : #{c.to_s}"
@@ -45,14 +40,16 @@ module AM
45
40
  alias_name = get_alias
46
41
  {alias_name => quot(commands[number.to_i-1].strip)}
47
42
  end
48
-
49
43
  end
50
44
 
51
- def del_command_with_number(arr)
45
+ def delete_command_with_number(config)
52
46
  number = get_number
53
-
54
47
  if valid?(number, "^[1-9]+$")
55
- arr[number.to_i-1][1] if arr.length >= number.to_i
48
+ if config.al.length >= number.to_i && config.al.key?(config.al.to_a[number.to_i-1][0])
49
+ config.al.to_a[number.to_i-1][0]
50
+ else
51
+ warning(:empty_config_number)
52
+ end
56
53
  else
57
54
  warning(:validate_number)
58
55
  end
data/spec/spec_helper.rb CHANGED
@@ -47,15 +47,13 @@ end
47
47
 
48
48
  def match_current_config
49
49
  return <<'EOS'
50
-
51
- ------------------------------------------------------------
52
50
  current registered alias
53
51
  1 : hoge = 'fuga'
54
52
  2 : 123 = '123'
55
53
  3 : ABC = 'ABC'
56
54
  4 : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'
57
55
  5 : ほげ = 'ふがふが'
58
- ------------------------------------------------------------
56
+ ============================================================
59
57
 
60
58
  EOS
61
59
  end
@@ -77,15 +75,13 @@ end
77
75
 
78
76
  def match_delete_list
79
77
  return <<'EOS'
80
-
81
- ------------------------------------------------------------
82
78
  current registered alias
83
79
  1 : hoge = 'fuga'
84
80
  2 : 123 = '123'
85
81
  3 : ABC = 'ABC'
86
82
  4 : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'
87
83
  5 : ほげ = 'ふがふが'
88
- ------------------------------------------------------------
84
+ ============================================================
89
85
 
90
86
  EOS
91
87
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: am
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - ka-yamashita