Class: GoNative::Plugins::Android::Create
- Inherits:
-
Object
- Object
- GoNative::Plugins::Android::Create
- Extended by:
- DSL::Serviceable
- Defined in:
- lib/gonative/plugins/android/create.rb
Constant Summary collapse
- TEMPLATE_DIRECTORY_PATH =
File.(File.join(__dir__, '../../../..', 'templates', 'plugins', 'android'))
Instance Attribute Summary collapse
-
#plugin_name ⇒ Object
readonly
Returns the value of attribute plugin_name.
Instance Method Summary collapse
- #assert_not_exists! ⇒ Object
- #call ⇒ Object
- #capitalized_plugin_name ⇒ Object
- #cp_template_files! ⇒ Object
-
#initialize(plugin_name) ⇒ Create
constructor
A new instance of Create.
- #java_package ⇒ Object
- #set_working_dir! ⇒ Object
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_name ⇒ Object (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
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 |
#call ⇒ Object
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_name ⇒ Object
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_package ⇒ Object
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 |