Class: JewelryPortfolio

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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.

Raises:

  • (ArgumentError)


16
17
18
19
20
21
22
23
24
25
26
# File 'lib/jewelry_portfolio.rb', line 16

def initialize(, repo = nil)
  raise ArgumentError, "No `account' given." unless 
  raise ArgumentError, "No valid `repo' given." if repo && !repo.valid?
  
  @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

#accountObject (readonly)

Returns the value of attribute account.



8
9
10
# File 'lib/jewelry_portfolio.rb', line 8

def 
  @account
end

#indexObject (readonly)

Returns the value of attribute index.



8
9
10
# File 'lib/jewelry_portfolio.rb', line 8

def index
  @index
end

#repoObject (readonly)

Returns the value of attribute repo.



8
9
10
# File 'lib/jewelry_portfolio.rb', line 8

def repo
  @repo
end

#templateObject (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! commit_message
  @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