Class: JewelryPortfolio::ReposIndex
- Inherits:
-
Object
- Object
- JewelryPortfolio::ReposIndex
- Defined in:
- lib/jewelry_portfolio/repos_index.rb
Instance Attribute Summary collapse
-
#account ⇒ Object
readonly
Returns the value of attribute account.
Instance Method Summary collapse
- #add(repo) ⇒ Object
- #commit!(message) ⇒ Object
-
#initialize(account, custom_work_directory = nil) ⇒ ReposIndex
constructor
A new instance of ReposIndex.
- #pages_repo ⇒ Object
- #path ⇒ Object
- #push! ⇒ Object
- #repo_name ⇒ Object
- #repos ⇒ Object
- #repos_file ⇒ Object
- #to_yaml ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(account, custom_work_directory = nil) ⇒ ReposIndex
Returns a new instance of ReposIndex.
11 12 13 |
# File 'lib/jewelry_portfolio/repos_index.rb', line 11 def initialize(account, custom_work_directory = nil) @account, @custom_work_directory = account, custom_work_directory end |
Instance Attribute Details
#account ⇒ Object (readonly)
Returns the value of attribute account.
9 10 11 |
# File 'lib/jewelry_portfolio/repos_index.rb', line 9 def account @account end |
Instance Method Details
#add(repo) ⇒ Object
45 46 47 48 |
# File 'lib/jewelry_portfolio/repos_index.rb', line 45 def add(repo) @repos = Set.new([repo]).merge(@repos) update_repos_file! end |
#commit!(message) ⇒ Object
50 51 52 53 |
# File 'lib/jewelry_portfolio/repos_index.rb', line 50 def commit!() pages_repo.add reraise_with_path { pages_repo.commit() } end |
#pages_repo ⇒ Object
27 28 29 30 |
# File 'lib/jewelry_portfolio/repos_index.rb', line 27 def pages_repo load_pages_repo! @pages_repo end |
#path ⇒ Object
19 20 21 |
# File 'lib/jewelry_portfolio/repos_index.rb', line 19 def path @path ||= @custom_work_directory || File.join(Dir.tmpdir, repo_name) end |
#push! ⇒ Object
55 56 57 58 |
# File 'lib/jewelry_portfolio/repos_index.rb', line 55 def push! puts "Pushing branch `master' to remote `#{url}'" reraise_with_path { pages_repo.push('origin', 'master') } end |
#repo_name ⇒ Object
23 24 25 |
# File 'lib/jewelry_portfolio/repos_index.rb', line 23 def repo_name @repo_name ||= "#{@account.downcase}.github.com.git" end |
#repos ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/jewelry_portfolio/repos_index.rb', line 36 def repos unless @repos load_pages_repo! data = File.read(repos_file) if File.exist?(repos_file) @repos = data.nil? || data.empty? ? Set.new : YAML.load(data).to_set end @repos end |
#repos_file ⇒ Object
32 33 34 |
# File 'lib/jewelry_portfolio/repos_index.rb', line 32 def repos_file File.join(path, 'repos.yml') end |
#to_yaml ⇒ Object
60 61 62 |
# File 'lib/jewelry_portfolio/repos_index.rb', line 60 def to_yaml repos.to_a.to_yaml end |
#url ⇒ Object
15 16 17 |
# File 'lib/jewelry_portfolio/repos_index.rb', line 15 def url "[email protected]:#{@account}/#{repo_name}" end |