Class: Gtool::Provision::Nickname
- Inherits:
-
Thor
- Object
- Thor
- Gtool::Provision::Nickname
- Includes:
- Util
- Defined in:
- lib/gtool/provision/nickname.rb
Class Method Summary collapse
Instance Method Summary collapse
Methods included from Util
Class Method Details
.banner(task, namespace = true, subcommand = false) ⇒ Object
62 63 64 |
# File 'lib/gtool/provision/nickname.rb', line 62 def self.(task, namespace = true, subcommand = false) "#{basename} #{task.formatted_usage(self, true, subcommand)}" end |
Instance Method Details
#create(username, nickname) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/gtool/provision/nickname.rb', line 50 def create(username, nickname) connection = Gtool::Auth.connection() nick = GProv::Provision::Nickname.new(:connection => connection) nick.login = username nick.nickname = nickname nick.create! invoke "user:nickname:get", [nickname] end |
#get(username) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/gtool/provision/nickname.rb', line 34 def get(username) connection = Gtool::Auth.connection() nicknames = GProv::Provision::Nickname.all(connection, .merge(:username => username)) fields = GProv::Provision::Nickname.attribute_names field_names = GProv::Provision::Nickname.attribute_titles rows = nicknames.map do |nickname| fields.map {|f| nickname.send f} end rows.unshift field_names print_table rows say "#{rows.length - 1} entries.", :cyan end |
#list ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/gtool/provision/nickname.rb', line 18 def list connection = Gtool::Auth.connection() nicknames = GProv::Provision::Nickname.all(connection, ) fields = GProv::Provision::Nickname.attribute_names field_names = GProv::Provision::Nickname.attribute_titles rows = nicknames.map do |nickname| fields.map {|f| nickname.send f} end rows.unshift field_names print_table rows say "#{rows.length - 1} entries.", :cyan end |