Class: Amiba::Source::CategoryScope

Inherits:
Object
  • Object
show all
Includes:
Repo
Defined in:
lib/amiba/source/entry_finder.rb

Instance Method Summary collapse

Methods included from Repo

#add_and_commit, #init, #last_commit_date, #last_commit_dates, #pull, #push, #repo

Constructor Details

#initialize(category = :all) ⇒ CategoryScope

Returns a new instance of CategoryScope.



102
103
104
# File 'lib/amiba/source/entry_finder.rb', line 102

def initialize(category = :all)
  @category = category
end

Instance Method Details

#applyObject



105
106
107
108
109
110
111
# File 'lib/amiba/source/entry_finder.rb', line 105

def apply
  entry_files.map do |ef|
    _, category, filename = ef.split('/')
    name, format = filename.split('.')
    Amiba::Source::Entry.new(category, name, format)
  end
end

#entry_filesObject



112
113
114
115
# File 'lib/amiba/source/entry_finder.rb', line 112

def entry_files
  globstring = "entries/#{@category == :all ? '*' : @category.to_s}/*"
  Dir.glob(globstring).select {|e| !repo.log(e).empty?}
end