Skip to content

Commit

Permalink
#1 github tickets
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Dec 10, 2016
1 parent 7e35a2f commit cc1cb77
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 8 deletions.
3 changes: 2 additions & 1 deletion 0pdd.rb
Expand Up @@ -26,6 +26,7 @@
require 'haml'

require_relative 'version'
require_relative 'objects/config'
require_relative 'objects/git_repo'

get '/' do
Expand All @@ -38,7 +39,7 @@
repo = json['repository']['full_name']
Process.detach(
fork do
GitRepo.new(name: repo).push
GitRepo.new(name: repo, id_rsa: Config.new.yaml['id_rsa']).push
end
)
puts "GitHub hook from #{repo}"
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Expand Up @@ -20,7 +20,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

ruby '2.2.2'
# ruby '2.2.2'
source 'https://rubygems.org'

gem 'coveralls', '0.8.17'
Expand Down
3 changes: 0 additions & 3 deletions Gemfile.lock
Expand Up @@ -133,8 +133,5 @@ DEPENDENCIES
sprockets (= 3.7.0)
test-unit (= 3.0.8)

RUBY VERSION
ruby 2.2.2p95

BUNDLED WITH
1.13.6
5 changes: 4 additions & 1 deletion objects/config.rb
Expand Up @@ -28,6 +28,9 @@
class Config
def yaml
cfg = File.join(File.dirname(__FILE__), '../config.yml')
File.exist?(cfg) ? YAML.load(File.open(cfg)) : {}
default = {
'id_rsa' => ''
}
File.exist?(cfg) ? YAML.load(File.open(cfg)) : default
end
end
8 changes: 6 additions & 2 deletions objects/git_repo.rb
Expand Up @@ -28,10 +28,14 @@
# Repository in Git
#
class GitRepo
def initialize(name:, dir: '/tmp/0pdd', uri: "git@github.com:#{name}")
def initialize(
name:, dir: '/tmp/0pdd',
uri: "git@github.com:#{name}", id_rsa: ''
)
@name = name
@path = "#{dir}/#{@name}"
@uri = uri
@id_rsa = id_rsa
end

def xml
Expand Down Expand Up @@ -70,7 +74,7 @@ def prepare
dir = "#{Dir.home}/.ssh"
FileUtils.mkdir_p(dir)
priv = "#{dir}/id_rsa"
IO.write(priv, Config.new.yaml['id_rsa']) unless File.exist?(priv)
IO.write(priv, @id_rsa) unless @id_rsa.empty?
return if File.exist?("#{dir}/config")
Exec.new(
'set -x;',
Expand Down
41 changes: 41 additions & 0 deletions objects/github_tickets.rb
@@ -0,0 +1,41 @@
# encoding: utf-8
#
# Copyright (c) 2016 Yegor Bugayenko
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the 'Software'), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

#
# Tickets in Github
#
class GithubTickets
def initialize(name:, login:, password:)
@name = name
@login = login
@password = password
end

# Submit a new puzzle as a ticket
def submit(puzzle)
# tbd
end

def close(id)
# tbd
end
end

0 comments on commit cc1cb77

Please sign in to comment.