Sha256: 922ccf3248cefa6a7260b47df28d2b49ff69193bff8c339c63e0fd992fbea93f

Contents?: true

Size: 1.1 KB

Versions: 3

Compression:

Stored size: 1.1 KB

Contents

# -*- encoding : utf-8 -*-

require "generators/card"

class Card
  module Generators
    class SetGenerator < NamedBase
      source_root File.expand_path("templates", __dir__)

      argument :set_pattern, required: true
      argument :anchors, required: true, type: :array
      class_option "core", type: :boolean, aliases: "-c",
                           default: false, group: :runtime,
                           desc: "create set files in Card gem"

      class_option "spec-only", type: :boolean,
                                default: false, group: :runtime,
                                desc: "create only spec file"

      def create_files
        template "set_template.erb", set_path unless options["spec-only"]
        template "set_spec_template.erb", set_path("spec")
      end

      private

      def set_path modifier=nil
        suffix = modifier ? "_#{modifier}" : nil
        filename = "#{anchors.last}#{suffix}.rb"
        dirs = anchors[0..-2]
        path_parts = [mod_path, modifier, "set", set_pattern, dirs, filename]
        File.join(*path_parts.compact)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
card-1.101.7 lib/generators/card/set/set_generator.rb
card-1.101.6 lib/generators/card/set/set_generator.rb
card-1.101.5 lib/generators/card/set/set_generator.rb