Sha256: bd7b29a472fb2505e4d78df94a478c1ec80f01e088b07dc699727062aca24f3d

Contents?: true

Size: 587 Bytes

Versions: 4

Compression:

Stored size: 587 Bytes

Contents

module Vue
  class ComponentGenerator < Rails::Generators::NamedBase
    source_root File.expand_path('../templates', __FILE__)


    def generate_component
      template 'Component.template', Rails.root.join("app", "javascript", "components", *path, "#{component_name}.vue")
    end

    private
    def component_name
      file = name.split("/").last
      if file.downcase.ends_with?(".js") || file.downcase.ends_with?(".vue")
        file = file.split(".")[0]
      end
      file
    end

    def path
      parts = name.split("/")
      parts.pop

      parts
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
vue-generators-0.1.3 lib/vue/generators/vue/component/component_generator.rb
vue-generators-0.1.2 lib/vue/generators/vue/component/component_generator.rb
vue-generators-0.1.1 lib/vue/generators/vue/component/component_generator.rb
vue-generators-0.1.0 lib/vue/generators/vue/component/component_generator.rb