Module: Ree
- Extended by:
- Args
- Defined in:
- lib/ree.rb,
lib/ree/cli.rb,
lib/ree/gen.rb,
lib/ree/version.rb,
lib/ree/cli/init.rb,
lib/ree/gen/init.rb,
lib/ree/gen/package.rb,
lib/ree/spec_runner.rb,
lib/ree/cli/indexing.rb,
lib/ree/cli/spec_runner.rb,
lib/ree/cli/generate_package.rb,
lib/ree/cli/generate_template.rb,
lib/ree/cli/indexing/index_file.rb,
lib/ree/cli/indexing/index_package.rb,
lib/ree/cli/indexing/index_project.rb,
lib/ree/cli/generate_package_schema.rb,
lib/ree/cli/generate_packages_schema.rb
Defined Under Namespace
Modules: Args, BeanDSL, CLI, Contracts, FnDSL, Gen, Inspectable, LinkDSL, ObjectSchema, PackageDSL, PackageSchema, PackagesSchema, RSpecLinkDSL, SpecRunner
Classes: BuildPackageDsl, Container, DomainError, Error, ErrorDsl, ImportDsl, LinkImportBuilder, LinkValidator, Object, ObjectCompiler, ObjectDsl, ObjectError, ObjectLink, Package, PackageDep, PackageEnvVar, PackageLoader, PackageSchemaBuilder, PackageSchemaLoader, PackagesDetector, PackagesFacade, PackagesSchemaBuilder, PackagesSchemaLoader, PackagesSchemaLocator, PackagesStore, PathHelper, ReeGem, RenderUtils, StringUtils, TemplateDetector, TemplateHandler, TemplateRenderer
Constant Summary
collapse
- PACKAGE =
'package'
- SCHEMAS =
'schemas'
- SCHEMA =
'schema'
- REE_SETUP =
'ree.setup.rb'
- PACKAGE_SCHEMA_FILE =
'Package.schema.json'
- PACKAGES_SCHEMA_FILE =
'Packages.schema.json'
- ROOT_DIR_MESSAGE =
'Ree.root_dir is not set. Use Ree.init(DIR) to set project dir'
- VERSION =
"1.0.47"
Class Method Summary
collapse
Methods included from Args
check_arg, check_arg_any, check_arg_array_of, check_bool, not_nil
Class Method Details
.disable_contracts ⇒ Object
103
104
105
|
# File 'lib/ree.rb', line 103
def disable_contracts
ENV['NO_CONTRACTS'] = 'true'
end
|
.disable_irb_mode ⇒ Object
99
100
101
|
# File 'lib/ree.rb', line 99
def disable_irb_mode
@irb_mode = false
end
|
.enable_contracts ⇒ Object
107
108
109
|
# File 'lib/ree.rb', line 107
def enable_contracts
ENV['NO_CONTRACTS'] = nil
end
|
.enable_irb_mode ⇒ Object
Switches Ree into irb mode that allows to declare ree objects inside IRB
95
96
97
|
# File 'lib/ree.rb', line 95
def enable_irb_mode
@irb_mode = true
end
|
173
174
175
176
|
# File 'lib/ree.rb', line 173
def gem(name)
check_arg(name, :name, Symbol)
gems.detect { _1.name == name }
end
|
178
179
180
181
|
# File 'lib/ree.rb', line 178
def gems
@gems ||= []
@gems
end
|
.generate_schemas_for_all_packages(silence = false) ⇒ Object
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
|
# File 'lib/ree.rb', line 232
def generate_schemas_for_all_packages(silence = false)
Ree.logger.debug("generate_schemas_for_all_packages") if !silence
facade = container.packages_facade
facade.class.write_packages_schema
facade.load_packages_schema
facade.packages_store.packages.each do |package|
next if package.gem?
next if package.dir.nil?
puts("Generating Package.schema.json for :#{package.name} package") if !silence
facade.load_entire_package(package.name)
facade.write_package_schema(package.name)
end
end
|
.init(dir, irb: false) ⇒ Object
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
# File 'lib/ree.rb', line 143
def init(dir, irb: false)
check_arg(dir, :dir, String)
if !Dir.exist?(dir)
raise Ree::Error.new("Dir does not exist: #{dir}", :invalid_root_dir)
end
@packages_schema_path = locate_packages_schema(dir)
@root_dir = Pathname.new(@packages_schema_path).dirname.to_s
ree_setup_path = File.join(@root_dir, REE_SETUP)
if File.exist?(ree_setup_path)
require(ree_setup_path)
end
if irb
require('irb')
enable_irb_mode
FileUtils.cd(@root_dir) do
IRB.start(@root_dir)
end
end
@root_dir
end
|
.irb_mode? ⇒ Boolean
111
112
113
|
# File 'lib/ree.rb', line 111
def irb_mode?
!!@irb_mode
end
|
.load_package(name) ⇒ Object
213
214
215
216
|
# File 'lib/ree.rb', line 213
def load_package(name)
check_arg(name, :name, Symbol)
container.load_package(name)
end
|
.locate_packages_schema(path) ⇒ Object
218
219
220
221
222
|
# File 'lib/ree.rb', line 218
def locate_packages_schema(path)
check_arg(path, :path, String)
Ree.logger.debug("locate_packages_schema: #{path}")
Ree::PackagesSchemaLocator.new.call(path)
end
|
84
85
86
87
88
89
90
91
92
|
# File 'lib/ree.rb', line 84
def logger
@logger ||= begin
logger = Logger.new(STDOUT)
logger.level = Logger::WARN
logger
end
@logger
end
|
.packages_schema_path ⇒ Object
224
225
226
|
# File 'lib/ree.rb', line 224
def packages_schema_path
@packages_schema_path || (raise Ree::Error.new(ROOT_DIR_MESSAGE, :invalid_root_dir))
end
|
128
129
130
|
# File 'lib/ree.rb', line 128
def performance_mode?
!!@performance_mode
end
|
.preload_for(env) ⇒ Object
Define preload context for registered objects
133
134
135
136
|
# File 'lib/ree.rb', line 133
def preload_for(env)
check_arg(env, :env, Symbol)
@prelaod_for = env
end
|
.preload_for?(env) ⇒ Boolean
138
139
140
141
|
# File 'lib/ree.rb', line 138
def preload_for?(env)
check_arg(env, :env, Symbol)
@prelaod_for == env
end
|
.register_gem(gem_name, dir) ⇒ Ree::ReeGem
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
# File 'lib/ree.rb', line 186
def register_gem(gem_name, dir)
check_arg(gem_name, :gem_name, Symbol)
check_arg(dir, :dir, String)
if gem(gem_name)
raise Ree::Error.new("Ree already registered gem `#{name}`", :duplicate_gem)
end
if !Dir.exist?(dir)
raise Ree::Error.new("Dir does not exist: #{dir}", :invalid_gem_dir)
end
dir = File.expand_path(dir)
packages_schema_path = locate_packages_schema(dir)
gem_dir = Pathname.new(packages_schema_path).dirname.to_s
ree_setup_path = File.join(gem_dir, REE_SETUP)
if File.exist?(ree_setup_path)
require(ree_setup_path)
end
gem = ReeGem.new(gem_name, gem_dir, packages_schema_path)
@gems.push(gem)
gem
end
|
.set_dev_mode ⇒ Object
124
125
126
|
# File 'lib/ree.rb', line 124
def set_dev_mode
@performance_mode = false
end
|
.set_logger_debug ⇒ Object
115
116
117
|
# File 'lib/ree.rb', line 115
def set_logger_debug
logger.level = Logger::DEBUG
end
|
Ree will use schema files to load packages and registered objects
120
121
122
|
# File 'lib/ree.rb', line 120
def set_performance_mode
@performance_mode = true
end
|