lib/open_source/owner.rb in opensource-0.6.1 vs lib/open_source/owner.rb in opensource-0.6.2
- old
+ new
@@ -1,35 +1,31 @@
module OpenSource
module Owner
extend self
- def set_credentials
- puts "Enter full name: "
- name = gets.chomp
- puts "Enter email address: "
- email = gets.chomp
+ OSRC_PATH = File.expand_path("~/.osrc")
- f = File.new(File.expand_path("~/.osrc"), "w")
- f.write <<-CREDENTIALS
- name: #{name}
- email: #{email}
+ def set_credentials credentials
+ f = File.new(OSRC_PATH, "w")
+ f.write <<-CREDENTIALS.gsub /^\s+/, ""
+ name: #{credentials[:name]}
+ email: #{credentials[:email]}
+ escaped_email: <#{credentials[:email]}>
CREDENTIALS
f.close
end
def get_credentials
- user = {}
+ credentials = {}
- IO.foreach(File.expand_path("~/.osrc")) do |line|
+ IO.foreach(OSRC_PATH) do |line|
current_line = line.strip
if !current_line.empty?
key, value = current_line.split(':')
- user[key.strip] = value.strip
+ credentials[key.strip.to_sym] = value.strip
end
end
- user['escaped_email'] = "<#{user['email']}>"
-
- user
+ credentials
end
end
end