Module: Gas
- Defined in:
- lib/gas.rb,
lib/gas/user.rb,
lib/gas/config.rb,
lib/gas/version.rb,
lib/gas/gitconfig.rb
Defined Under Namespace
Classes: Config, Gitconfig, User
Constant Summary collapse
- VERSION =
'0.1.1'
Class Method Summary collapse
-
.add(nickname, name, email) ⇒ Object
Adds a author to the config.
-
.delete(nickname) ⇒ Object
Deletes a author from the config using nickname.
-
.has_user?(nickname) ⇒ Boolean
Checks if the user exists and gives error and exit if so.
-
.list ⇒ Object
Lists all authors.
-
.no_user?(nickname) ⇒ Boolean
Checks if the user exists and gives error and exit if not.
-
.show ⇒ Object
Shows the current user.
-
.use(nickname) ⇒ Object
Sets nickname as current user.
-
.version ⇒ Object
Prints the current version.
Class Method Details
.add(nickname, name, email) ⇒ Object
Adds a author to the config
42 43 44 45 46 47 48 49 50 |
# File 'lib/gas.rb', line 42 def self.add(nickname, name, email) self.has_user? nickname user = User.new name, email, nickname @config.add user @config.save! puts 'Added author' puts user end |
.delete(nickname) ⇒ Object
Deletes a author from the config using nickname
54 55 56 57 58 59 60 |
# File 'lib/gas.rb', line 54 def self.delete(nickname) self.no_user? nickname @config.delete nickname @config.save! puts "Deleted author #{nickname}" end |
.has_user?(nickname) ⇒ Boolean
Checks if the user exists and gives error and exit if so
78 79 80 81 82 83 |
# File 'lib/gas.rb', line 78 def self.has_user?(nickname) if @config.exists? nickname puts "Nickname #{nickname} does already exist" exit end end |
.list ⇒ Object
Lists all authors
12 13 14 15 16 17 |
# File 'lib/gas.rb', line 12 def self.list puts 'Available users:' puts @config self.show end |
.no_user?(nickname) ⇒ Boolean
Checks if the user exists and gives error and exit if not
69 70 71 72 73 74 |
# File 'lib/gas.rb', line 69 def self.no_user?(nickname) if !@config.exists? nickname puts "Nickname #{nickname} does not exist" exit end end |
.show ⇒ Object
Shows the current user
20 21 22 23 24 |
# File 'lib/gas.rb', line 20 def self.show user = @gitconfig.current_user puts 'Current user:' puts "#{user.name} <#{user.email}>" end |
.use(nickname) ⇒ Object
Sets nickname as current user
28 29 30 31 32 33 34 35 36 |
# File 'lib/gas.rb', line 28 def self.use(nickname) self.no_user? nickname user = @config[nickname] @gitconfig.change_user user.name, user.email @gitconfig.save! self.show end |
.version ⇒ Object
Prints the current version
63 64 65 |
# File 'lib/gas.rb', line 63 def self.version puts Gas::VERSION end |