forest_liana 1.4.3 → 1.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9847fca87fc1e7caff49a8aaf899a23c33169314
4
- data.tar.gz: bf383e4e3b8fcc4be34a368018bdd8ab43e1bb0c
3
+ metadata.gz: 1c7e65eaf32a280961a284a31d555dd41cb52b5a
4
+ data.tar.gz: 68d912adea12939ab9bc20779434161c01fd993c
5
5
  SHA512:
6
- metadata.gz: 812421ddef29e95a562c928d610b3dfb148a7b9526ce69e88586d89c6b10a3569f9d32ea8cc8243ae1d4e67056ee406c770ed8b5a6fbf00e06a6dbd0ba01a1ea
7
- data.tar.gz: bec80b2cb5b6524af1b6c2ddcbdd7a132910c85b25f9a6f06ca0455165c106c46b9cecc9c7c4dba37f4945dabc805bf8208109f89d7c3c96e38e360b3456865d
6
+ metadata.gz: b336890472dd721f35d08aa754166436251d7e053f4e94eeaa9d2ea5f268e97145e6860e7a4e67e8ce19192fc31b49ce194446360a52075f97650422f20a1b33
7
+ data.tar.gz: f2a40fd9fcfdda465440f7eb8911f5386fba5b28170bdddff0e9f093366a39c0fb74f4848e4d4f730d97ef9ad8c4baa8153c1529ea730c18cb6b70f1646600b0
@@ -1,7 +1,7 @@
1
1
  module ForestLiana
2
2
  class ApimapsController < ActionController::Base
3
3
  def index
4
- render nothing: true, status: 204
4
+ head :no_content
5
5
  end
6
6
  end
7
7
  end
@@ -49,7 +49,7 @@ module ForestLiana
49
49
  render json: { error: 'expired_token' }, status: 401, serializer: nil
50
50
  end
51
51
  else
52
- render nothing: true, status: 401
52
+ head :unauthorized
53
53
  end
54
54
  end
55
55
 
@@ -22,21 +22,21 @@ module ForestLiana
22
22
  updater = BelongsToUpdater.new(@resource, @association, params)
23
23
  updater.perform
24
24
 
25
- render nothing: true, status: 204
25
+ head :no_content
26
26
  end
27
27
 
28
28
  def associate
29
29
  associator = HasManyAssociator.new(@resource, @association, params)
30
30
  associator.perform
31
31
 
32
- render nothing: true, status: 204
32
+ head :no_content
33
33
  end
34
34
 
35
35
  def dissociate
36
36
  dissociator = HasManyDissociator.new(@resource, @association, params)
37
37
  dissociator.perform
38
38
 
39
- render nothing: true, status: 204
39
+ head :no_content
40
40
  end
41
41
 
42
42
  private
@@ -64,7 +64,7 @@ module ForestLiana
64
64
  def destroy
65
65
  @resource.destroy_all(id: params[:id])
66
66
 
67
- render nothing: true, status: 204
67
+ head :no_content
68
68
  end
69
69
 
70
70
  private
@@ -9,7 +9,7 @@ module ForestLiana
9
9
  if token
10
10
  render json: { token: token }, serializer: nil
11
11
  else
12
- render nothing: true, status: 401
12
+ head :unauthorized
13
13
  end
14
14
  end
15
15
 
@@ -1,12 +1,6 @@
1
1
  module ForestLiana
2
2
  class OperatorDateIntervalParser
3
3
  PERIODS = {
4
- yesterday: { duration: 1, period: 'day' }, # TODO: Remove once new filter protocol is live
5
- lastWeek: { duration: 1, period: 'week' }, # TODO: Remove once new filter protocol is live
6
- last2Weeks: { duration: 2, period: 'week' }, # TODO: Remove once new filter protocol is live
7
- lastMonth: { duration: 1, period: 'month' }, # TODO: Remove once new filter protocol is live
8
- last3Months: { duration: 3, period: 'month' }, # TODO: Remove once new filter protocol is live
9
- lastYear: { duration: 1, period: 'year' }, # TODO: Remove once new filter protocol is live
10
4
  :$yesterday => { duration: 1, period: 'day' },
11
5
  :$previousWeek => { duration: 1, period: 'week' },
12
6
  :$previousMonth => { duration: 1, period: 'month' },
@@ -20,14 +14,10 @@ module ForestLiana
20
14
  :$yearToDate => { duration: 1, period: 'year', to_date: true }
21
15
  }
22
16
 
23
- PERIODS_FROM_NOW = 'fromNow' # TODO: Remove once new filter protocol is live
24
- PERIODS_TODAY_DEPRECATED = 'today' # TODO: Remove once new filter protocol is live
25
-
26
17
  PERIODS_PAST = '$past';
27
18
  PERIODS_FUTURE = '$future';
28
19
  PERIODS_TODAY = '$today';
29
20
 
30
- PERIODS_LAST_X_DAYS = /^last(\d+)days$/ # TODO: Remove once new filter protocol is live
31
21
  PERIODS_PREVIOUS_X_DAYS = /^\$previous(\d+)Days$/;
32
22
  PERIODS_X_DAYS_TO_DATE = /^\$(\d+)DaysToDate$/;
33
23
 
@@ -39,15 +29,8 @@ module ForestLiana
39
29
  return false if @value.nil?
40
30
  return true if PERIODS[@value.to_sym]
41
31
 
42
- # TODO: Remove once new filter protocol is live
43
- return true if [PERIODS_FROM_NOW, PERIODS_TODAY_DEPRECATED].include? @value
44
-
45
32
  return true if [PERIODS_PAST, PERIODS_FUTURE, PERIODS_TODAY].include? @value
46
33
 
47
- # TODO: Remove once new filter protocol is live
48
- match = PERIODS_LAST_X_DAYS.match(@value)
49
- return true if match && match[1]
50
-
51
34
  match = PERIODS_PREVIOUS_X_DAYS.match(@value)
52
35
  return true if match && match[1]
53
36
 
@@ -61,15 +44,8 @@ module ForestLiana
61
44
  return false if @value.nil?
62
45
  return true if PERIODS[@value.to_sym]
63
46
 
64
- # TODO: Remove once new filter protocol is live
65
- return true if PERIODS_TODAY_DEPRECATED == @value
66
-
67
47
  return true if PERIODS_TODAY == @value
68
48
 
69
- # TODO: Remove once new filter protocol is live
70
- match = PERIODS_LAST_X_DAYS.match(@value)
71
- return true if match && match[1]
72
-
73
49
  match = PERIODS_PREVIOUS_X_DAYS.match(@value)
74
50
  return true if match && match[1]
75
51
 
@@ -82,30 +58,14 @@ module ForestLiana
82
58
  def get_interval_date_filter
83
59
  return nil unless is_interval_date_value()
84
60
 
85
- # TODO: Remove once new filter protocol is live
86
- return ">= '#{Time.now}'" if @value == PERIODS_FROM_NOW
87
-
88
61
  return ">= '#{Time.now}'" if @value == PERIODS_FUTURE
89
62
  return "<= '#{Time.now}'" if @value == PERIODS_PAST
90
63
 
91
- # TODO: Remove once new filter protocol is live
92
- if @value == PERIODS_TODAY_DEPRECATED
93
- return "BETWEEN '#{Time.now.beginning_of_day}' AND " +
94
- "'#{Time.now.end_of_day}'"
95
- end
96
-
97
64
  if @value == PERIODS_TODAY
98
65
  return "BETWEEN '#{Time.now.beginning_of_day}' AND " +
99
66
  "'#{Time.now.end_of_day}'"
100
67
  end
101
68
 
102
- # TODO: Remove once new filter protocol is live
103
- match = PERIODS_LAST_X_DAYS.match(@value)
104
- if match && match[1]
105
- return "BETWEEN '#{Integer(match[1]).day.ago.beginning_of_day}'" +
106
- " AND '#{1.day.ago.end_of_day}'"
107
- end
108
-
109
69
  match = PERIODS_PREVIOUS_X_DAYS.match(@value)
110
70
  if match && match[1]
111
71
  return "BETWEEN '#{Integer(match[1]).day.ago.beginning_of_day}'" +
@@ -137,24 +97,11 @@ module ForestLiana
137
97
  def get_interval_date_filter_for_previous_interval
138
98
  return nil unless has_previous_interval()
139
99
 
140
- # TODO: Remove once new filter protocol is live
141
- if @value == PERIODS_TODAY_DEPRECATED
142
- return "BETWEEN '#{1.day.ago.beginning_of_day}' AND " +
143
- "'#{1.day.ago.end_of_day}'"
144
- end
145
-
146
100
  if @value == PERIODS_TODAY
147
101
  return "BETWEEN '#{1.day.ago.beginning_of_day}' AND " +
148
102
  "'#{1.day.ago.end_of_day}'"
149
103
  end
150
104
 
151
- # TODO: Remove once new filter protocol is live
152
- match = PERIODS_LAST_X_DAYS.match(@value)
153
- if match && match[1]
154
- return "BETWEEN '#{(Integer(match[1]) * 2).day.ago.beginning_of_day}'" +
155
- " AND '#{(Integer(match[1]) + 1).day.ago.end_of_day}'"
156
- end
157
-
158
105
  match = PERIODS_PREVIOUS_X_DAYS.match(@value)
159
106
  if match && match[1]
160
107
  return "BETWEEN '#{(Integer(match[1]) * 2).day.ago.beginning_of_day}'" +
@@ -15,7 +15,6 @@ module ForestLiana
15
15
  mattr_accessor :models
16
16
  mattr_accessor :excluded_models
17
17
  mattr_accessor :included_models
18
- mattr_accessor :inject_forest_cors
19
18
 
20
19
  # Legacy.
21
20
  mattr_accessor :jwt_signing_key
@@ -25,5 +24,4 @@ module ForestLiana
25
24
  self.models = []
26
25
  self.excluded_models = []
27
26
  self.included_models = []
28
- self.inject_forest_cors = true
29
27
  end
@@ -13,8 +13,6 @@ module ForestLiana
13
13
  isolate_namespace ForestLiana
14
14
 
15
15
  def configure_forest_cors
16
- return unless ForestLiana.inject_forest_cors
17
-
18
16
  rack_cors_class = Rack::Cors
19
17
  rack_cors_class = 'Rack::Cors' if Rails::VERSION::MAJOR < 5
20
18
 
@@ -30,9 +28,10 @@ module ForestLiana
30
28
  end
31
29
  end
32
30
 
31
+ configure_forest_cors unless ENV['FOREST_CORS_DEACTIVATED']
32
+
33
33
  config.after_initialize do |app|
34
34
  unless Rails.env.test?
35
- configure_forest_cors
36
35
  app.eager_load!
37
36
  Bootstraper.new(app).perform
38
37
  end
@@ -1,3 +1,3 @@
1
1
  module ForestLiana
2
- VERSION = "1.4.3"
2
+ VERSION = "1.4.4"
3
3
  end
@@ -116,7 +116,7 @@ module ForestLiana
116
116
  test 'Filter on an updated_at field of the main collection' do
117
117
  getter = ResourcesGetter.new(Owner, {
118
118
  page: { size: 10, number: 1 },
119
- filter: { 'updated_at' => '<lastYear' },
119
+ filter: { 'updated_at' => '$previousYear' },
120
120
  filterType: 'and'
121
121
  })
122
122
  getter.perform
@@ -131,7 +131,7 @@ module ForestLiana
131
131
  test 'Filter on an updated_at field of an associated collection' do
132
132
  getter = ResourcesGetter.new(Tree, {
133
133
  page: { size: 10, number: 1 },
134
- filter: { 'owner:updated_at' => '<lastYear' },
134
+ filter: { 'owner:updated_at' => '$previousYear' },
135
135
  filterType: 'and'
136
136
  })
137
137
  getter.perform
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forest_liana
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.3
4
+ version: 1.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sandro Munda
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-16 00:00:00.000000000 Z
11
+ date: 2016-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails