Class: Cid::Publish

Inherits:
Object
  • Object
show all
Includes:
Helpers::Github
Defined in:
lib/cid/publish.rb

Constant Summary collapse

GITHUB_REPO_REGEX =
/github.com[:\/]([^\/]*)\/([^\.]*)/

Instance Method Summary collapse

Methods included from Helpers::Github

#add_blob_to_tree, #blob_content, #blob_shas, #commit, #create_blob, #default_branch, #github, #latest_commit, #push, #repo, #tree, #user

Constructor Details

#initialize(path, oauth_token) ⇒ Publish

Returns a new instance of Publish.



11
12
13
14
15
16
# File 'lib/cid/publish.rb', line 11

def initialize(path, oauth_token)
  g = Git.open(path)
  @path = path
  @git_url = g.config["remote.origin.url"]
  @oauth_token = oauth_token
end

Instance Method Details

#publishObject



18
19
20
21
22
23
24
# File 'lib/cid/publish.rb', line 18

def publish
  name, content = "datapackage.json", File.read("#{@path}/datapackage.json")
  blob_sha = create_blob(content)
  tree_sha = add_blob_to_tree(blob_sha, name)
  commit_sha = commit(tree_sha)
  push(commit_sha)
end