Skip to content

Commit

Permalink
#1 puzzles
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Dec 10, 2016
1 parent d43850f commit 0f27ad9
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 5 deletions.
15 changes: 11 additions & 4 deletions 0pdd.rb
Expand Up @@ -28,6 +28,8 @@
require_relative 'version'
require_relative 'objects/config'
require_relative 'objects/git_repo'
require_relative 'objects/github_tickets'
require_relative 'objects/puzzles'

get '/' do
haml :index, layout: :layout, locals: { ver: VERSION }
Expand All @@ -36,14 +38,19 @@
post '/hook/github' do
request.body.rewind
json = JSON.parse(request.body.read)
repo = json['repository']['full_name']
name = json['repository']['full_name']
Process.detach(
fork do
GitRepo.new(name: repo, id_rsa: Config.new.yaml['id_rsa']).push
cfg = Config.new.yaml
repo = GitRepo.new(name: name, id_rsa: cfg['id_rsa'])
repo.push
Puzzles.new(repo, cfg['s3']['key'], cfg['s3']['secret']).deploy(
GithubTickets.new(name, cfg['github']['login'], cfg['github']['pwd'])
)
end
)
puts "GitHub hook from #{repo}"
"thanks #{repo}"
puts "GitHub hook from #{name}"
"thanks #{name}"
end

get '/css/*.css' do
Expand Down
8 changes: 8 additions & 0 deletions objects/config.rb
Expand Up @@ -29,6 +29,14 @@ class Config
def yaml
cfg = File.join(File.dirname(__FILE__), '../config.yml')
default = {
'github' => {
'login' => '0pdd',
'pwd' => '--secret--'
},
's3' => {
'key' => '?',
'secret' => '?'
},
'id_rsa' => ''
}
File.exist?(cfg) ? YAML.load(File.open(cfg)) : default
Expand Down
2 changes: 1 addition & 1 deletion objects/github_tickets.rb
Expand Up @@ -24,7 +24,7 @@
# Tickets in Github
#
class GithubTickets
def initialize(name:, login:, password:)
def initialize(name, login, password)
@name = name
@login = login
@password = password
Expand Down
36 changes: 36 additions & 0 deletions objects/puzzles.rb
@@ -0,0 +1,36 @@
# 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.

#
# Puzzles in XML/S3
#
class Puzzles
def initialize(repo, key, secret)
@repo = repo
@key = key
@secret = secret
end

def deploy(tickets)
# tbd
end
end

0 comments on commit 0f27ad9

Please sign in to comment.