streetcreds 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: af6ecc10882372da78cf976cce4482a0dee27969
4
+ data.tar.gz: c14be195d64e2cd331c53cd6867bd2505c1d468c
5
+ SHA512:
6
+ metadata.gz: db85e2f896f184c5af86d826e90ab5a728e521626cb4b015357f2a604e58a6098753784a9259efbfdade8a30dd3562362a6d2d7bf778c69cf19b6306f8db35f9
7
+ data.tar.gz: 1c4e35f11fd7963ae413a932d78f24c3ebef0ce894a3da644b89daa3313009540be01a8ce0ef6095253876cce870246c80e9831f0b94db1b2e4b8324b5907925
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ *.gem
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in 1s.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,20 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ streetcreds (0.1.0)
5
+ colorize
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ colorize (0.7.7)
11
+
12
+ PLATFORMS
13
+ ruby
14
+
15
+ DEPENDENCIES
16
+ bundler (~> 1.10)
17
+ streetcreds!
18
+
19
+ BUNDLED WITH
20
+ 1.10.6
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Wesley Boynton
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,38 @@
1
+ # StreetCreds
2
+
3
+ StreetCreds is a little tiny library to handle reading/writing credentials for ruby apps. I wrote it mostly because I do this a lot, and I want to stop re-writing my own code. I'm sure someone else has done it, but my apps all already use my code, so this should work as a drop-in replacement.
4
+
5
+ I plan to add stuff like:
6
+ - Safer (non plaintext) storage
7
+ - Database-based storage
8
+ - Password Generation
9
+
10
+ It's not in rubygems yet.
11
+
12
+ ## Usage
13
+
14
+ TODO
15
+
16
+ ## License
17
+
18
+ The MIT License (MIT)
19
+
20
+ Copyright (c) 2015 Wesley Boynton
21
+
22
+ Permission is hereby granted, free of charge, to any person obtaining a copy
23
+ of this software and associated documentation files (the "Software"), to deal
24
+ in the Software without restriction, including without limitation the rights
25
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
26
+ copies of the Software, and to permit persons to whom the Software is
27
+ furnished to do so, subject to the following conditions:
28
+
29
+ The above copyright notice and this permission notice shall be included in
30
+ all copies or substantial portions of the Software.
31
+
32
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
33
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
34
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
35
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
36
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
37
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
38
+ THE SOFTWARE.
data/lib/streetcred.rb ADDED
@@ -0,0 +1,101 @@
1
+ require 'streetcreds/version'
2
+ require 'colorize'
3
+
4
+ module StreetCreds
5
+ class Credentials
6
+ # rubocop:disable Style/PredicateName
7
+
8
+ require 'singleton'
9
+ include Singleton
10
+ attr_accessor :credentials
11
+
12
+ def initialize
13
+ end
14
+
15
+ def set_up(cred_file)
16
+ @cred_file = cred_file
17
+ @sample_file = "#{cred_file}.sample"
18
+ check_dir
19
+ check_file
20
+ @credentials = YAML.load_file(@cred_file) || {}
21
+ end
22
+
23
+ def check_dir
24
+ cred_path = get_cred_path
25
+ unless File.exist?(cred_path)
26
+ puts "Creating credentials directory at '#{cred_path}'"
27
+ FileUtils.mkdir_p(cred_path)
28
+ end
29
+ end
30
+
31
+ def check_file
32
+ unless File.exist?(@cred_file)
33
+ puts "There is no credentials.yml file at '#{@cred_file.yellow}'".red
34
+ puts "Please fill out the sample file at '#{@sample_file.yellow}' and copy it to '#{@cred_file.yellow}'".red
35
+ if !File.exist?(@cred_file) && !File.exist?(@sample_file)
36
+ File.open(@sample_file, 'w') { |f| f.write(sample) }
37
+ end
38
+ raise StandardError
39
+ end
40
+ end
41
+
42
+
43
+ def get_cred_path
44
+ @cred_file.split('/')[0..-2].join('/')
45
+ end
46
+
47
+ def save
48
+ File.open(@cred_file, 'w') { |f| f.write(@credentials.to_yaml) }
49
+ end
50
+
51
+ def [](key)
52
+ @credentials[key]
53
+ end
54
+
55
+ def []=(key, val)
56
+ @credentials[key] = val
57
+ end
58
+
59
+ def has_key?(key)
60
+ @credentials.has_key?(key)
61
+ end
62
+
63
+ def self.has_key?(key)
64
+ Credentials.instance.has_key?(key)
65
+ end
66
+
67
+ def self.[](key)
68
+ Credentials.instance[key]
69
+ end
70
+
71
+ def self.[]=(key, val)
72
+ Credentials.instance[key] = val
73
+ end
74
+
75
+ def self.save
76
+ Credentials.instance.save
77
+ end
78
+
79
+ def self.credentials
80
+ Credentials.instance.credentials
81
+ end
82
+
83
+ def sample
84
+ <<EOS
85
+ ---
86
+ :google:
87
+ :username:
88
+ :password:
89
+ :google_drive:
90
+ :client_id:
91
+ :client_secret:
92
+ :github:
93
+ :username:
94
+ :password:
95
+ :hipchat:
96
+ :token:
97
+ EOS
98
+ end
99
+ end
100
+ end
101
+
@@ -0,0 +1,3 @@
1
+ module StreetCreds
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'streetcreds/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "streetcreds"
8
+ spec.version = StreetCreds::VERSION
9
+ spec.authors = ["Wesley Boynton"]
10
+ spec.email = ["wes@boynton.io"]
11
+
12
+ spec.summary = %q{Manage credentials with ease!}
13
+ spec.homepage = "https://www.github.com/wwboynton/streetcreds"
14
+ spec.license = "MIT"
15
+
16
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
17
+ # delete this section to allow pushing this gem to any host.
18
+ if spec.respond_to?(:metadata)
19
+ spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
20
+ else
21
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
22
+ end
23
+
24
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ spec.bindir = "bin"
26
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
27
+ spec.require_paths = ["lib"]
28
+
29
+ spec.add_runtime_dependency 'colorize'
30
+
31
+ spec.add_development_dependency "bundler", "~> 1.10"
32
+ end
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: streetcreds
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Wesley Boynton
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-11-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: colorize
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
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: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.10'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.10'
41
+ description:
42
+ email:
43
+ - wes@boynton.io
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - .gitignore
49
+ - Gemfile
50
+ - Gemfile.lock
51
+ - LICENSE.txt
52
+ - README.md
53
+ - lib/streetcred.rb
54
+ - lib/streetcreds/version.rb
55
+ - streetcreds.gemspec
56
+ homepage: https://www.github.com/wwboynton/streetcreds
57
+ licenses:
58
+ - MIT
59
+ metadata:
60
+ allowed_push_host: 'TODO: Set to ''http://mygemserver.com'''
61
+ post_install_message:
62
+ rdoc_options: []
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ requirements: []
76
+ rubyforge_project:
77
+ rubygems_version: 2.0.14
78
+ signing_key:
79
+ specification_version: 4
80
+ summary: Manage credentials with ease!
81
+ test_files: []