Class: GoNative::Plugins::Android::Create

Inherits:
Object
  • Object
show all
Extended by:
DSL::Serviceable
Defined in:
lib/gonative/plugins/android/create.rb

Constant Summary collapse

TEMPLATE_DIRECTORY_PATH =
File.expand_path(File.join(__dir__, '../../../..', 'templates', 'plugins', 'android'))

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(plugin_name) ⇒ Create

Returns a new instance of Create.



17
18
19
# File 'lib/gonative/plugins/android/create.rb', line 17

def initialize(plugin_name)
  @plugin_name = Utils::SanitizePluginName.call(plugin_name, 'android')
end

Instance Attribute Details

#plugin_nameObject (readonly)

Returns the value of attribute plugin_name.



15
16
17
# File 'lib/gonative/plugins/android/create.rb', line 15

def plugin_name
  @plugin_name
end

Instance Method Details

#assert_not_exists!Object

Raises:



28
29
30
31
32
# File 'lib/gonative/plugins/android/create.rb', line 28

def assert_not_exists!
  return unless File.directory?(plugin_name)

  raise Error, "Directory #{plugin_name} already exists"
end

#callObject



21
22
23
24
25
26
# File 'lib/gonative/plugins/android/create.rb', line 21

def call
  assert_not_exists!
  set_working_dir!
  cp_template_files!
  Utils::TemplateInflator.new(plugin_name: capitalized_plugin_name, java_package: java_package).call
end

#capitalized_plugin_nameObject



44
45
46
# File 'lib/gonative/plugins/android/create.rb', line 44

def capitalized_plugin_name
  [plugin_name, 'plugin'].join('_').camelize
end

#cp_template_files!Object



39
40
41
42
# File 'lib/gonative/plugins/android/create.rb', line 39

def cp_template_files!
  FileUtils.cp_r("#{TEMPLATE_DIRECTORY_PATH}/.", '.')
  system('ditto', TEMPLATE_DIRECTORY_PATH, '.')
end

#java_packageObject



48
49
50
# File 'lib/gonative/plugins/android/create.rb', line 48

def java_package
  plugin_name
end

#set_working_dir!Object



34
35
36
37
# File 'lib/gonative/plugins/android/create.rb', line 34

def set_working_dir!
  FileUtils.mkdir(plugin_name)
  FileUtils.cd(plugin_name)
end