cli_credentials 0.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e6a482b8bd0365fcf98f1d84685f315ebb8fa243
4
+ data.tar.gz: 50abaee2255b7fa328d485380f9c7c07ba9ecd7f
5
+ SHA512:
6
+ metadata.gz: 51b4aa5486e778063f6a98fec68cec2b85ffe88bfa5b9b960e0bf7a035c8607db00d2b5f04bc3d8df185272057f07a9f2c8dfb77af8673962989f90fcebe99ca
7
+ data.tar.gz: dd7bc04f7324c8eb7de4eea557043c16f30733d1f63dbe61d0be40e84a123d262be3f0aae6066273bc5a58783c8ab19bc11a29e389792b39b3abfaae7df9de84
@@ -0,0 +1,3 @@
1
+ module CLICredentials
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,39 @@
1
+ require 'cli_credentials/version'
2
+ require 'io/console'
3
+
4
+ # Stores credentials for a user in memory
5
+ # Prompts user for credentials if they aren't already stored
6
+ class CLICredentials
7
+ attr_reader :title
8
+
9
+ def initialize(username = nil, opts = {})
10
+ @username = username
11
+ @title = opts[:title] if opts[:title]
12
+ end
13
+
14
+ # Semantically nicer equivalent to new
15
+ def self.for(username)
16
+ instance = self.new(username)
17
+ end
18
+
19
+ def prompt_for_username
20
+ print "#{title.to_s + ' ' if title}Username: "
21
+ gets.chomp
22
+ end
23
+
24
+ def prompt_for_password
25
+ print "#{title.to_s + ' ' if title}Password: "
26
+ password = ''
27
+ $stdin.noecho {|io| password = $stdin.gets.chomp}
28
+ print "\n\n"
29
+ password
30
+ end
31
+
32
+ def username
33
+ @username ||= prompt_for_username
34
+ end
35
+
36
+ def password
37
+ @password ||= prompt_for_password
38
+ end
39
+ end
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cli_credentials
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Josh Bodah
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-07-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: minitest
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '5'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '5'
41
+ description: A simple, no-frills class for prompting users for their credentials.
42
+ Great for command line tools
43
+ email: jb3689@yahoo.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - lib/cli_credentials.rb
49
+ - lib/cli_credentials/version.rb
50
+ homepage: https://github.com/jbodah/cli_credentials
51
+ licenses:
52
+ - MIT
53
+ metadata: {}
54
+ post_install_message:
55
+ rdoc_options: []
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ requirements: []
69
+ rubyforge_project:
70
+ rubygems_version: 2.2.2
71
+ signing_key:
72
+ specification_version: 4
73
+ summary: minimal credentials manager for command line apps
74
+ test_files: []