Class: Atum::Generation::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/atum/generation/cli.rb

Instance Method Summary collapse

Instance Method Details

#generateObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/atum/generation/cli.rb', line 43

def generate
  config = options_from_atum_file.merge(options)
  validate_config(config)

  names = name_versions(config['gem_name'])
  config['constant_name'] ||= names[:constant_name]

  # Preserve the version file
  version_file = File.join('lib', names[:namespaced_path], 'version.rb')
  version_file_content = File.read(version_file)

  # Nuke everything in the lib folder
  FileUtils.rm_rf('lib/*')

  # Regenerate everything in the lib folder
  regenerate_lib_folder(config)

  # Re-write the version file
  File.open(version_file, 'w') { |f| f.write(version_file_content) }

  # Print advice
  print_closing_message
end

#new(client_name) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/atum/generation/cli.rb', line 10

def new(client_name)
  # Generate a basic gem
  run_command("bundle gem #{client_name}")

  # Add atum to the gemspec file
  run_command("sed -i '$ d' #{client_name}/#{client_name}.gemspec")
  run_command("echo '\n  spec.add_runtime_dependency \"atum\", " \
              "\"~> #{Atum::VERSION}\"' >> " \
              "#{client_name}/#{client_name}.gemspec")
  run_command("echo 'end' >> #{client_name}/#{client_name}.gemspec")

  # Populate a .atum file in the root
  Dir.chdir(client_name) do
    File.open('.atum.yml', 'w') do |f|
      names = name_versions(client_name)
      f.puts "gem_name: #{client_name}"
      f.puts "constant_name: #{names[:constant_name]}"
    end
  end
end

#versionObject



68
69
70
# File 'lib/atum/generation/cli.rb', line 68

def version
  print Atum::VERSION, "\n"
end