Sha256: e34d6a317e2d5739c8e953122fa4eb465e34ae37a2b53806ab09eec500b2bef1

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 KB

Contents

require "thor"

module Grnplum
  module Generator
    class C < Thor::Group
      include Thor::Actions

      argument :name

      def self.source_root
        File.join(File.dirname(__FILE__), "templates", "c")
      end

      def create_files
        git_user_name = `git config user.name`.chomp
        git_user_email = `git config user.email`.chomp
        config = {
          plugin_name: name,
          author: (git_user_name || "TODO: YOUR NAME"),
          email: (git_user_email || "TODO: YOUR EMAIL"),
        }
        [
          ".gitignore",
          "LICENSE",
          "Makefile.am.tt",
          "README.md.tt",
          "autogen.sh",
          "configure.ac.tt",
          "plugin_name/Makefile.am.tt",
          "plugin_name/plugin_name.c.tt",
          "plugin_name/sources.am.tt",
          "test/Makefile.am",
          "test/run-test.sh",
          "test/suite/register.expected.tt",
          "test/suite/register.test.tt",
        ].each do |path|
          output_path = path.gsub(/plugin_name/, config[:plugin_name])
          output_path = output_path.gsub(/\.tt\z/, "")
          template(path, "groonga-plugin-#{name}/#{output_path}", config)
          if /\.sh\z/ =~ output_path
            File.chmod(0755, "groonga-plugin-#{name}/#{output_path}")
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
grnplum-0.1.0 lib/grnplum/generator/c.rb