Class: Swagger::Shell::User
- Inherits:
-
Object
- Object
- Swagger::Shell::User
- Defined in:
- lib/swagger/shell/user.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#info ⇒ Object
readonly
Returns the value of attribute info.
Instance Method Summary collapse
- #clean! ⇒ Object
- #create ⇒ Object
-
#debug ⇒ Object
patch.
- #list ⇒ Object
- #load(id) ⇒ Object
- #load_sample ⇒ Object
- #login ⇒ Object
- #save(id, info) ⇒ Object
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/swagger/shell/user.rb', line 4 def id @id end |
#info ⇒ Object (readonly)
Returns the value of attribute info.
4 5 6 |
# File 'lib/swagger/shell/user.rb', line 4 def info @info end |
Instance Method Details
#clean! ⇒ Object
21 22 23 24 |
# 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 ⇒ Object
33 34 35 |
# File 'lib/swagger/shell/user.rb', line 33 def create # need to override end |
#debug ⇒ Object
patch
42 43 44 45 46 47 |
# 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 ⇒ Object
17 18 19 |
# 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) ⇒ Object
12 13 14 15 |
# 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 ⇒ Object
6 7 8 9 10 |
# File 'lib/swagger/shell/user.rb', line 6 def load_sample id = list.sample return if id.nil? load(id) end |
#login ⇒ Object
37 38 39 |
# File 'lib/swagger/shell/user.rb', line 37 def login # need to override end |
#save(id, info) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/swagger/shell/user.rb', line 26 def save(id, info) @id = id @info = info save_to_yml(@id, @info) end |