Class: Codenize::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/codenize/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



2
3
4
5
# File 'lib/codenize/client.rb', line 2

def initialize(options = {})
  @options = options
  @logger = Codenize::Logger.instance
end

Instance Method Details

#generateObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/codenize/client.rb', line 7

def generate
  FileUtils.chdir(@options[:dir]) do
    name = @options[:name]

    if File.exist?(name)
      raise "directory already exists: #{name}"
    end

    Bundler.with_clean_env do
      sh 'bundle', 'gem', name or raise 'bundle gem faild'
    end

    FileUtils.chdir(name) do
      update_files(name)
      create_files(name)
      @logger.info 'Adding generated code to git repo'
      sh 'git', 'add', '.'
    end
  end
end