Class: Nanoc::Github::Source

Inherits:
DataSource
  • Object
show all
Defined in:
lib/nanoc/github.rb

Instance Method Summary collapse

Instance Method Details

#itemsObject



66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/nanoc/github.rb', line 66

def items
  @items ||= begin
    repository_items
      .sort_by { |item| item[:name] }
      .map     { |item|
        identifier     = Nanoc::Identifier.new("/#{item[:name]}")
        , data = decode(item[:content])

        new_item(data, , identifier, checksum_data: item[:sha])
      }
  end
end

#upObject



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/nanoc/github.rb', line 48

def up
  stack = Faraday::RackBuilder.new do |builder|
    builder.use Faraday::HttpCache,
      serializer: Marshal,
      shared_cache: false,
      store: Cache.new(tmp_dir),
      logger: verbose ? logger : nil
    builder.use ModifyMaxAge, time: max_age
    builder.use Faraday::Request::Retry,
      exceptions: [Octokit::ServerError]
    builder.use Octokit::Middleware::FollowRedirects
    builder.use Octokit::Response::RaiseError
    builder.use Octokit::Response::FeedParser
    builder.adapter Faraday.default_adapter
  end
  Octokit.middleware = stack
end