collins_auth 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/collins_auth.rb +11 -11
  3. metadata +14 -22
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9d66f3699148c1b27613bbe6988a2e092b6a70b2
4
+ data.tar.gz: 2b12164630c513d1fd19379c21f8d44bcca15808
5
+ SHA512:
6
+ metadata.gz: 9cff54a601c78031421d97f8aecb74fd84342efc186dfa6ed5f111ebfd8c7e5a7780457309153017f2cec30d5bb8a0375c381d58be1dc21ba4d6dd5572e5ccf0
7
+ data.tar.gz: 43e86f9aca5ed6738ea2bba434017ebca6ed7c03fff060d8cbc4249d044b28cf28e45550eb9b9120bdb34bc9ffdcf501cbaea3a69f50bb76b1f1a3254fa69799
data/lib/collins_auth.rb CHANGED
@@ -5,7 +5,7 @@ require 'socket'
5
5
 
6
6
  module Collins
7
7
  module Authenticator
8
- def self.setup_client(options = {prompt: false})
8
+ def self.setup_client(options = {:prompt => false})
9
9
  if options[:config_file] and not File.readable? options[:config_file]
10
10
  raise 'unable to read invalid config file: ' + options[:config_file]
11
11
  end
@@ -14,23 +14,23 @@ module Collins
14
14
  end
15
15
 
16
16
  def self.load_config(options = {})
17
- conf = (read_config(options[:config_file]) || {}).merge(options) unless options[:prompt] == :only
18
-
17
+ conf = (options[:prompt] == :only) ? {} : (read_config(options[:config_file]) || {}).merge(options)
18
+
19
19
  # check if we have all that we expect
20
20
  if [:username, :password, :host].all? {|key| conf.keys.include? key}
21
21
  return conf
22
22
  end
23
-
23
+
24
24
  # Something is missing. Can we prompt for it?
25
25
  if options[:prompt]
26
26
  conf.merge!(prompt_creds(conf))
27
27
  else
28
28
  raise "could not load any valid configuration."
29
29
  end
30
-
30
+
31
31
  conf
32
32
  end
33
-
33
+
34
34
  private
35
35
  def self.file2conf(file)
36
36
  if file and File.readable? file
@@ -49,20 +49,20 @@ module Collins
49
49
  conf[:host] ||= ask('host: ') {|host| host.default = ['https://collins', get_domain].compact.join('.')}
50
50
  conf
51
51
  end
52
-
52
+
53
53
  def self.read_config(config_file = nil)
54
54
  home_config_file = File.join(ENV['HOME'], '.collins.yml') unless ENV['HOME'].nil?
55
55
 
56
56
  config_file ||= [ENV['COLLINS_CLIENT_CONFIG'], home_config_file, '/etc/collins.yml', '/var/db/collins.yml'].compact.find do |config_file|
57
57
  File.readable? config_file and File.size(config_file) > 0
58
58
  end
59
-
59
+
60
60
  file2conf config_file
61
- end
62
-
61
+ end
62
+
63
63
  def self.get_domain
64
64
  hostname = Socket.gethostname.downcase.split('.')
65
-
65
+
66
66
  if hostname.length > 1
67
67
  hostname.shift
68
68
  hostname.join('.')
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: collins_auth
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.1.1
4
+ version: 0.1.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Michael Benedict
@@ -10,15 +9,15 @@ autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
11
 
13
- date: 2013-11-22 00:00:00 Z
12
+ date: 2014-07-08 00:00:00 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: collins_client
17
16
  prerelease: false
18
17
  requirement: &id001 !ruby/object:Gem::Requirement
19
- none: false
20
18
  requirements:
21
- - - ">="
19
+ - &id002
20
+ - ">="
22
21
  - !ruby/object:Gem::Version
23
22
  version: "0"
24
23
  type: :runtime
@@ -26,14 +25,11 @@ dependencies:
26
25
  - !ruby/object:Gem::Dependency
27
26
  name: highline
28
27
  prerelease: false
29
- requirement: &id002 !ruby/object:Gem::Requirement
30
- none: false
28
+ requirement: &id003 !ruby/object:Gem::Requirement
31
29
  requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: "0"
30
+ - *id002
35
31
  type: :runtime
36
- version_requirements: *id002
32
+ version_requirements: *id003
37
33
  description: This is a library to make it easy to obtain an authenticated collins_client object. It attempts to load credentials from the following yaml files ENV['COLLINS_CLIENT_CONFIG'], ~/.collins.yml, /etc/collins.yml, /var/db/collins.yml, and supports user input.
38
34
  email: benedict@tumblr.com
39
35
  executables: []
@@ -44,34 +40,30 @@ extra_rdoc_files: []
44
40
 
45
41
  files:
46
42
  - lib/collins_auth.rb
47
- - readme.md
48
43
  - license.txt
44
+ - readme.md
49
45
  homepage: https://github.com/tumblr/collins/tree/master/support/ruby/collins-auth
50
46
  licenses:
51
47
  - Apache License 2.0
48
+ metadata: {}
49
+
52
50
  post_install_message:
53
51
  rdoc_options: []
54
52
 
55
53
  require_paths:
56
54
  - lib
57
55
  required_ruby_version: !ruby/object:Gem::Requirement
58
- none: false
59
56
  requirements:
60
- - - ">="
61
- - !ruby/object:Gem::Version
62
- version: "0"
57
+ - *id002
63
58
  required_rubygems_version: !ruby/object:Gem::Requirement
64
- none: false
65
59
  requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: "0"
60
+ - *id002
69
61
  requirements: []
70
62
 
71
63
  rubyforge_project:
72
- rubygems_version: 1.8.10
64
+ rubygems_version: 2.3.0
73
65
  signing_key:
74
- specification_version: 3
66
+ specification_version: 4
75
67
  summary: Library to aid in getting an authenticated Collins::Client
76
68
  test_files: []
77
69