Class: JewelryPortfolio
- Inherits:
-
Object
- Object
- JewelryPortfolio
- Defined in:
- lib/jewelry_portfolio.rb,
lib/jewelry_portfolio/repo.rb,
lib/jewelry_portfolio/tasks.rb,
lib/jewelry_portfolio/template.rb,
lib/jewelry_portfolio/repos_index.rb
Defined Under Namespace
Classes: FileMissingError, Repo, ReposIndex, Tasks, Template
Instance Attribute Summary collapse
-
#account ⇒ Object
readonly
Returns the value of attribute account.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#repo ⇒ Object
readonly
Returns the value of attribute repo.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
Instance Method Summary collapse
-
#initialize(account, repo = nil) ⇒ JewelryPortfolio
constructor
Initializes a JewelryPortfolio instance for the specified
account
. -
#release! ⇒ Object
Renders the index.html file, then commits and pushes it to the remote.
-
#render! ⇒ Object
Renders the index.html file.
Constructor Details
#initialize(account, repo = nil) ⇒ JewelryPortfolio
Initializes a JewelryPortfolio instance for the specified account
.
If an optional repo
is provided it will be added to, or updated in, the index. If no repo
is provided it is assumed you are working in a clone of your GitHub pages repo. In this case no fetching and merging will be performed.
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/jewelry_portfolio.rb', line 16 def initialize(account, repo = nil) raise ArgumentError, "No `account' given." unless account raise ArgumentError, "No valid `repo' given." if repo && !repo.valid? @account = account @repo = repo @index = ReposIndex.new(@account, (Dir.pwd unless @repo)) @template = Template.new(File.join(@index.path, 'template'), @index.repos) @index.add(@repo) if @repo end |
Instance Attribute Details
#account ⇒ Object (readonly)
Returns the value of attribute account.
8 9 10 |
# File 'lib/jewelry_portfolio.rb', line 8 def account @account end |
#index ⇒ Object (readonly)
Returns the value of attribute index.
8 9 10 |
# File 'lib/jewelry_portfolio.rb', line 8 def index @index end |
#repo ⇒ Object (readonly)
Returns the value of attribute repo.
8 9 10 |
# File 'lib/jewelry_portfolio.rb', line 8 def repo @repo end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
8 9 10 |
# File 'lib/jewelry_portfolio.rb', line 8 def template @template end |
Instance Method Details
#release! ⇒ Object
Renders the index.html file, then commits and pushes it to the remote.
35 36 37 38 39 |
# File 'lib/jewelry_portfolio.rb', line 35 def release! render! @index.commit! @index.push! end |
#render! ⇒ Object
Renders the index.html file.
29 30 31 32 |
# File 'lib/jewelry_portfolio.rb', line 29 def render! puts "Generating html" File.open(File.join(@index.path, 'index.html'), 'w') { |f| f << @template.render } end |