authkeys 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,4 +19,5 @@ Gem::Specification.new do |spec|
19
19
 
20
20
  spec.add_development_dependency "bundler", "~> 1.3"
21
21
  spec.add_development_dependency "rake"
22
+ spec.add_development_dependency "rspec"
22
23
  end
@@ -1,5 +1,9 @@
1
1
  require "authkeys/version"
2
+ require "authkeys/key"
3
+ require "authkeys/key_collection"
2
4
 
3
5
  module Authkeys
4
- # Your code goes here...
6
+ def self.keys(filename)
7
+ KeyCollection.new(filename)
8
+ end
5
9
  end
@@ -0,0 +1,7 @@
1
+ module Authkeys
2
+ class Key
3
+ def initialize(data)
4
+ @data = data
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,33 @@
1
+ module Authkeys
2
+ class KeyCollection
3
+ def initialize(file)
4
+ @file = file
5
+ end
6
+
7
+ def each(&block)
8
+ keys.each do |key|
9
+ yield(key)
10
+ end
11
+ end
12
+
13
+ private
14
+
15
+ def keys
16
+ key_lines.collect do |line|
17
+ Key.new(line)
18
+ end
19
+ end
20
+
21
+ def key_lines
22
+ raw_lines.reject {|item| item.strip.empty? || item.strip.start_with?("#") }
23
+ end
24
+
25
+ def raw_lines
26
+ file_data.split("\n")
27
+ end
28
+
29
+ def file_data
30
+ @file_data ||= File.read(@file)
31
+ end
32
+ end
33
+ end
@@ -1,3 +1,3 @@
1
1
  module Authkeys
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -0,0 +1 @@
1
+ require 'authkeys'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: authkeys
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Joshua B. Bussdieker
@@ -46,6 +46,20 @@ dependencies:
46
46
  version: "0"
47
47
  type: :development
48
48
  version_requirements: *id002
49
+ - !ruby/object:Gem::Dependency
50
+ name: rspec
51
+ prerelease: false
52
+ requirement: &id003 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ hash: 3
58
+ segments:
59
+ - 0
60
+ version: "0"
61
+ type: :development
62
+ version_requirements: *id003
49
63
  description:
50
64
  email:
51
65
  - jbussdieker@gmail.com
@@ -63,7 +77,10 @@ files:
63
77
  - Rakefile
64
78
  - authkeys.gemspec
65
79
  - lib/authkeys.rb
80
+ - lib/authkeys/key.rb
81
+ - lib/authkeys/key_collection.rb
66
82
  - lib/authkeys/version.rb
83
+ - spec/spec_helper.rb
67
84
  homepage: ""
68
85
  licenses:
69
86
  - MIT
@@ -97,5 +114,5 @@ rubygems_version: 1.8.15
97
114
  signing_key:
98
115
  specification_version: 3
99
116
  summary: Manage authorized keys files
100
- test_files: []
101
-
117
+ test_files:
118
+ - spec/spec_helper.rb