Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Fuchs committed Apr 5, 2010
1 parent d145d01 commit d286f5e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
3 changes: 1 addition & 2 deletions lib/gem_release/gemspec.rb
Expand Up @@ -7,8 +7,7 @@ def initialize(options = {})

@authors ||= [`git config --get user.name`.strip]
@email ||= `git config --get user.email`.strip
@github_user ||= `git config --get github.user`.strip
@homepage ||= "http://github.com/#{@github_user}/#{name}" || "[your github name]"
@homepage ||= "http://github.com/#{github_user}/#{name}" || "[your github name]"

@summary ||= '[summary]'
@description ||= '[description]'
Expand Down
18 changes: 11 additions & 7 deletions lib/gem_release/helpers.rb
Expand Up @@ -5,25 +5,29 @@ module Helpers
def github_user
@github_user ||= `git config --get github.user`.strip
end

def github_token
@github_token ||= `git config --get github.token`.strip
end

def gem_name
@gem_name ||= gemspec ? gemspec.name : File.basename(Dir.pwd)
@gem_name ||= gemspec ? gemspec.name : gem_name_from_directory
end

def gem_name_from_directory
File.basename(Dir.pwd)
end

def gem_filename
gemspec.file_name
end

def gem_version
gemspec.version.to_s
end

def gemspec
@gemspec ||= silence { Gem::Specification.load(gemspec_filename) }
@gemspec ||= Gem::Specification.load(gemspec_filename) # silence { }
rescue LoadError, RuntimeError
nil
end
Expand Down
7 changes: 5 additions & 2 deletions lib/gem_release/template.rb
Expand Up @@ -4,12 +4,15 @@

module GemRelease
class Template
attr_reader :name, :module_name, :module_path
include GemRelease::Helpers

attr_reader :name, :module_name, :module_path, :options

def initialize(options = {})
@options = options
options.each { |key, value| instance_variable_set(:"@#{key}", value) }

@name ||= File.basename(Dir.pwd)
@name ||= gem_name_from_directory
@module_path ||= name.gsub('-', '_')
@module_name ||= module_path.camelize
end
Expand Down

0 comments on commit d286f5e

Please sign in to comment.