sweet-moon 0.0.4 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,17 +1,19 @@
1
1
  require_relative '../../../logic/interpreters/interpreter_54'
2
2
 
3
+ require_relative 'function'
3
4
  require_relative 'reader'
4
- require_relative 'writer'
5
5
  require_relative 'table'
6
+ require_relative 'writer'
6
7
 
7
8
  module Component
8
9
  module V54
9
10
  Interpreter = {
10
11
  version: Logic::V54::Interpreter[:version],
12
+ logic: Logic::V54,
11
13
 
12
14
  create_state!: ->(api) {
13
15
  state = api.luaL_newstate
14
- { state: { lua: state, avoid_gc: [] },
16
+ { state: { lua: state, avoid_gc: [], ruby_error_info: nil },
15
17
  error: state ? nil : :MemoryAllocation }
16
18
  },
17
19
 
@@ -40,7 +42,7 @@ module Component
40
42
  },
41
43
 
42
44
  push_value!: ->(api, state, value) {
43
- Writer[:push!].(api, state, value)
45
+ Writer[:push!].(api, state, Component::V54, value)
44
46
  { state: state }
45
47
  },
46
48
 
@@ -55,7 +57,7 @@ module Component
55
57
  unless key.nil?
56
58
  if api.lua_typename(state[:lua],
57
59
  api.lua_type(state[:lua], -1)).read_string == 'table'
58
- Table[:read_field!].(api, state, key, -1)
60
+ Table[:read_field!].(api, state, Component::V54, key, -1)
59
61
  else
60
62
  api.lua_pushnil(state[:lua])
61
63
  end
@@ -70,7 +72,8 @@ module Component
70
72
  },
71
73
 
72
74
  read_and_pop!: ->(api, state, stack_index = -1, extra_pop: false) {
73
- result = Component::V54::Reader[:read!].(api, state, stack_index)
75
+ result = Component::V54::Reader[:read!].(api, state, Component::V54,
76
+ stack_index)
74
77
 
75
78
  api.lua_settop(state[:lua], -2) if result[:pop]
76
79
  api.lua_settop(state[:lua], -2) if extra_pop
@@ -79,7 +82,7 @@ module Component
79
82
  },
80
83
 
81
84
  read_all!: ->(api, state) {
82
- result = Reader[:read_all!].(api, state)
85
+ result = Reader[:read_all!].(api, state, Component::V54)
83
86
 
84
87
  { state: state, output: result }
85
88
  },
@@ -7,33 +7,34 @@ require_relative 'table'
7
7
  module Component
8
8
  module V54
9
9
  Reader = {
10
- read_all!: ->(api, state) {
10
+ read_all!: ->(api, state, component) {
11
11
  (1..api.lua_gettop(state[:lua])).map do
12
- Interpreter[:read_and_pop!].(api, state)[:output]
12
+ component::Interpreter[:read_and_pop!].(api, state)[:output]
13
13
  end.reverse
14
14
  },
15
15
 
16
- read!: ->(api, state, stack_index = -1) {
16
+ read!: ->(api, state, component, stack_index = -1) {
17
17
  stack_index = api.lua_gettop(state[:lua]) if stack_index == -1
18
18
 
19
- type = api.lua_typename(state[:lua],
20
- api.lua_type(state[:lua], stack_index)).read_string
19
+ type = api.lua_typename(
20
+ state[:lua], api.lua_type(state[:lua], stack_index)
21
+ ).read_string
21
22
 
22
23
  case type
23
24
  when 'string'
24
- Reader[:read_string!].(api, state, stack_index)
25
+ component::Reader[:read_string!].(api, state, stack_index)
25
26
  when 'number'
26
- Reader[:read_number!].(api, state, stack_index)
27
+ component::Reader[:read_number!].(api, state, stack_index)
27
28
  when 'no value'
28
29
  { value: nil, pop: true, type: type }
29
30
  when 'nil'
30
31
  { value: nil, pop: true }
31
32
  when 'boolean'
32
- Reader[:read_boolean!].(api, state, stack_index)
33
+ component::Reader[:read_boolean!].(api, state, stack_index)
33
34
  when 'table'
34
- Table[:read!].(api, state, stack_index)
35
+ component::Table[:read!].(api, state, component, stack_index)
35
36
  when 'function'
36
- Function[:read!].(api, state, stack_index)
37
+ component::Function[:read!].(api, state, component, stack_index)
37
38
  else
38
39
  # none nil boolean lightuserdata number
39
40
  # string table function userdata thread
@@ -6,31 +6,36 @@ require_relative 'reader'
6
6
  module Component
7
7
  module V54
8
8
  Table = {
9
- push!: ->(api, state, list, stack_index = -1) {
9
+ create_table!: ->(api, state, list) {
10
+ api.lua_createtable(state[:lua], list.size, 0)
11
+ },
12
+
13
+ push!: ->(api, state, component, list, stack_index = -1) {
10
14
  stack_index = api.lua_gettop(state[:lua]) if stack_index == -1
11
15
 
12
- api.lua_createtable(state[:lua], list.size, 0)
16
+ component::Table[:create_table!].(api, state, list)
13
17
 
14
18
  if list.is_a? Hash
15
19
  list.each_key do |key|
16
- Writer[:push!].(api, state, key)
17
- Writer[:push!].(api, state, list[key])
20
+ component::Writer[:push!].(api, state, component, key)
21
+ component::Writer[:push!].(api, state, component, list[key])
18
22
  api.lua_settable(state[:lua], stack_index + 1)
19
23
  end
20
24
  else
21
25
  list.each_with_index do |value, index|
22
- Writer[:push!].(api, state, index + 1)
23
- Writer[:push!].(api, state, value)
26
+ component::Writer[:push!].(api, state, component, index + 1)
27
+ component::Writer[:push!].(api, state, component, value)
24
28
  api.lua_settable(state[:lua], stack_index + 1)
25
29
  end
26
30
  end
27
31
  },
28
32
 
29
- read!: ->(api, state, stack_index) {
33
+ read!: ->(api, state, component, stack_index) {
30
34
  stack_index = api.lua_gettop(state[:lua]) if stack_index == -1
31
35
 
32
- type = api.lua_typename(state[:lua],
33
- api.lua_type(state[:lua], stack_index)).read_string
36
+ type = api.lua_typename(
37
+ state[:lua], api.lua_type(state[:lua], stack_index)
38
+ ).read_string
34
39
 
35
40
  api.lua_pushnil(state[:lua])
36
41
 
@@ -39,8 +44,8 @@ module Component
39
44
  tuples = []
40
45
 
41
46
  while api.lua_next(state[:lua], stack_index).positive?
42
- value = Reader[:read!].(api, state, stack_index + 2)
43
- key = Reader[:read!].(api, state, stack_index + 1)
47
+ value = component::Reader[:read!].(api, state, component, stack_index + 2)
48
+ key = component::Reader[:read!].(api, state, component, stack_index + 1)
44
49
  api.lua_settop(state[:lua], -2) if value[:pop]
45
50
 
46
51
  tuples << [key[:value], value[:value]]
@@ -51,7 +56,7 @@ module Component
51
56
  { value: Logic::Tables[:to_hash_or_array].(tuples), pop: true }
52
57
  },
53
58
 
54
- read_field!: ->(api, state, expected_key, stack_index) {
59
+ read_field!: ->(api, state, _component, expected_key, stack_index) {
55
60
  expected_key = expected_key.to_s if expected_key.is_a? Symbol
56
61
 
57
62
  api.lua_getfield(state[:lua], stack_index, expected_key)
@@ -4,8 +4,8 @@ require_relative 'table'
4
4
  module Component
5
5
  module V54
6
6
  Writer = {
7
- push!: ->(api, state, value) {
8
- case Writer[:_to_lua_type].(value)
7
+ push!: ->(api, state, component, value) {
8
+ case component::Writer[:_to_lua_type].(value)
9
9
  when 'string'
10
10
  api.lua_pushstring(state[:lua], value.to_s)
11
11
  when 'number'
@@ -21,9 +21,9 @@ module Component
21
21
  when 'boolean'
22
22
  api.lua_pushboolean(state[:lua], value ? 1 : 0)
23
23
  when 'table'
24
- Table[:push!].(api, state, value)
24
+ component::Table[:push!].(api, state, component, value)
25
25
  when 'function'
26
- Function[:push!].(api, state, value)
26
+ component::Function[:push!].(api, state, component, value)
27
27
  else
28
28
  api.lua_pushstring(
29
29
  state[:lua], "#<#{value.class}:0x#{format('%016x', value.object_id)}>"
@@ -1,43 +1,44 @@
1
1
  # Available at https://github.com/gbaptista/sweet-moon-test
2
2
 
3
- fennel-dev: '/home/me/sweet-moon-test/fennel-dev.lua'
3
+ fennel-dev: '/home/gbaptista/Fennel/?.lua'
4
4
 
5
5
  luarocks:
6
+ expected: ['dkjson', 'supernova', 'readline']
6
7
  path:
7
8
  - /home/me/.luarocks/share/lua/5.4/?.lua
8
9
  - /home/me/.luarocks/share/lua/5.4/?/init.lua
10
+ cpath:
9
11
  - /home/me/.luarocks/lib/lua/5.4/?.so
10
- expected: ['supernova', 'dkjson', 'lfs']
11
12
 
12
13
  jit:2.0.5:
13
14
  description: 'Lua Jit 2.0.5 + Fennel 1.0.0'
14
15
  shared_object: /home/me/sweet-moon-test/libluajit.so.2.0.5
15
- fennel: /home/me/sweet-moon-test/fennel-100.lua
16
+ fennel: /home/me/sweet-moon-test/fennel/100/?.lua
16
17
 
17
18
  5.4.4:
18
19
  description: 'Lua 5.4.4 + Fennel 1.0.0'
19
20
  shared_object: /home/me/sweet-moon-test/liblua.so.5.4.4
20
- fennel: /home/me/sweet-moon-test/fennel-100.lua
21
+ fennel: /home/me/sweet-moon-test/fennel/100/?.lua
21
22
 
22
23
  5.4.2:
23
24
  description: 'Lua 5.4.2 + Fennel 1.0.0'
24
25
  shared_object: /home/me/sweet-moon-test/liblua.so.5.4.2
25
- fennel: /home/me/sweet-moon-test/fennel-100.lua
26
+ fennel: /home/me/sweet-moon-test/fennel/100/?.lua
26
27
 
27
28
  5.3.3:
28
29
  description: 'Lua 5.3.3'
29
30
  shared_object: /home/me/sweet-moon-test/liblua.so.5.3.3
30
- fennel: /home/me/sweet-moon-test/fennel-100.lua
31
+ fennel: /home/me/sweet-moon-test/fennel/100/?.lua
31
32
 
32
33
  5.2.4:
33
34
  description: 'Lua 5.2.4'
34
35
  shared_object: /home/me/sweet-moon-test/liblua.so.5.2.4
35
- fennel: /home/me/sweet-moon-test/fennel-100.lua
36
+ fennel: /home/me/sweet-moon-test/fennel/100/?.lua
36
37
 
37
38
  5.1.5:
38
39
  description: 'Lua 5.1.5'
39
40
  shared_object: /home/me/sweet-moon-test/liblua.so.5.1.5
40
- fennel: /home/me/sweet-moon-test/fennel-100.lua
41
+ fennel: /home/me/sweet-moon-test/fennel/100/?.lua
41
42
 
42
43
  5.0.3:
43
44
  description: 'Lua 5.0.3'
data/controllers/api.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require_relative '../components/injections'
2
2
  require_relative '../components/api'
3
+ require_relative '../components/default'
3
4
  require_relative '../components/io'
4
5
  require_relative '../dsl/errors'
5
6
 
@@ -11,7 +12,9 @@ module Controller
11
12
  handle!: ->(options) {
12
13
  shared_objects = API[:elect_shared_objects!].(options[:shared_objects])
13
14
 
14
- api = Component::API[:open!].(shared_objects)
15
+ api = Component::API[:open!].(
16
+ shared_objects, options, Component::Default.instance.options
17
+ )
15
18
 
16
19
  api_reference = API[:elect_api_reference!].(
17
20
  api.ffi_libraries, options[:api_reference]
data/controllers/state.rb CHANGED
@@ -87,10 +87,20 @@ module Controller
87
87
  },
88
88
 
89
89
  _check!: ->(result) {
90
+ ruby_error = result[:state] && result[:state][:ruby_error_info]
91
+
92
+ result[:state][:ruby_error_info] = nil if ruby_error
93
+
90
94
  if result[:error]
91
- raise SweetMoon::Errors::SweetMoonErrorHelper.for(
92
- result[:error][:status]
93
- ), result[:error][:value]
95
+ if ruby_error
96
+ raise SweetMoon::Errors::SweetMoonErrorHelper.merge_traceback!(
97
+ ruby_error, result[:error][:value]
98
+ )
99
+ else
100
+ raise SweetMoon::Errors::SweetMoonErrorHelper.for(
101
+ result[:error][:status]
102
+ ), result[:error][:value]
103
+ end
94
104
  end
95
105
 
96
106
  result
data/dsl/api.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require_relative '../components/default'
2
+
1
3
  module DSL
2
4
  class Api
3
5
  attr_reader :functions, :meta
@@ -7,13 +9,31 @@ module DSL
7
9
 
8
10
  @functions = @component[:signatures].keys
9
11
 
10
- @meta = Struct.new(
11
- *@component[:meta][:elected].keys
12
- ).new(*@component[:meta][:elected].values)
12
+ build_meta
13
13
 
14
14
  extend @component[:api]
15
15
  end
16
16
 
17
+ def build_global_ffi
18
+ global_ffi = Component::Default.instance.options[:global_ffi]
19
+
20
+ unless @component[:meta][:options][:global_ffi].nil?
21
+ global_ffi = @component[:meta][:options][:global_ffi]
22
+ end
23
+
24
+ global_ffi
25
+ end
26
+
27
+ def build_meta
28
+ meta_data = @component[:meta][:elected].clone
29
+
30
+ meta_data[:global_ffi] = build_global_ffi
31
+
32
+ @meta = Struct.new(
33
+ *meta_data.keys
34
+ ).new(*meta_data.values)
35
+ end
36
+
17
37
  def signature_for(function)
18
38
  @component[:signatures][function.to_sym]
19
39
  end
data/dsl/cache.rb CHANGED
@@ -7,112 +7,126 @@ require_relative '../controllers/state'
7
7
  require_relative 'api'
8
8
  require_relative 'sweet_moon'
9
9
 
10
- class Cache
11
- include Singleton
10
+ module DSL
11
+ class Cache
12
+ include Singleton
12
13
 
13
- def clear_global!
14
- @cache[:global_state]&._unsafely_destroy
14
+ API_KEYS = %i[shared_objects api_reference global_ffi]
15
+ STATE_KEYS = %i[interpreter package_path package_cpath]
15
16
 
16
- @cache.each_key { |key| @cache.delete(key) if key[/^global/] }
17
- end
17
+ def api_keys?(options)
18
+ API_KEYS.each { |key| return true if options.key?(key) }
19
+ false
20
+ end
18
21
 
19
- def keys
20
- @cache.keys
21
- end
22
+ def state_keys?(options)
23
+ STATE_KEYS.each { |key| return true if options.key?(key) }
24
+ false
25
+ end
22
26
 
23
- def initialize
24
- @cache = {}
25
- end
27
+ def clear_global!
28
+ @cache[:global_state]&._unsafely_destroy
26
29
 
27
- def global_state(options = {}, recreate: false)
28
- key = :global_state
30
+ @cache.each_key { |key| @cache.delete(key) if key[/^global/] }
31
+ end
29
32
 
30
- clear_global_state_cache!(options) if recreate
33
+ def keys
34
+ @cache.keys
35
+ end
31
36
 
32
- return @cache[key] if @cache[key]
37
+ def initialize
38
+ @cache = {}
39
+ end
33
40
 
34
- api = Cache.instance.api_module(options, :global_api_module)
35
- interpreter = Cache.instance.interpreter_module(
36
- api, options, :global_interpreter_module
37
- )
41
+ def global_state(options = {}, recreate: false)
42
+ key = :global_state
38
43
 
39
- @cache[key] = DSL::State.new(api, interpreter, Controller::State, options)
40
- @cache[key].instance_eval('undef :destroy', __FILE__, __LINE__)
44
+ clear_global_state_cache!(options) if recreate
41
45
 
42
- @cache[key]
43
- end
46
+ return @cache[key] if @cache[key]
44
47
 
45
- def global_api(options = {}, recreate: false)
46
- key = :global_api
48
+ api = Cache.instance.api_module(options, :global_api_module)
49
+ interpreter = Cache.instance.interpreter_module(
50
+ api, options, :global_interpreter_module
51
+ )
47
52
 
48
- clear_global_api_cache! if recreate
53
+ @cache[key] = DSL::State.new(api, interpreter, Controller::State, options)
54
+ @cache[key].instance_eval('undef :destroy', __FILE__, __LINE__)
49
55
 
50
- @cache[key] ||= api(options, :global_api, :global_api_module)
51
- end
56
+ @cache[key]
57
+ end
52
58
 
53
- def api(options = {}, key = nil, api_module_key = nil)
54
- key ||= cache_key_for(:api, options, %i[shared_objects api_reference])
55
- @cache[key] ||= DSL::Api.new(api_module(options, api_module_key))
56
- end
59
+ def global_api(options = {}, recreate: false)
60
+ key = :global_api
57
61
 
58
- def api_module(options = {}, key = nil)
59
- key ||= cache_key_for(:api_module, options, %i[shared_objects api_reference])
60
- @cache[key] ||= Controller::API[:handle!].(options)
61
- end
62
+ clear_global_api_cache! if recreate
62
63
 
63
- def interpreter_module(api, options = {}, key = nil)
64
- key ||= cache_key_for(
65
- :interpreter_module,
66
- { shared_objects: api[:meta][:elected][:shared_objects],
67
- api_reference: api[:meta][:elected][:api_reference],
68
- interpreter: options[:interpreter], package_path: options[:package_path],
69
- package_cpath: options[:package_cpath] },
70
- %i[shared_objects api_reference interpreter package_path package_cpath]
71
- )
72
-
73
- @cache[key] ||= Controller::Interpreter[:handle!].(api, options)
74
- end
64
+ @cache[key] ||= api(options, :global_api, :global_api_module)
65
+ end
75
66
 
76
- private
67
+ def api(options = {}, key = nil, api_module_key = nil)
68
+ key ||= cache_key_for(:api, options, API_KEYS)
69
+ @cache[key] ||= DSL::Api.new(api_module(options, api_module_key))
70
+ end
77
71
 
78
- def clear_global_api_cache!
79
- @cache[:global_state]&._unsafely_destroy
72
+ def api_module(options = {}, key = nil)
73
+ key ||= cache_key_for(:api_module, options, API_KEYS)
74
+ @cache[key] ||= Controller::API[:handle!].(options)
75
+ end
80
76
 
81
- %i[global_api global_api_module
82
- global_interpreter_module
83
- global_state].each do |key|
84
- @cache.delete(key)
77
+ def interpreter_module(api, options = {}, key = nil)
78
+ key ||= cache_key_for(
79
+ :interpreter_module,
80
+ { shared_objects: api[:meta][:elected][:shared_objects],
81
+ api_reference: api[:meta][:elected][:api_reference],
82
+ global_ffi: api[:meta][:global_ffi],
83
+ interpreter: options[:interpreter], package_path: options[:package_path],
84
+ package_cpath: options[:package_cpath] },
85
+ API_KEYS.concat(STATE_KEYS)
86
+ )
87
+
88
+ @cache[key] ||= Controller::Interpreter[:handle!].(api, options)
85
89
  end
86
- end
87
90
 
88
- def clear_global_state_cache!(options)
89
- @cache[:global_state]&._unsafely_destroy
91
+ def cache_key_for(prefix, options = {}, relevant_keys = [])
92
+ values = [prefix]
90
93
 
91
- %i[global_interpreter_module global_state].each do |key|
92
- @cache.delete(key)
93
- end
94
+ relevant_keys.each do |key|
95
+ value = options[key]
96
+ value = options[key.to_s] if value.nil?
94
97
 
95
- return unless options.key?(:shared_objects) || options.key?(:api_reference)
98
+ values << (value.is_a?(Array) ? value.sort.join(':') : value.inspect)
99
+ end
96
100
 
97
- %i[global_api global_api_module].each do |key|
98
- @cache.delete(key)
101
+ values.join('|')
99
102
  end
100
103
 
101
- global_api(options, recreate: true)
102
- end
104
+ private
103
105
 
104
- def cache_key_for(prefix, options = {}, relevant_keys = [])
105
- values = [prefix]
106
+ def clear_global_api_cache!
107
+ @cache[:global_state]&._unsafely_destroy
106
108
 
107
- relevant_keys.each do |key|
108
- value = options[key] || options[key.to_s]
109
- if value.is_a?(Array)
110
- values << value.sort.join(':')
111
- elsif value
112
- values << value
109
+ %i[global_api global_api_module
110
+ global_interpreter_module
111
+ global_state].each do |key|
112
+ @cache.delete(key)
113
113
  end
114
114
  end
115
115
 
116
- values.join('|')
116
+ def clear_global_state_cache!(options)
117
+ @cache[:global_state]&._unsafely_destroy
118
+
119
+ %i[global_interpreter_module global_state].each do |key|
120
+ @cache.delete(key)
121
+ end
122
+
123
+ return unless api_keys?(options)
124
+
125
+ %i[global_api global_api_module].each do |key|
126
+ @cache.delete(key)
127
+ end
128
+
129
+ global_api(options, recreate: true)
130
+ end
117
131
  end
118
132
  end
data/dsl/errors.rb CHANGED
@@ -10,6 +10,14 @@ module SweetMoon
10
10
  class LuaFileError < LuaError; end
11
11
 
12
12
  module SweetMoonErrorHelper
13
+ def merge_traceback!(ruby_error, lua_traceback)
14
+ ruby_error.set_backtrace(
15
+ ruby_error.backtrace.concat(lua_traceback.split("\n"))
16
+ )
17
+
18
+ ruby_error
19
+ end
20
+
13
21
  def for(status)
14
22
  case status
15
23
  when :runtime then LuaRuntimeError
@@ -22,7 +30,7 @@ module SweetMoon
22
30
  end
23
31
  end
24
32
 
25
- module_function :for
33
+ module_function :for, :merge_traceback!
26
34
  end
27
35
  end
28
36
  end
data/dsl/fennel.rb CHANGED
@@ -11,8 +11,7 @@ module DSL
11
11
  'table.insert(package.loaders or package.searchers, fennel.searcher)'
12
12
  )
13
13
 
14
- # TODO: Makes sense?
15
- # debug.traceback = fennel.traceback
14
+ @state.eval('debug.traceback = fennel.traceback')
16
15
 
17
16
  @eval = @state.get(:fennel, :eval)
18
17
  @dofile = @state.get(:fennel, :dofile)
@@ -21,12 +20,16 @@ module DSL
21
20
  build_meta
22
21
  end
23
22
 
24
- def eval(input, outputs = 1)
25
- @eval.([input], outputs)
23
+ def eval(input, first = nil, second = nil)
24
+ options = _build_options(first, second)
25
+
26
+ @eval.([input, options[:options]], options[:outputs])
26
27
  end
27
28
 
28
- def load(path, outputs = 1)
29
- @dofile.([path], outputs)
29
+ def load(path, first = nil, second = nil)
30
+ options = _build_options(first, second)
31
+
32
+ @dofile.([path, options[:options]], options[:outputs])
30
33
  end
31
34
 
32
35
  def build_meta
data/dsl/global.rb CHANGED
@@ -2,41 +2,40 @@ require_relative '../logic/options'
2
2
 
3
3
  require_relative 'cache'
4
4
 
5
- module Global
6
- def api
7
- Cache.instance.global_api
8
- end
5
+ module DSL
6
+ module Global
7
+ def api
8
+ Cache.instance.global_api
9
+ end
9
10
 
10
- def state
11
- Cache.instance.global_state
12
- end
11
+ def state
12
+ Cache.instance.global_state
13
+ end
13
14
 
14
- def config(options = {})
15
- options = Logic::Options[:normalize].(options)
15
+ def config(options = {})
16
+ options = Logic::Options[:normalize].(options)
16
17
 
17
- if options.key?(:shared_objects) || options.key?(:api_reference)
18
- Cache.instance.global_api(options, recreate: true)
19
- end
18
+ if Cache.instance.api_keys?(options)
19
+ Cache.instance.global_api(options, recreate: true)
20
+ end
20
21
 
21
- return unless
22
- options.key?(:interpreter) ||
23
- options.key?(:package_path) ||
24
- options.key?(:package_cpath)
22
+ return unless Cache.instance.state_keys?(options)
25
23
 
26
- Cache.instance.global_state(options, recreate: true)
24
+ Cache.instance.global_state(options, recreate: true)
27
25
 
28
- nil
29
- end
26
+ nil
27
+ end
30
28
 
31
- def cached(all: false)
32
- return Cache.instance.keys if all
29
+ def cached(all: false)
30
+ return Cache.instance.keys if all
33
31
 
34
- Cache.instance.keys.select { |key| key[/^global/] }
35
- end
32
+ Cache.instance.keys.select { |key| key[/^global/] }
33
+ end
36
34
 
37
- def clear
38
- Cache.instance.clear_global!
39
- end
35
+ def clear
36
+ Cache.instance.clear_global!
37
+ end
40
38
 
41
- module_function :api, :state, :config, :cached, :clear
39
+ module_function :api, :state, :config, :cached, :clear
40
+ end
42
41
  end