mirror of
https://github.com/gwenhael-le-moine/ledgerrb.git
synced 2024-12-26 09:59:18 +01:00
refactoring
Signed-off-by: Gwenhael Le Moine <gwenhael.le.moine@gmail.com>
This commit is contained in:
parent
5c7c4752f5
commit
4df1819854
9 changed files with 46 additions and 79 deletions
37
Gemfile.lock
37
Gemfile.lock
|
@ -1,37 +0,0 @@
|
|||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
coderay (1.1.1)
|
||||
method_source (0.8.2)
|
||||
pry (0.10.4)
|
||||
coderay (~> 1.1.0)
|
||||
method_source (~> 0.8.1)
|
||||
slop (~> 3.4)
|
||||
puma (3.6.0)
|
||||
rack (1.6.4)
|
||||
rack-protection (1.5.3)
|
||||
rack
|
||||
rack-rewrite (1.5.1)
|
||||
rake (11.3.0)
|
||||
sinatra (1.4.7)
|
||||
rack (~> 1.5)
|
||||
rack-protection (~> 1.4)
|
||||
tilt (>= 1.3, < 3)
|
||||
sinatra-param (1.4.0)
|
||||
sinatra (~> 1.3)
|
||||
slop (3.6.0)
|
||||
tilt (2.0.5)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
pry
|
||||
puma
|
||||
rack-rewrite
|
||||
rake
|
||||
sinatra
|
||||
sinatra-param
|
||||
|
||||
BUNDLED WITH
|
||||
1.13.6
|
21
app.rb
21
app.rb
|
@ -4,12 +4,11 @@ require 'json'
|
|||
|
||||
Bundler.require( :default, ENV[ 'RACK_ENV' ].to_sym )
|
||||
|
||||
require_relative './options'
|
||||
require_relative './lib/ledger'
|
||||
|
||||
# Sinatra app serving API
|
||||
class LedgerRbApp < Sinatra::Base
|
||||
helpers Sinatra::Param
|
||||
|
||||
before do
|
||||
content_type :json, 'charset' => 'utf-8'
|
||||
end
|
||||
|
@ -24,8 +23,6 @@ class LedgerRbApp < Sinatra::Base
|
|||
end
|
||||
|
||||
get '/api/ledger/accounts/depth/:depth/?' do
|
||||
param :depth, Integer, required: true
|
||||
|
||||
Ledger.accounts( params[ :depth ] ).to_json
|
||||
end
|
||||
|
||||
|
@ -34,20 +31,12 @@ class LedgerRbApp < Sinatra::Base
|
|||
end
|
||||
|
||||
get '/api/ledger/register/?' do
|
||||
param :period, String, default: nil
|
||||
param :categories, String, required: true
|
||||
|
||||
{ key: params[ :categories ],
|
||||
values: Ledger.register( params[ :period ], params[ :categories ] ) }
|
||||
.to_json
|
||||
end
|
||||
|
||||
get '/api/ledger/balance/?' do
|
||||
param :depth, Integer, default: false
|
||||
param :period, String, default: nil
|
||||
param :cleared, Boolean, default: false
|
||||
param :categories, String, default: ''
|
||||
|
||||
Ledger.balance( params[ :cleared ],
|
||||
params[ :depth ],
|
||||
params[ :period ],
|
||||
|
@ -60,17 +49,11 @@ class LedgerRbApp < Sinatra::Base
|
|||
end
|
||||
|
||||
get '/api/ledger/budget/?' do
|
||||
param :period, String, default: 'this month'
|
||||
param :categories, String, required: true
|
||||
|
||||
Ledger.budget( params[ :period ],
|
||||
params[ :categories ] ).to_json
|
||||
end
|
||||
|
||||
get '/api/ledger/graph_values/?' do
|
||||
param :period, String, default: nil
|
||||
param :categories, String, default: 'Expenses'
|
||||
|
||||
get '/api/ledger/graph_values/?' do
|
||||
Ledger.graph_values( params[:period], params[:categories].split(' ') ).to_json
|
||||
end
|
||||
|
||||
|
|
|
@ -1,12 +1,7 @@
|
|||
# encoding: utf-8
|
||||
|
||||
require 'bundler'
|
||||
|
||||
require_relative './config/options'
|
||||
require_relative './app'
|
||||
|
||||
use Rack::Rewrite do
|
||||
rewrite %r{^/(.*(css|js|ttf|woff|html|png|jpg|jpeg|gif|ico)$)}, '/app/$1'
|
||||
map "/" do
|
||||
run LedgerRbApp
|
||||
end
|
||||
|
||||
run LedgerRbApp
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
# encoding: utf-8
|
||||
|
||||
ENV[ 'LEDGER_FILE' ] ||= '/home/owncloud-data/cycojesus/files/org-files/comptes.ledger'
|
||||
|
||||
CURRENCY = '€'
|
||||
SEPARATOR = ','
|
34
gems.locked
Normal file
34
gems.locked
Normal file
|
@ -0,0 +1,34 @@
|
|||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
coderay (1.1.2)
|
||||
method_source (0.9.0)
|
||||
mustermann (1.0.1)
|
||||
pry (0.11.2)
|
||||
coderay (~> 1.1.0)
|
||||
method_source (~> 0.9.0)
|
||||
puma (3.10.0)
|
||||
rack (2.0.3)
|
||||
rack-protection (2.0.0)
|
||||
rack
|
||||
rack-rewrite (1.5.1)
|
||||
rake (12.2.1)
|
||||
sinatra (2.0.0)
|
||||
mustermann (~> 1.0)
|
||||
rack (~> 2.0)
|
||||
rack-protection (= 2.0.0)
|
||||
tilt (~> 2.0)
|
||||
tilt (2.0.8)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
pry
|
||||
puma
|
||||
rack-rewrite
|
||||
rake
|
||||
sinatra
|
||||
|
||||
BUNDLED WITH
|
||||
1.14.6
|
|
@ -2,9 +2,7 @@
|
|||
|
||||
source 'https://rubygems.org'
|
||||
|
||||
gem 'rack-rewrite'
|
||||
gem 'sinatra'
|
||||
gem 'sinatra-param'
|
||||
gem 'puma'
|
||||
gem 'rake'
|
||||
gem 'pry'
|
6
options.rb
Normal file
6
options.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
# encoding: utf-8
|
||||
|
||||
ENV[ 'LEDGER_FILE' ] ||= '/home/nextcloud/data/cycojesus/files/org-files/comptes.ledger'
|
||||
|
||||
CURRENCY = '€'
|
||||
SEPARATOR = ','
|
|
@ -10,7 +10,7 @@
|
|||
options="graphiques.monthly_values.options"></nvd3>
|
||||
</md-card>
|
||||
</md-card>
|
||||
<h1>{{period | amDateFormat:'MMMM YYYY'}}</h1>
|
||||
<h1 style="text-align: center;">{{period | amDateFormat:'MMMM YYYY'}}</h1>
|
||||
<md-card flex="100" layout="column"
|
||||
ng:repeat="bucket in balance.buckets">
|
||||
<md-toolbar>
|
||||
|
|
|
@ -2,13 +2,7 @@
|
|||
|
||||
ENV['RACK_ENV'] = 'development'
|
||||
task :load_config do
|
||||
require 'rubygems'
|
||||
require 'bundler'
|
||||
|
||||
Bundler.require( :default, ENV['RACK_ENV'].to_sym ) # require tout les gems définis dans Gemfile
|
||||
|
||||
require_relative '../lib/ledger'
|
||||
require_relative '../config/options'
|
||||
require_relative '../app'
|
||||
end
|
||||
|
||||
desc 'Open pry with DB environment setup'
|
||||
|
|
Loading…
Reference in a new issue