grape-reload 0.0.4 → 0.1.0
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 +4 -4
- data/.travis.yml +1 -0
- data/Gemfile +1 -1
- data/grape-reload.gemspec +1 -1
- data/lib/grape/reload/dependency_map.rb +8 -1
- data/lib/grape/reload/grape_api.rb +48 -7
- data/lib/grape/reload/version.rb +1 -1
- data/lib/grape/reload/watcher.rb +1 -1
- data/lib/ripper/extract_constants.rb +24 -5
- data/spec/ripper/extract_constants_spec.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: da9b9fe811b2d7cba4c719a8bc5046cbc2fb97a3
|
|
4
|
+
data.tar.gz: 5698e1ff3994a6982222643bce5b3bbfc2dbbd21
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3e63acc751942a9d1c39439d608f2e65d7508c9f34aae731a7bb5157b6569a1113bac0b8f635c33cd022bd284d0daba18c29151e48a3f980702aa224af377bde
|
|
7
|
+
data.tar.gz: ee0f36a0cd76bd6c317cec13bf94afcc5d417e4841d7970c10d0201aa717af25e068aa8145ab6b6b68335a0be14b1e2da700d2a0d72af796e47959e8c126ea88
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/grape-reload.gemspec
CHANGED
|
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
|
|
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
18
18
|
spec.require_paths = ["lib"]
|
|
19
19
|
|
|
20
|
-
spec.add_runtime_dependency "grape", "~> 0.
|
|
20
|
+
spec.add_runtime_dependency "grape", "~> 0.10.1"
|
|
21
21
|
spec.add_runtime_dependency "rack", "~> 1.5.2"
|
|
22
22
|
|
|
23
23
|
spec.add_development_dependency "bundler", "~> 1.6"
|
|
@@ -24,7 +24,14 @@ module Grape
|
|
|
24
24
|
def initialize(sources)
|
|
25
25
|
@sources = sources
|
|
26
26
|
files = @sources.map{|p| Dir[p]}.flatten.uniq
|
|
27
|
-
@map = Hash[files.zip(files.map
|
|
27
|
+
@map = Hash[files.zip(files.map do |file|
|
|
28
|
+
begin
|
|
29
|
+
Ripper.extract_constants(File.read(file))
|
|
30
|
+
rescue
|
|
31
|
+
Grape::RackBuilder.logger.error("Theres is an error while parsing #{file}")
|
|
32
|
+
[]
|
|
33
|
+
end
|
|
34
|
+
end)]
|
|
28
35
|
end
|
|
29
36
|
|
|
30
37
|
def sorted_files
|
|
@@ -35,6 +35,12 @@ end
|
|
|
35
35
|
|
|
36
36
|
module Grape
|
|
37
37
|
module Reload
|
|
38
|
+
module EndpointPatch
|
|
39
|
+
def clear_inheritable_settings!
|
|
40
|
+
@inheritable_settings.clear
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
38
44
|
module AutoreloadInterceptor
|
|
39
45
|
extend ActiveSupport::Concern
|
|
40
46
|
|
|
@@ -63,17 +69,33 @@ module Grape
|
|
|
63
69
|
METHOD
|
|
64
70
|
end
|
|
65
71
|
|
|
66
|
-
def
|
|
67
|
-
|
|
72
|
+
def fire_definitions!
|
|
73
|
+
@declaration_cache.each {|decl|
|
|
74
|
+
send(decl[0],*deep_reconstantize.call(decl[1]),&decl[2])
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
endpoints.each { |e|
|
|
78
|
+
if e.options[:app].respond_to?('fire_definitions!')
|
|
79
|
+
e.options[:app].inheritable_setting.inherit_from(e.options[:app].inheritable_setting.parent)
|
|
80
|
+
e.options[:app].fire_definitions!
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
}
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def reinit!(root = true)
|
|
87
|
+
@declaration_cache = class_declaration.dup
|
|
68
88
|
@class_decl = []
|
|
69
89
|
endpoints_cache = endpoints
|
|
70
90
|
reset!
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
91
|
+
inheritable_setting.clear!
|
|
92
|
+
top_level_setting.clear!
|
|
93
|
+
endpoints_cache.each { |e|
|
|
94
|
+
e.inheritable_setting.clear!
|
|
95
|
+
e.options[:app].reinit!(false) if e.options[:app].respond_to?('reinit!')
|
|
75
96
|
}
|
|
76
97
|
change!
|
|
98
|
+
fire_definitions! if root
|
|
77
99
|
end
|
|
78
100
|
|
|
79
101
|
def recursive_!
|
|
@@ -103,9 +125,28 @@ METHOD
|
|
|
103
125
|
end
|
|
104
126
|
end
|
|
105
127
|
|
|
128
|
+
module Grape
|
|
129
|
+
module Util
|
|
130
|
+
class InheritableSetting
|
|
131
|
+
def clear!
|
|
132
|
+
self.route = {}
|
|
133
|
+
self.api_class = {}
|
|
134
|
+
self.namespace = InheritableValues.new # only inheritable from a parent when
|
|
135
|
+
# used with a mount, or should every API::Class be a seperate namespace by default?
|
|
136
|
+
self.namespace_inheritable = InheritableValues.new
|
|
137
|
+
self.namespace_stackable = StackableValues.new
|
|
138
|
+
|
|
139
|
+
self.point_in_time_copies = []
|
|
140
|
+
|
|
141
|
+
# self.parent = nil
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
|
|
106
148
|
Grape::API.singleton_class.class_eval do
|
|
107
149
|
alias_method :inherited_shadowed, :inherited
|
|
108
|
-
alias_method :settings_shadowed, :settings
|
|
109
150
|
def inherited(*args)
|
|
110
151
|
inherited_shadowed(*args)
|
|
111
152
|
args.first.class_eval do
|
data/lib/grape/reload/version.rb
CHANGED
data/lib/grape/reload/watcher.rb
CHANGED
|
@@ -197,7 +197,7 @@ end
|
|
|
197
197
|
class ASTBody < ASTEntity
|
|
198
198
|
def self.ripper_id; :bodystmt end
|
|
199
199
|
def initialize(*args)
|
|
200
|
-
@body = args.
|
|
200
|
+
@body = args.reject(&:nil?).map{ |node| ASTEntity.node_for(node) }
|
|
201
201
|
end
|
|
202
202
|
def collect_constants(result, context)
|
|
203
203
|
context[:variable_assignment] = false
|
|
@@ -350,9 +350,7 @@ class ASTModule < ASTEntity
|
|
|
350
350
|
def self.ripper_id; :module end
|
|
351
351
|
def initialize(*args)
|
|
352
352
|
@module_name = args.find{|a| a.first == :const_ref}.last[1]
|
|
353
|
-
@body = args.find{|a| a.first == :bodystmt}
|
|
354
|
-
ASTEntity.node_for(node)
|
|
355
|
-
}
|
|
353
|
+
@body = [ASTEntity.node_for(args.find{|a| a.first == :bodystmt})]
|
|
356
354
|
end
|
|
357
355
|
def collect_constants(result, context)
|
|
358
356
|
result.declare_const(@module_name)
|
|
@@ -387,9 +385,30 @@ class ASTLambda < ASTEntity
|
|
|
387
385
|
end
|
|
388
386
|
end
|
|
389
387
|
|
|
388
|
+
class ASTStatementsAdd < ASTEntity
|
|
389
|
+
def self.ripper_id; :stmts_add end
|
|
390
|
+
def initialize(*args)
|
|
391
|
+
super(*args)
|
|
392
|
+
end
|
|
393
|
+
end
|
|
394
|
+
|
|
395
|
+
class ASTStatementsNew < ASTEntity
|
|
396
|
+
def self.ripper_id; :stmts_new end
|
|
397
|
+
def initialize(*args)
|
|
398
|
+
super(*args)
|
|
399
|
+
end
|
|
400
|
+
end
|
|
401
|
+
|
|
402
|
+
class ASTStatementsProgram < ASTEntity
|
|
403
|
+
def self.ripper_id; :program end
|
|
404
|
+
def initialize(*args)
|
|
405
|
+
super(args.first)
|
|
406
|
+
end
|
|
407
|
+
end
|
|
408
|
+
|
|
390
409
|
class Ripper
|
|
391
410
|
def self.extract_constants(code)
|
|
392
|
-
ast = Ripper.
|
|
411
|
+
ast = Ripper.sexp_raw(code)
|
|
393
412
|
result = ASTEntity.node_for(ast).collect_constants(TraversingResult.new)
|
|
394
413
|
consts = result.extract_consts
|
|
395
414
|
consts[:declared].flatten!
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: grape-reload
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0
|
|
4
|
+
version: 0.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- AMar4enko
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2015-02-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: grape
|
|
@@ -16,14 +16,14 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version:
|
|
19
|
+
version: 0.10.1
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version:
|
|
26
|
+
version: 0.10.1
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: rack
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -252,7 +252,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
252
252
|
version: '0'
|
|
253
253
|
requirements: []
|
|
254
254
|
rubyforge_project:
|
|
255
|
-
rubygems_version: 2.
|
|
255
|
+
rubygems_version: 2.4.5
|
|
256
256
|
signing_key:
|
|
257
257
|
specification_version: 4
|
|
258
258
|
summary: Grape autoreload gem
|