Sha256: 5003f88807365ee8a4b51d6aa43dee2bbdc880f0ce2a9f0234d6eedafd990013

Contents?: true

Size: 1.05 KB

Versions: 19

Compression:

Stored size: 1.05 KB

Contents

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

module Cardio
  module Generators
    # generate set module files
    class SetGenerator < ModBase
      source_root File.expand_path("templates", __dir__)

      argument :set_pattern, required: true
      argument :anchors, required: true, type: :array

      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

      def module_class_string
        "Card::Set::#{set_pattern.camelize}::#{anchors.map(&:camelize).join '::'}"
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
card-1.107.0 lib/generators/set/set_generator.rb
card-1.106.0 lib/generators/set/set_generator.rb
card-1.105.6 lib/generators/set/set_generator.rb
card-1.105.5 lib/generators/set/set_generator.rb
card-1.105.4 lib/generators/set/set_generator.rb
card-1.105.3 lib/generators/set/set_generator.rb
card-1.105.2.pre1 lib/generators/set/set_generator.rb
card-1.105.2 lib/generators/set/set_generator.rb
card-1.105.1 lib/generators/set/set_generator.rb
card-1.105.0 lib/generators/set/set_generator.rb
card-1.104.2 lib/generators/set/set_generator.rb
card-1.104.1 lib/generators/set/set_generator.rb
card-1.104.0 lib/generators/set/set_generator.rb
card-1.103.4 lib/generators/set/set_generator.rb
card-1.103.3 lib/generators/set/set_generator.rb
card-1.103.2 lib/generators/set/set_generator.rb
card-1.103.1 lib/generators/set/set_generator.rb
card-1.103.0 lib/generators/set/set_generator.rb
card-1.102.0 lib/generators/set/set_generator.rb