Module: Appsules

Defined in:
lib/appsules.rb,
lib/appsules/railtie.rb,
lib/appsules/version.rb

Defined Under Namespace

Classes: Railtie

Constant Summary collapse

VERSION =
"1.1.0"

Class Method Summary collapse

Class Method Details

.add_factory_bot_paths!Object



7
8
9
10
11
# File 'lib/appsules.rb', line 7

def self.add_factory_bot_paths!
  Dir[File.join(Appsules.test_path, "*")].each do |appsule_path|
    FactoryBot.definition_file_paths << File.join(appsule_path, "factories")
  end
end

.add_factory_girl_paths!Object



13
14
15
16
17
# File 'lib/appsules.rb', line 13

def self.add_factory_girl_paths!
  Dir[File.join(Appsules.test_path, "*")].each do |appsule_path|
    FactoryGirl.definition_file_paths << File.join(appsule_path, "factories")
  end
end

.add_helpers(appsule_path, initializer_context) ⇒ Object

for internal use by the appsules gem



34
35
36
37
38
39
40
41
42
43
# File 'lib/appsules.rb', line 34

def self.add_helpers(appsule_path, initializer_context)
  return unless initializer_context.respond_to?(:helper)

  helpers_dir = File.join(appsule_path, "helpers")

  Dir[File.join(helpers_dir, "**", "*_helper.rb")].map do |helper_path|
    module_name = helper_path.sub(%r{^#{helpers_dir}/(.+)\.rb}i, '\1').classify
    initializer_context.instance_eval "helper #{module_name}"
  end
end

.pathObject



26
27
28
29
30
31
# File 'lib/appsules.rb', line 26

def self.path
  return @@path if defined?(@@path)
  @@path = Rails.root.join("appsules")
  FileUtils.mkdir_p @@path
  @@path
end

.test_pathObject



19
20
21
22
23
24
# File 'lib/appsules.rb', line 19

def self.test_path
  return @@test_path if defined?(@@test_path)
  @@test_path = Rails.root.join("test", "appsules")
  FileUtils.mkdir_p @@test_path
  @@test_path
end