Class: Packman::Github::Repository
- Inherits:
-
Object
- Object
- Packman::Github::Repository
- Defined in:
- lib/packman/github/repository.rb,
lib/packman/github/repository/version.rb
Constant Summary collapse
- VERSION =
"0.0.1"
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#org ⇒ Object
readonly
Returns the value of attribute org.
Instance Method Summary collapse
- #cloned? ⇒ Boolean
- #full_name ⇒ Object
-
#initialize(org, name, github_options: {}) ⇒ Repository
constructor
A new instance of Repository.
- #pull_request! ⇒ Object
- #push! ⇒ Object
- #sync! ⇒ Object
- #sync_directory ⇒ Object
Constructor Details
#initialize(org, name, github_options: {}) ⇒ Repository
Returns a new instance of Repository.
14 15 16 17 18 |
# File 'lib/packman/github/repository.rb', line 14 def initialize(org, name, github_options: {}) @org = org @name = name @config = Github.config() end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
12 13 14 |
# File 'lib/packman/github/repository.rb', line 12 def name @name end |
#org ⇒ Object (readonly)
Returns the value of attribute org.
12 13 14 |
# File 'lib/packman/github/repository.rb', line 12 def org @org end |
Instance Method Details
#cloned? ⇒ Boolean
28 29 30 31 32 33 |
# File 'lib/packman/github/repository.rb', line 28 def cloned? Dir.exist?(sync_directory) && Git.open(sync_directory) rescue ArgumentError FileUtils.rm_rf(sync_directory) false end |
#full_name ⇒ Object
20 21 22 |
# File 'lib/packman/github/repository.rb', line 20 def full_name "#{org}/#{name}" end |
#pull_request! ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/packman/github/repository.rb', line 52 def pull_request! pr = octokit.create_pull_request( full_name, 'master', branch_name, "bundle update #{Time.now.strftime('%Y-%m-%d %H:%M:%S')}", "Pull requested from [PackmanBot](https://github.com/packmanbot)." ) pr[:html_url] rescue Octokit::UnprocessableEntity => e puts e end |
#push! ⇒ Object
45 46 47 48 49 50 |
# File 'lib/packman/github/repository.rb', line 45 def push! git = Git.open(sync_directory) git.branch(branch_name).checkout git.commit_all('update') git.push('origin', branch_name) end |
#sync! ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/packman/github/repository.rb', line 35 def sync! if cloned? git = Git.open(sync_directory) git.checkout('master') git.pull else Git.clone(clone_url, sync_directory) end end |
#sync_directory ⇒ Object
24 25 26 |
# File 'lib/packman/github/repository.rb', line 24 def sync_directory "#{repos_directory}/#{full_name}" end |