acm 0.2.0 → 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.
Files changed (7) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +22 -0
  3. data/README.md +34 -2
  4. data/acm.gemspec +1 -0
  5. data/exe/acm +59 -17
  6. data/lib/acm/version.rb +1 -1
  7. metadata +5 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2babfcf9ffcf40589333a55d863e374ea23816c5
4
- data.tar.gz: 2155016055e98122a132f396bb4a1f04cb93da72
3
+ metadata.gz: 5fa11ff16e85699fdc1e641f2ef6114c53798cab
4
+ data.tar.gz: 52de884deb9bc95f615c3a6812fb375b1e7e169e
5
5
  SHA512:
6
- metadata.gz: d4d1b722eb4fd2ba7301cfbe62a499fead44cf0a30b954ddfbc7afd06c0861d416b6255ff6a4b3b58c86a989bec11a73b64a9fa1e8f4223d1887dd321989e31f
7
- data.tar.gz: cb0ce8d21e7ad700a76d3d67e3d8e8bdd207f97f6dd2423ebb75a46cb49b774f4e25a1a49c25437da2893707a5a930024b7a2d28993b2759f91508b5dcac3e19
6
+ metadata.gz: e22409dfcd9edba0b3661eaeb83aee7c0a74a1a49a6dc6d3d951590953c61ca3c41c7c41679d09442da07b043f5ac44d1d434aea7e7a0f76696bde2293edaafa
7
+ data.tar.gz: 6c81f3e140611ceb5173ad5a323a815d021548e29865565bafdeb5d2e5542859d459cc25adb78786276e03b1d607aa5fe2a1cb038ab547fc5f2853dbb9a69790
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 takatoh
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -15,7 +15,8 @@ At first, init database:
15
15
 
16
16
  > acm init
17
17
 
18
- The database file save as &HOMEDRIVE%%HOMEPATH%/Documents/.account, in YAML.
18
+ The database file is saved as %HOMEDRIVE%%HOMEPATH%/Documents/.accounts, in YAML.
19
+
19
20
  Add account:
20
21
 
21
22
  > acm add takatoh.m@gmail.com
@@ -25,7 +26,9 @@ Add account:
25
26
  (acm) Value? xxxxxxxx
26
27
  (acm) Key? # Enter to exit.
27
28
 
28
- Then added account to database. List account(s):
29
+ Then added account to database.
30
+
31
+ List account(s):
29
32
 
30
33
  > acm list
31
34
  takatoh.m@gmail.com
@@ -37,6 +40,35 @@ Show details:
37
40
  email: takatoh.m@gmail.com
38
41
  password: xxxxxxxx
39
42
 
43
+ Update value of key:
44
+
45
+ > acm update takatoh.m@gmail.com password yyyyyyyy
46
+
47
+ > acm show takatoh.m@gmail.com
48
+ Account: takatoh.m@gmail.com
49
+ email: takatoh.m@gmail.com
50
+ password: xxxxxxxx
51
+
52
+ Remove key and value:
53
+
54
+ > acm remove_key takatoh.m@gmail.com password
55
+
56
+ > acm show takatoh.m@gmail.com
57
+ Account: takatoh.m@gmail.com
58
+ email: takatoh.m@gmail.com
59
+
60
+ And remove account:
61
+
62
+ > acm remove_account takatoh.m@gmail.com
63
+ Account: takatoh.m@gmail.com
64
+ email: takatoh.m@gmail.com
65
+
66
+ Are you sure?(y/n) y # Enter 'y' to remove.
67
+
68
+ > acm show takatoh.m@gmail.com
69
+ No such account: takatoh.m@gmail.com
70
+
71
+
40
72
  ## Development
41
73
 
42
74
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake false` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
data/acm.gemspec CHANGED
@@ -12,6 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.summary = %q{A simple account manager for Windows (NOT SECURE ;p).}
13
13
  spec.description = %q{}
14
14
  spec.homepage = "https://github.com/takatoh/acm"
15
+ spec.license = "MIT"
15
16
 
16
17
  # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
17
18
  # delete this section to allow pushing this gem to any host.
data/exe/acm CHANGED
@@ -15,14 +15,13 @@ class MyCLI < Thor
15
15
  if File.exist?(DB_FILE)
16
16
  puts "Database file is already exist."
17
17
  else
18
- db = []
19
- File.open(DB_FILE, "w"){|f| f.puts db.to_yaml }
18
+ save_db([])
20
19
  end
21
20
  end
22
21
 
23
22
  desc "add ACCOUNT", "Add ACCOUNT"
24
23
  def add(account)
25
- db = YAML.load_file(DB_FILE)
24
+ db = load_db
26
25
  ac = lookup(account, db)
27
26
  if ac
28
27
  puts "Account #{account} is already exist."
@@ -42,20 +41,18 @@ class MyCLI < Thor
42
41
  details[key] = value
43
42
  end
44
43
  db << ac
45
- File.open(DB_FILE, "w"){|f| f.puts db.to_yaml }
44
+ save_db(db)
46
45
  end
47
46
 
48
47
  desc "list", "List accounts"
49
48
  def list
50
- db = YAML.load_file(DB_FILE)
51
- db.map{|a| a['account'] }.each do |a|
52
- puts a
53
- end
49
+ db = load_db
50
+ db.each{|a| puts a['account'] }
54
51
  end
55
52
 
56
53
  desc "show ACCOUNT", "Show details of ACCOUNT"
57
54
  def show(target)
58
- db = YAML.load_file(DB_FILE)
55
+ db = load_db
59
56
  account = lookup(target.encode("utf-8"), db)
60
57
  if account
61
58
  puts "Account: #{account['account']}"
@@ -67,22 +64,67 @@ class MyCLI < Thor
67
64
  end
68
65
  end
69
66
 
67
+ desc "update ACCOUNT KEY VALUE", "Update value of KEY in ACCOUNT"
68
+ def update(target, key, value)
69
+ db = load_db
70
+ account = lookup(target.encode("utf-8"), db)
71
+ if account
72
+ account['details'][key] = value
73
+ save_db(db)
74
+ else
75
+ puts "No such account: #{target}"
76
+ end
77
+ end
78
+
79
+ desc "remove_key ACCOUNT KEY", "Remove KEY and value in ACCOUNT"
80
+ def remove_key(target, key)
81
+ db = load_db
82
+ account = lookup(target.encode("utf-8"), db)
83
+ if account
84
+ account['details'].delete(key)
85
+ save_db(db)
86
+ else
87
+ puts "No such account: #{target}"
88
+ end
89
+ end
90
+
91
+ desc "remove_account ACCOUNT", "Remove ACCOUNT"
92
+ def remove_account(target)
93
+ db = load_db
94
+ account = lookup(target.encode("utf-8"), db)
95
+ if account
96
+ puts "Account: #{target}"
97
+ account['details'].each do |k, v|
98
+ puts " #{k}: #{v}"
99
+ end
100
+ print "\nAre you sure?(y/n) "
101
+ if STDIN.gets.chomp.downcase == "y"
102
+ db.reject!{|a| a['account'] == target.encode("utf-8") }
103
+ save_db(db)
104
+ end
105
+ else
106
+ puts "No such account: #{target}"
107
+ end
108
+ end
109
+
70
110
  desc "version", "Show version and exit"
71
111
  def version
72
112
  puts "v#{Acm::VERSION}"
73
113
  end
74
114
 
115
+
75
116
  private
76
117
 
118
+ def load_db
119
+ YAML.load_file(DB_FILE)
120
+ end
121
+
77
122
  def lookup(target, db)
78
- ac = nil
79
- db.each do |a|
80
- if a['account'] == target
81
- ac = a
82
- break
83
- end
84
- end
85
- ac
123
+ db.find{|a| a['account'] == target }
124
+ end
125
+
126
+ def save_db(db)
127
+ File.open(DB_FILE, "w"){|f| f.puts db.to_yaml }
86
128
  end
87
129
 
88
130
  end # of class MyCLI
data/lib/acm/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Acm
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - takatoh
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-10-19 00:00:00.000000000 Z
11
+ date: 2015-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -63,6 +63,7 @@ files:
63
63
  - ".gitignore"
64
64
  - ".travis.yml"
65
65
  - Gemfile
66
+ - LICENSE.txt
66
67
  - README.md
67
68
  - Rakefile
68
69
  - acm.gemspec
@@ -72,7 +73,8 @@ files:
72
73
  - lib/acm.rb
73
74
  - lib/acm/version.rb
74
75
  homepage: https://github.com/takatoh/acm
75
- licenses: []
76
+ licenses:
77
+ - MIT
76
78
  metadata: {}
77
79
  post_install_message:
78
80
  rdoc_options: []