class Swagger::Shell::User
Attributes
id[R]
info[R]
Public Instance Methods
clean!()
click to toggle source
# File lib/swagger/shell/user.rb, line 21 def clean! Dir.glob("#{users_path}/#{Swagger::Shell.env}.*.yml") {|f| File.delete f } @info = nil end
create()
click to toggle source
# File lib/swagger/shell/user.rb, line 33 def create # need to override end
debug()
click to toggle source
patch
# File lib/swagger/shell/user.rb, line 42 def debug command = "open #{Swagger::Shell.config_env.debug_url}/#{id}" puts command `#{command}` nil end
list()
click to toggle source
# File lib/swagger/shell/user.rb, line 17 def list Dir.glob("#{users_path}/#{Swagger::Shell.env}.*.yml").map {|f| File.basename(f, ".yml").gsub(/^#{Swagger::Shell.env}\./, "") } end
load(id)
click to toggle source
# File lib/swagger/shell/user.rb, line 12 def load(id) @id = id @info = YAML.load_file("#{users_path}/#{Swagger::Shell.env}.#{@id}.yml") end
load_sample()
click to toggle source
# File lib/swagger/shell/user.rb, line 6 def load_sample id = list.sample return if id.nil? load(id) end
login()
click to toggle source
# File lib/swagger/shell/user.rb, line 37 def login # need to override end
save(id, info)
click to toggle source
# File lib/swagger/shell/user.rb, line 26 def save(id, info) @id = id @info = info save_to_yml(@id, @info) end
Private Instance Methods
save_to_yml(filename, data)
click to toggle source
# File lib/swagger/shell/user.rb, line 51 def save_to_yml(filename, data) FileUtils.mkdir_p(users_path) open("#{users_path}/#{Swagger::Shell.env}.#{filename}.yml","w") do |f| YAML.dump(data, f) end end
users_path()
click to toggle source
# File lib/swagger/shell/user.rb, line 58 def users_path Swagger::Shell.config_pry.users_path end