marfa 0.10.0 → 0.10.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/marfa/controllers/base_controller.rb +3 -0
- data/lib/marfa/exceptions.rb +15 -0
- data/lib/marfa/models/api_model.rb +11 -0
- data/lib/marfa/version.rb +1 -1
- data/lib/marfa.rb +1 -0
- data/marfa.gemspec +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 077740413761a2332ab3064d01571c536a9debcc
|
4
|
+
data.tar.gz: 8a76c2df9d05d1e7f94f977cc95ae94f52c890cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8798bc436b7e58f5a781f94dab28dd7610345a0b5cef10e2d964309f1fd4962341f6abbd755050f75c10a9bb2bb326697b506186989c5c5b05e645e3db96a7fb
|
7
|
+
data.tar.gz: 0c7674862463f5e124ed654178d05d452bd781692b44b42cc694c6989573fedf5bebee39323dd042b7a00c05005eb7b051a0bdd0a243e00c95cdd0c30ea1d371
|
@@ -4,6 +4,7 @@ require 'device_detector'
|
|
4
4
|
require 'marfa/helpers/controller'
|
5
5
|
require 'marfa/helpers/http/vary'
|
6
6
|
require 'marfa/css_version'
|
7
|
+
require 'marfa/exceptions'
|
7
8
|
|
8
9
|
# Extending Marfa
|
9
10
|
module Marfa
|
@@ -11,6 +12,8 @@ module Marfa
|
|
11
12
|
module Controllers
|
12
13
|
# base controller
|
13
14
|
class BaseController < Sinatra::Base
|
15
|
+
include Marfa::Exceptions
|
16
|
+
|
14
17
|
before do
|
15
18
|
if Marfa.config.device_detector[:enabled]
|
16
19
|
client = DeviceDetector.new(request.user_agent)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# Extending Marfa
|
2
|
+
module Marfa
|
3
|
+
# Marfa Exceptions
|
4
|
+
module Exceptions
|
5
|
+
# Pages range error
|
6
|
+
class PagesRangeError < StandardError
|
7
|
+
attr_reader :redirect_page_to
|
8
|
+
|
9
|
+
def initialize(msg = 'Page is out of range', redirect_page_to = 1)
|
10
|
+
@redirect_page_to = redirect_page_to
|
11
|
+
super(msg)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'rest-client'
|
2
2
|
require 'json'
|
3
3
|
require 'marfa/configuration'
|
4
|
+
require 'marfa/exceptions'
|
4
5
|
|
5
6
|
module Marfa
|
6
7
|
# Extend Models
|
@@ -11,6 +12,7 @@ module Marfa
|
|
11
12
|
class ModelError < StandardError; end
|
12
13
|
|
13
14
|
include Marfa::Helpers::HTTP
|
15
|
+
include Marfa::Exceptions
|
14
16
|
|
15
17
|
@aliases = {}
|
16
18
|
|
@@ -69,6 +71,8 @@ module Marfa
|
|
69
71
|
# @return [Hash]
|
70
72
|
def self.get_raw_data_with_pagination(params)
|
71
73
|
params[:query] = params[:query].delete_if { |_, v| v.nil? } unless params[:query].nil?
|
74
|
+
params[:query][:page] = 1 if params[:query][:page].blank?
|
75
|
+
|
72
76
|
path = params[:path]
|
73
77
|
cache_key = params[:cache_key]
|
74
78
|
|
@@ -83,7 +87,14 @@ module Marfa
|
|
83
87
|
Marfa.cache.set(cache_key, result.to_json, params[:cache_time] || Marfa.config.cache[:expiration_time])
|
84
88
|
|
85
89
|
return result
|
90
|
+
# Avoid range errors
|
91
|
+
rescue RestClient::RangeNotSatisfiable
|
92
|
+
params[:query][:page] = 1
|
93
|
+
|
94
|
+
# try to get x_pages
|
95
|
+
res = _get_request_result_with_headers(params)
|
86
96
|
|
97
|
+
raise PagesRangeError.new('Page is out of range', res[:data_pages])
|
87
98
|
rescue => exception
|
88
99
|
if [:development, :test].include? Marfa.config.environment
|
89
100
|
_log_exception(exception, path, params)
|
data/lib/marfa/version.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Version constant
|
2
2
|
module Marfa
|
3
3
|
# The version constant for the current version of Marfa
|
4
|
-
VERSION = '0.10.
|
4
|
+
VERSION = '0.10.1'.freeze unless defined?(Marfa::VERSION)
|
5
5
|
|
6
6
|
# The current Marfa version.
|
7
7
|
# @return [String] The version number
|
data/lib/marfa.rb
CHANGED
data/marfa.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: marfa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Max Krechetov
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2018-02-
|
13
|
+
date: 2018-02-15 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: haml
|
@@ -253,6 +253,7 @@ files:
|
|
253
253
|
- lib/marfa/controllers/base_controller.rb
|
254
254
|
- lib/marfa/controllers/css_controller.rb
|
255
255
|
- lib/marfa/css_version.rb
|
256
|
+
- lib/marfa/exceptions.rb
|
256
257
|
- lib/marfa/file_templates.rb
|
257
258
|
- lib/marfa/helpers/classes/array.rb
|
258
259
|
- lib/marfa/helpers/classes/false_class.rb
|