Sha256: d9b4bd241f52471912609bf610b48b6b6dff1a64f4c5327192ce25faf6ceb382

Contents?: true

Size: 1.71 KB

Versions: 6

Compression:

Stored size: 1.71 KB

Contents

require "thor"

module TurboNativeInitializer
  class Generator < Thor::Group
    include Thor::Actions

    argument :name

    class_option :platform,   type: :string, enum: %w[ios android], required: true
    class_option :navigation, type: :string, enum: %w[stack tabs], default: "stack"
    class_option :package,    type: :string, default: "dev.hotwire.turbo"

    source_root File.expand_path("templates", __dir__)

    def self.exit_on_failure?
      true
    end

    def copy_template_files
      case options.platform
      when "ios"
        directory "#{project}/TurboNativeProject/Configuration", "#{name}/#{name}/Configuration"
        directory "#{project}/TurboNativeProject/Controllers", "#{name}/#{name}/Controllers"
        directory "#{project}/TurboNativeProject/Delegates", "#{name}/#{name}/Delegates"
        directory "#{project}/TurboNativeProject/Resources", "#{name}/#{name}/Resources"
        directory "#{project}/TurboNativeProject/Strada", "#{name}/#{name}/Strada"
        directory "#{project}/TurboNativeProject.xcodeproj", "#{name}/#{name}.xcodeproj"
        template  "#{project}/TurboNativeProject/TurboNativeProject.swift", "#{name}/#{name}/#{name}.swift"
      when "android"
        directory "#{project}/base", "#{name}"
        directory "#{project}/app/src/main/java/dev/hotwire/turbo/turbonativeproject", "#{name}/app/src/main/java/#{package_path}"
      end
    end

    private
      def project
        "#{options[:platform]}_#{options[:navigation]}"
      end

      def package_name
        "#{options[:package]}.#{name.downcase}"
      end

      def package_path
        package_name.split(".").join("/")
      end

      def bundle_identifier
        "#{options[:package]}.#{name}"
      end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
turbo-native-initializer-0.0.16 lib/turbo_native_initializer/generator.rb
turbo-native-initializer-0.0.15 lib/turbo_native_initializer/generator.rb
turbo-native-initializer-0.0.14 lib/turbo_native_initializer/generator.rb
turbo-native-initializer-0.0.13 lib/turbo_native_initializer/generator.rb
turbo-native-initializer-0.0.12 lib/turbo_native_initializer/generator.rb
turbo-native-initializer-0.0.11 lib/turbo_native_initializer/generator.rb