documentación
This commit is contained in:
parent
94fbf70cd8
commit
4875a770ac
17 changed files with 164 additions and 10 deletions
|
@ -3,7 +3,6 @@ node_modules/
|
|||
tmp/
|
||||
log/
|
||||
public/
|
||||
docs/
|
||||
bin/
|
||||
db/
|
||||
lib/
|
||||
|
|
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -27,3 +27,6 @@
|
|||
/config/master.key
|
||||
# Siempre da conflictos
|
||||
/db/schema.rb
|
||||
/public/docs/
|
||||
/.yardoc/
|
||||
/docs/
|
||||
|
|
|
@ -33,7 +33,7 @@ RUN git archive -o ../web.tar.gz HEAD
|
|||
FROM lunar/monit:3.9
|
||||
RUN apk add --no-cache libxslt libxml2 tzdata ruby ruby-bundler ruby-json ruby-bigdecimal ruby-rake
|
||||
RUN apk add --no-cache sqlite sqlite-libs
|
||||
RUN addgroup -g 82 -S www-data
|
||||
RUN apk add --no-cache darkhttpd
|
||||
COPY ./entrypoint.sh /usr/bin/entrypoint
|
||||
RUN chmod 755 /usr/bin/entrypoint
|
||||
# Agregar el usuario
|
||||
|
@ -46,9 +46,11 @@ RUN tar xf /tmp/web.tar.gz && rm /tmp/web.tar.gz
|
|||
# Traer las gemas
|
||||
COPY --from=build --chown=app:www-data /home/app/web/vendor ./vendor
|
||||
COPY --from=build --chown=app:www-data /home/app/web/.bundle ./.bundle
|
||||
COPY --chown=app:www-data ./docs ./public/docs
|
||||
|
||||
USER root
|
||||
RUN install -m 640 -o root -g root ./monit.conf /etc/monit.d/puma.conf
|
||||
RUN monit -t
|
||||
VOLUME "/srv/http/public/system"
|
||||
VOLUME "/srv/http/data"
|
||||
EXPOSE 3000
|
||||
EXPOSE 8080
|
||||
|
|
1
Gemfile
1
Gemfile
|
@ -40,6 +40,7 @@ group :development do
|
|||
gem 'rubocop'
|
||||
gem 'spring'
|
||||
gem 'spring-watcher-listen', '~> 2.0.0'
|
||||
gem 'yard'
|
||||
end
|
||||
|
||||
group :test do
|
||||
|
|
|
@ -160,6 +160,7 @@ GEM
|
|||
websocket-driver (0.7.0)
|
||||
websocket-extensions (>= 0.1.0)
|
||||
websocket-extensions (0.1.3)
|
||||
yard (0.9.19)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
@ -179,6 +180,7 @@ DEPENDENCIES
|
|||
spring
|
||||
spring-watcher-listen (~> 2.0.0)
|
||||
sqlite3
|
||||
yard
|
||||
|
||||
RUBY VERSION
|
||||
ruby 2.5.3p105
|
||||
|
|
7
Makefile
7
Makefile
|
@ -5,6 +5,11 @@ c ?= $(shell date +%F | tr "-" ".")
|
|||
r ?= $(shell git rev-list --count HEAD)
|
||||
name = miniloom/$(d):$(c).$(r)
|
||||
|
||||
doc:
|
||||
./bin/yardoc --output-dir=./docs/ \
|
||||
app/controllers/*.rb \
|
||||
app/models/*.rb
|
||||
|
||||
clean:
|
||||
rm -f log/*.log
|
||||
rm -rf tmp/cache/assets
|
||||
|
@ -22,4 +27,4 @@ push:
|
|||
docker push registry.forja.lainventoria.com.ar/$(name)
|
||||
docker push registry.forja.lainventoria.com.ar/miniloom/$(d):latest
|
||||
|
||||
all: clean build tag push
|
||||
all: clean doc build tag push
|
||||
|
|
|
@ -1,15 +1,29 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Consensos
|
||||
# API para Consensos, necesita autenticar una pirata vía HTTP Basic Auth
|
||||
#
|
||||
# @see PiratasController#create
|
||||
class ConsensosController < ApplicationController
|
||||
# Para cualquier acción necesitamos autenticación
|
||||
before_action :authenticate!
|
||||
|
||||
# GET /consensos
|
||||
#
|
||||
# Podemos ver todos los consensos
|
||||
#
|
||||
# @return [Array] [ consensos ]
|
||||
def index
|
||||
@consensos = Consenso.all.order(:created_at, :desc)
|
||||
end
|
||||
|
||||
# Podemos ver uno solo
|
||||
# GET /consensos/:id
|
||||
#
|
||||
# Podemos ver uno solo sabiendo su ID
|
||||
#
|
||||
# @param id [Integer] El ID del consenso
|
||||
# @return [Hash] { id: @int, created_at: @date,
|
||||
# titulo: @string, texto: @string,
|
||||
# posiciones: [] }
|
||||
def show
|
||||
@consenso = Consenso.find(params[:id])
|
||||
return if @consenso
|
||||
|
@ -17,7 +31,14 @@ class ConsensosController < ApplicationController
|
|||
render json: {}, status: :not_found
|
||||
end
|
||||
|
||||
# Podemos crear uno
|
||||
# POST /consensos
|
||||
#
|
||||
# Podemos crear uno, enviando un hash con todas las propiedades
|
||||
#
|
||||
# @param consenso [Hash] { consenso: { titulo: @string, texto: @string } }
|
||||
# @return [Hash] { id: @int, created_at: @date,
|
||||
# titulo: @string, texto: @string,
|
||||
# posiciones: [] }
|
||||
def create
|
||||
@consenso = current_pirata.consensos
|
||||
.new(params.require(:consenso).permit(:titulo, :texto))
|
||||
|
|
|
@ -2,7 +2,13 @@
|
|||
|
||||
# Las piratas son las que activan el Miniloom
|
||||
class PiratasController < ApplicationController
|
||||
# POST /piratas
|
||||
#
|
||||
# Registra una cuenta
|
||||
#
|
||||
# @param pirata [Hash] { pirata: { password: @string, email: @string,
|
||||
# nick: @string } }
|
||||
# @return [Hash] { id: @int, nick: @string, email: @string }
|
||||
def create
|
||||
@pirata = Pirata.new(params
|
||||
.require(:pirata)
|
||||
|
|
|
@ -1,9 +1,21 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# API para posiciones
|
||||
#
|
||||
# Las posiciones solo se pueden agregar a su consenso
|
||||
#
|
||||
# @see PiratasController#create
|
||||
class PosicionesController < ApplicationController
|
||||
# Necesitamos autenticarnos
|
||||
before_action :authenticate!
|
||||
|
||||
# POST /consensos/:consenso_id/posiciones
|
||||
#
|
||||
# Crea una posición dentro de un consenso
|
||||
#
|
||||
# @param :consenso_id [Integer] El ID del consenso
|
||||
# @param :posicion [Hash] { posicion: { estado: @string, comentario: @string } }
|
||||
# @return [Hash] { id: @int, estado: @string, comentario: @string }
|
||||
def create
|
||||
@consenso = Consenso.find(params[:consenso_id])
|
||||
@posicion = @consenso.try(:posiciones).try(:build, posicion_params)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# El consenso agrupa posiciones y textos
|
||||
# Los consensos son textos sobre los que las piratas establecen
|
||||
# posiciones
|
||||
class Consenso < ApplicationRecord
|
||||
# Es escrito por una pirata
|
||||
belongs_to :pirata
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
json.call(@pirata, :nick, :email)
|
||||
json.call(@pirata, :id, :nick, :email)
|
||||
|
|
29
bin/yard
Executable file
29
bin/yard
Executable file
|
@ -0,0 +1,29 @@
|
|||
#!/usr/bin/env ruby
|
||||
# frozen_string_literal: true
|
||||
|
||||
#
|
||||
# This file was generated by Bundler.
|
||||
#
|
||||
# The application 'yard' is installed as part of a gem, and
|
||||
# this file is here to facilitate running it.
|
||||
#
|
||||
|
||||
require 'pathname'
|
||||
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
|
||||
Pathname.new(__FILE__).realpath)
|
||||
|
||||
bundle_binstub = File.expand_path('bundle', __dir__)
|
||||
|
||||
if File.file?(bundle_binstub)
|
||||
if /This file was generated by Bundler/.match?(File.read(bundle_binstub, 300))
|
||||
load(bundle_binstub)
|
||||
else
|
||||
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
||||
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
||||
end
|
||||
end
|
||||
|
||||
require 'rubygems'
|
||||
require 'bundler/setup'
|
||||
|
||||
load Gem.bin_path('yard', 'yard')
|
29
bin/yardoc
Executable file
29
bin/yardoc
Executable file
|
@ -0,0 +1,29 @@
|
|||
#!/usr/bin/env ruby
|
||||
# frozen_string_literal: true
|
||||
|
||||
#
|
||||
# This file was generated by Bundler.
|
||||
#
|
||||
# The application 'yardoc' is installed as part of a gem, and
|
||||
# this file is here to facilitate running it.
|
||||
#
|
||||
|
||||
require 'pathname'
|
||||
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
|
||||
Pathname.new(__FILE__).realpath)
|
||||
|
||||
bundle_binstub = File.expand_path('bundle', __dir__)
|
||||
|
||||
if File.file?(bundle_binstub)
|
||||
if /This file was generated by Bundler/.match?(File.read(bundle_binstub, 300))
|
||||
load(bundle_binstub)
|
||||
else
|
||||
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
||||
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
||||
end
|
||||
end
|
||||
|
||||
require 'rubygems'
|
||||
require 'bundler/setup'
|
||||
|
||||
load Gem.bin_path('yard', 'yardoc')
|
29
bin/yri
Executable file
29
bin/yri
Executable file
|
@ -0,0 +1,29 @@
|
|||
#!/usr/bin/env ruby
|
||||
# frozen_string_literal: true
|
||||
|
||||
#
|
||||
# This file was generated by Bundler.
|
||||
#
|
||||
# The application 'yri' is installed as part of a gem, and
|
||||
# this file is here to facilitate running it.
|
||||
#
|
||||
|
||||
require 'pathname'
|
||||
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
|
||||
Pathname.new(__FILE__).realpath)
|
||||
|
||||
bundle_binstub = File.expand_path('bundle', __dir__)
|
||||
|
||||
if File.file?(bundle_binstub)
|
||||
if /This file was generated by Bundler/.match?(File.read(bundle_binstub, 300))
|
||||
load(bundle_binstub)
|
||||
else
|
||||
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
||||
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
||||
end
|
||||
end
|
||||
|
||||
require 'rubygems'
|
||||
require 'bundler/setup'
|
||||
|
||||
load Gem.bin_path('yard', 'yri')
|
|
@ -22,4 +22,4 @@ test:
|
|||
|
||||
production:
|
||||
<<: *default
|
||||
database: db/production.sqlite3
|
||||
database: data/production.sqlite3
|
||||
|
|
|
@ -10,4 +10,15 @@ case $1 in
|
|||
bundle exec puma -d config.ru
|
||||
exit $?
|
||||
;;
|
||||
darkhttpd)
|
||||
darkhttpd /srv/http/public \
|
||||
--no-server-id \
|
||||
--pidfile /tmp/darkhttpd.pid \
|
||||
--uid darkhttpd \
|
||||
--gid www-data \
|
||||
--no-listing \
|
||||
--daemon \
|
||||
--port 8080
|
||||
exit $?
|
||||
;;
|
||||
esac
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
check process api with pidfile /srv/http/tmp/puma.pid
|
||||
start program = "/usr/bin/entrypoint api" as uid app
|
||||
stop program = "/bin/sh -c 'cat /srv/http/tmp/puma.pid | xargs kill'"
|
||||
|
||||
check process static with pidfile /tmp/darkhttpd.pid
|
||||
start program = "/usr/bin/entrypoint darkhttpd"
|
||||
stop program = "/bin/sh -c 'cat /tmp/darkhttpd.pid | xargs kill'"
|
||||
|
|
Loading…
Reference in a new issue