From 96d49bf04ce77c975fe500f4d961e4a1ffed4c26 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sun, 30 Dec 2012 14:43:00 +0200 Subject: Use sdoc to generate application code documentation --- doc/code/classes/Key.html | 429 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 429 insertions(+) create mode 100644 doc/code/classes/Key.html (limited to 'doc/code/classes/Key.html') diff --git a/doc/code/classes/Key.html b/doc/code/classes/Key.html new file mode 100644 index 00000000000..0935e4862ef --- /dev/null +++ b/doc/code/classes/Key.html @@ -0,0 +1,429 @@ + + + + + Key + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + +
Methods
+
+ +
F
+
+ +
+ +
I
+
+ +
+ +
L
+
+ +
+ +
P
+
+ +
+ +
S
+
+ +
+ +
U
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + +
Instance Public methods
+ +
+
+ + fingerprintable_key() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File app/models/key.rb, line 44
+def fingerprintable_key
+  return true unless key # Don't test if there is no key.
+  # `ssh-keygen -lf /dev/stdin <<< "#{key}"` errors with: redirection unexpected
+  file = Tempfile.new('key_file')
+  begin
+    file.puts key
+    file.rewind
+    fingerprint_output = %xssh-keygen -lf #{file.path} 2>&1` # Catch stderr.
+  ensure
+    file.close
+    file.unlink # deletes the temp file
+  end
+  errors.add(:key, "can't be fingerprinted") if fingerprint_output.match("failed")
+end
+
+
+ +
+ +
+
+ + is_deploy_key() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File app/models/key.rb, line 67
+def is_deploy_key
+  true if project_id
+end
+
+
+ +
+ +
+
+ + last_deploy?() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File app/models/key.rb, line 80
+def last_deploy?
+  Key.where(identifier: identifier).count == 0
+end
+
+
+ +
+ +
+
+ + projects() + + +
+ + +
+

projects that has this key

+
+ + + + + + +
+ + +
+
# File app/models/key.rb, line 72
+def projects
+  if is_deploy_key
+    [project]
+  else
+    user.projects
+  end
+end
+
+
+ +
+ +
+
+ + set_identifier() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File app/models/key.rb, line 59
+def set_identifier
+  if is_deploy_key
+    self.identifier = "deploy_#{Digest::MD5.hexdigest(key)}"
+  else
+    self.identifier = "#{user.identifier}_#{Time.now.to_i}"
+  end
+end
+
+
+ +
+ +
+
+ + strip_white_space() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File app/models/key.rb, line 32
+def strip_white_space
+  self.key = self.key.strip unless self.key.blank?
+end
+
+
+ +
+ +
+
+ + unique_key() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File app/models/key.rb, line 36
+def unique_key
+  query = Key.where(key: key)
+  query = query.where('(project_id IS NULL OR project_id = ?)', project_id) if project_id
+  if (query.count > 0)
+    errors.add :key, 'already exist.'
+  end
+end
+
+
+ +
+
+ +
+ + \ No newline at end of file -- cgit v1.2.1