Src C0 Coverage Information - RCov

lib/model/consumer.rb

Name Total Lines Lines of Code Total Coverage Code Coverage
lib/model/consumer.rb 62 40
79.03%
67.50%

Key

Code reported as executed by Ruby looks like this...and this: this line is also marked as covered.Lines considered as run by rcov, but not reported by Ruby, look like this,and this: these lines were inferred by rcov (using simple heuristics).Finally, here's a line marked as not executed.

Coverage Details

1 #
2 #   Copyright [2011] [Red Hat, Inc.]
3 #
4 #   Licensed under the Apache License, Version 2.0 (the "License");
5 #   you may not use this file except in compliance with the License.
6 #   You may obtain a copy of the License at
7 #
8 #   http://www.apache.org/licenses/LICENSE-2.0
9 #
10 #   Unless required by applicable law or agreed to in writing, software
11 #   distributed under the License is distributed on an "AS IS" BASIS,
12 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 #   See the License for the specific language governing permissions and
14 #  limitations under the License.
15 #
16 module ConfigServer
17   module Model
18     class Consumer < Base
19       def self.storage_path
20         super "oauth"
21       end
22 
23       def self.find(key)
24         consumer = Consumer.new(key)
25         consumer.load
26       end
27 
28       def self.create(key, secret)
29         consumer = Consumer.new(key)
30         consumer.store(secret)
31       end
32 
33       attr_reader :key, :secret
34       def initialize(key)
35         super()
36         @key = key
37         @secret = nil
38       end
39 
40       def store(secret)
41         File.open(path, "w", 0600) {|f| f.write(secret)}
42         self
43       end
44 
45       def load
46         if exists?
47           File.open(path, "r") {|f| @secret = f.read.chomp}
48           self
49         end
50       end
51 
52       private
53       def path
54         File.join(Consumer.storage_path, key)
55       end
56 
57       def exists?
58         File.exists?(path)
59       end
60     end
61   end
62 end

Generated on Wed Dec 14 16:00:31 -0500 2011 with rcov 0.9.11