Class: Hajimeru::Generator::GroongaPlugin

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/hajimeru/generator/groonga_plugin.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



10
11
12
# File 'lib/hajimeru/generator/groonga_plugin.rb', line 10

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

Instance Method Details

#create_filesObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/hajimeru/generator/groonga_plugin.rb', line 14

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"),
  }
  [
    "Makefile.am.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, "#{name}/#{output_path}", config)
    if /\.sh\z/ =~ output_path
      File.chmod(0755, "#{name}/#{output_path}")
    end
  end
end