class FileStorage
Constants
- CONFIG_DIR
- CONFIG_FILE
- KEEP_KEYS
- REPOS_FILE
Attributes
repo[R]
Public Class Methods
get_input(prompt, echo = true)
click to toggle source
# File lib/mygit.rb, line 49 def get_input prompt, echo = true ask(prompt) {|q| q.echo = echo} end
new()
click to toggle source
# File lib/mygit.rb, line 24 def initialize @repo ||= YAML.load_file REPOS_FILE if File.exist?(REPOS_FILE) end
remove_keys(array)
click to toggle source
# File lib/mygit.rb, line 41 def remove_keys array keep = [] array.each do |a| keep << a.keep_if {|k| KEEP_KEYS.include? k } end keep end
save(data)
click to toggle source
# File lib/mygit.rb, line 53 def save data File.open(REPOS_FILE, "w+") {|f| f.puts(data.to_yaml) } # File.open(fnm, ‘w’) { |out| YAML.dump(h, out) } end
update(filename = CONFIG_FILE)
click to toggle source
# File lib/mygit.rb, line 29 def update filename = CONFIG_FILE # Get username from prompt if file missing file = File.expand_path filename conf = YAML.load_file file gh = GitHub.new(conf['user'], get_input("Enter password: ", '*')) repo = gh.repos(conf['repo']) keep = remove_keys repo save keep end