Class: GoNative::Plugins::IOS::Create
- Inherits:
-
Object
- Object
- GoNative::Plugins::IOS::Create
- Extended by:
- DSL::Serviceable
- Defined in:
- lib/gonative/plugins/ios/create.rb
Constant Summary collapse
- TEMPLATE_DIRECTORY_PATH =
File.(File.join(__dir__, '../../../..', 'templates', 'plugins', 'ios'))
- COMMON_TEMPLATES_PATH =
File.join(TEMPLATE_DIRECTORY_PATH, 'common')
- LANGUAGES =
%w[objc swift].freeze
Instance Attribute Summary collapse
-
#language ⇒ Object
readonly
Returns the value of attribute language.
-
#plugin_name ⇒ Object
readonly
Returns the value of attribute plugin_name.
Instance Method Summary collapse
- #assert_not_exists! ⇒ Object
- #call ⇒ Object
- #cp_template_files! ⇒ Object
-
#initialize(plugin_name, language) ⇒ Create
constructor
A new instance of Create.
- #repo_name ⇒ Object
- #set_working_dir! ⇒ Object
Constructor Details
#initialize(plugin_name, language) ⇒ Create
Returns a new instance of Create.
20 21 22 23 |
# File 'lib/gonative/plugins/ios/create.rb', line 20 def initialize(plugin_name, language) @plugin_name = plugin_name @language = language end |
Instance Attribute Details
#language ⇒ Object (readonly)
Returns the value of attribute language.
18 19 20 |
# File 'lib/gonative/plugins/ios/create.rb', line 18 def language @language end |
#plugin_name ⇒ Object (readonly)
Returns the value of attribute plugin_name.
18 19 20 |
# File 'lib/gonative/plugins/ios/create.rb', line 18 def plugin_name @plugin_name end |
Instance Method Details
#assert_not_exists! ⇒ Object
32 33 34 35 36 |
# File 'lib/gonative/plugins/ios/create.rb', line 32 def assert_not_exists! return unless File.directory?(plugin_name) raise Error, "Directory #{plugin_name} already exists" end |
#call ⇒ Object
25 26 27 28 29 30 |
# File 'lib/gonative/plugins/ios/create.rb', line 25 def call assert_not_exists! set_working_dir! cp_template_files! Utils::TemplateInflator.new(plugin_name: plugin_name, repo_name: repo_name).call end |
#cp_template_files! ⇒ Object
43 44 45 46 |
# File 'lib/gonative/plugins/ios/create.rb', line 43 def cp_template_files! FileUtils.cp_r("#{COMMON_TEMPLATES_PATH}/.", '.') system('ditto', File.join(TEMPLATE_DIRECTORY_PATH, 'language-specific', language), '.') end |
#repo_name ⇒ Object
48 49 50 |
# File 'lib/gonative/plugins/ios/create.rb', line 48 def repo_name plugin_name.underscore.dasherize.prepend 'ios-' end |
#set_working_dir! ⇒ Object
38 39 40 41 |
# File 'lib/gonative/plugins/ios/create.rb', line 38 def set_working_dir! FileUtils.mkdir(plugin_name) FileUtils.cd(plugin_name) end |