class DevTraining::Training
Main Developer training object, used to coordinate resource creation and updates
Attributes
An Octokit::Client
The DevTraining::Repository
for this training
Public Class Methods
Source
# File lib/dev_training/training.rb, line 25 def initialize(token) @client = Octokit::Client.new access_token: token @repo = DevTraining::Repository.new(@client) @milestone = DevTraining::Milestone.new(@client, @repo) end
Initialized with a GitHub token. In the console, you can use a Personal Access Token, but the Sinatra app uses an OAuth token. Note that many of the objects in a training instance create GitHub resources lazily. So, nothing will be created on GitHub at initialization.
Public Instance Methods
Source
# File lib/dev_training/training.rb, line 34 def add_collaborators!(collaborators) collaborators.each { |user| @repo.add_collaborator user } end
Takes an array of login names and adds them in turn as outside collaborators to the repository.
Source
# File lib/dev_training/training.rb, line 49 def create_issues!(stream) stream.map do |data| DevTraining::Issue.new(@client, @repo, @milestone, data).resource end end
Takes an Array
of Hash
es, each in the format a DevTraining::Issue
expects, and returns an Array
of resources as created on or returned from GitHub.
Source
# File lib/dev_training/training.rb, line 41 def create_readme!(filename) DevTraining::Readme.new(filename, @client, @repo).resource end
Takes a filename that will be passed to a new DevTraining::Readme
, and then returns the resource as created on or returned from GitHub.