Method: IOS::ProjectManipulator#createModuleDummies

Defined in:
lib/ios/module/setup/ProjectManipulator.rb

#createModuleDummiesObject


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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# File 'lib/ios/module/setup/ProjectManipulator.rb', line 145

def createModuleDummies
    @configurator.printMessage("Gerando arquivos de exemplo")

    if @module_type == :feature
        FileUtils.touch File.join(@module_path, "Sources", "Features", "Dummy.swift")
    else
        FileUtils.touch File.join(@module_path, "Sources", "DummySource.swift")
    end

    # Header.h
    headerFilename = File.join(@module_path, "Resources", @configurator.pod_name + ".h")
    FileUtils.cp(
        File.join(@configurator.template_path, "Feature", "Header_template"),
        headerFilename
    )
    text = File.read(headerFilename)
    text.gsub!("${POD_NAME}", @configurator.pod_name)
    File.open(headerFilename, "w") { |file| file.puts text}

    # Info.plist
    FileUtils.cp(
        File.join(@configurator.template_path, "Feature", "Info_template"),
        File.join(@module_path, "Resources", "Info.plist")
    )

    if @has_swiftgen == :yes
        # Bundle
        bundleFilename = File.join(@module_path, "Sources", "ModuleConfiguration", "Bundle.swift")
        FileUtils.cp(
            File.join(@configurator.template_path, "Feature", "bundle_template"),
            bundleFilename
        )

        text = File.read(bundleFilename)
        text.gsub!("${POD_NAME}", @configurator.pod_name)
        File.open(bundleFilename, "w") { |file| file.puts text}

        # Strings
        FileUtils.touch File.join(@module_path, "Resources", "Localizable.strings")
        File.open(File.join(@module_path, "Resources", "Localizable.strings"), "w") { |file|
            file.puts "\"example.title.text\" = \"EXAMPLE\";"
        }

        # Assets
        FileUtils.mkdir_p(File.join(@module_path, "Resources", "Assets.xcassets"))
    end

    @configurator.printDone
end