Class: Nugem::Repository
- Inherits:
-
Object
- Object
- Nugem::Repository
- Defined in:
- lib/nugem/repository.rb
Defined Under Namespace
Classes: Host
Constant Summary collapse
- HOSTS =
[ Host.new(domain: 'github.com', camel_case: 'GitHub', id: :github), Host.new(domain: 'bitbucket.org', camel_case: 'BitBucket', id: :bitbucket), ].freeze
Instance Attribute Summary collapse
-
#gem_server_url ⇒ Object
readonly
Returns the value of attribute gem_server_url.
-
#global_config ⇒ Object
readonly
Returns the value of attribute global_config.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#private ⇒ Object
readonly
Returns the value of attribute private.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
-
#user_email ⇒ Object
readonly
Returns the value of attribute user_email.
-
#user_name ⇒ Object
readonly
Returns the value of attribute user_name.
Instance Method Summary collapse
- #bitbucket? ⇒ Boolean
- #github? ⇒ Boolean
-
#initialize(options) ⇒ Repository
constructor
A new instance of Repository.
- #origin ⇒ Object
-
#private? ⇒ Boolean
TODO: Currently all private repositories are on BitBucket and all public repos are on GitHub TODO: Drop BitBucket? TODO: Support private repos on GitHub.
- #public? ⇒ Boolean
- #url ⇒ Object
Constructor Details
#initialize(options) ⇒ Repository
Returns a new instance of Repository.
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/nugem/repository.rb', line 12 def initialize() @host = HOSTS.find { |host| host.id == [:host] } @private = [:private] @name = [:name] @user = [:user] @global_config = Rugged::Config.global abort 'Git global config not found' if @global_config.nil? @user_name = @global_config['user.name'] @user_email = @global_config['user.email'] @gem_server_url = [:gem_server_url] @private = [:private] end |
Instance Attribute Details
#gem_server_url ⇒ Object (readonly)
Returns the value of attribute gem_server_url.
4 5 6 |
# File 'lib/nugem/repository.rb', line 4 def gem_server_url @gem_server_url end |
#global_config ⇒ Object (readonly)
Returns the value of attribute global_config.
4 5 6 |
# File 'lib/nugem/repository.rb', line 4 def global_config @global_config end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
4 5 6 |
# File 'lib/nugem/repository.rb', line 4 def host @host end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/nugem/repository.rb', line 4 def name @name end |
#private ⇒ Object (readonly)
Returns the value of attribute private.
4 5 6 |
# File 'lib/nugem/repository.rb', line 4 def private @private end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
4 5 6 |
# File 'lib/nugem/repository.rb', line 4 def user @user end |
#user_email ⇒ Object (readonly)
Returns the value of attribute user_email.
4 5 6 |
# File 'lib/nugem/repository.rb', line 4 def user_email @user_email end |
#user_name ⇒ Object (readonly)
Returns the value of attribute user_name.
4 5 6 |
# File 'lib/nugem/repository.rb', line 4 def user_name @user_name end |
Instance Method Details
#bitbucket? ⇒ Boolean
26 27 28 |
# File 'lib/nugem/repository.rb', line 26 def bitbucket? @host.id == :bitbucket end |
#github? ⇒ Boolean
30 31 32 |
# File 'lib/nugem/repository.rb', line 30 def github? @host.id == :github end |
#origin ⇒ Object
34 35 36 |
# File 'lib/nugem/repository.rb', line 34 def origin "git@#{@host.domain}:#{@user}/#{@name}.git" end |
#private? ⇒ Boolean
TODO: Currently all private repositories are on BitBucket and all public repos are on GitHub TODO: Drop BitBucket? TODO: Support private repos on GitHub
41 42 43 |
# File 'lib/nugem/repository.rb', line 41 def private? @private end |
#public? ⇒ Boolean
45 46 47 |
# File 'lib/nugem/repository.rb', line 45 def public? !@private end |
#url ⇒ Object
49 50 51 |
# File 'lib/nugem/repository.rb', line 49 def url "https://#{@host.domain}/#{@user}/#{@name}" end |