Class: Pawnee::CLI
Instance Attribute Summary
Attributes inherited from Base
#server, #server_options, #setup_with_connection
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Base
Methods included from Base::Roles
Methods included from SshConnection
Methods included from Modified
included, #modified?, #modify_block, #track_modification!
Methods included from Invocation
Methods included from Actions
#add_user_to_group, #compile, #create_user, #delete_user, #insert_into_file, #install_package, #install_packages, #installed_package_version, #package_installed?, #pawnee_setup_actions, #remove_package, #remove_packages, #update_package_list, #user
Constructor Details
This class inherits a constructor from Pawnee::Base
Class Method Details
.source_root ⇒ Object
68 69 70 |
# File 'lib/pawnee/pawnee/cli.rb', line 68 def self.source_root File.(File.join(File.dirname(__FILE__), 'templates')) end |
Instance Method Details
#gem(name) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/pawnee/pawnee/cli.rb', line 29 def gem(name) # Prefix all gems with pawnee- dir_name = 'pawnee-' + name.chomp("/") # remove trailing slash if present folder_name = "pawnee/" + name target = File.join(Dir.pwd, dir_name) constant_name = "Pawnee::" + name.split('-').map{|q| q[0..0].upcase + q[1..-1] }.join('') puts constant_name constant_array = constant_name.split('::') puts constant_array.inspect git_user_name = `git config user.name`.chomp git_user_email = `git config user.email`.chomp opts = { # Don't require the pawnee- when requring though :name => name, :constant_name => constant_name, :constant_array => constant_array, :author => git_user_name.empty? ? "TODO: Write your name" : git_user_name, :email => git_user_email.empty? ? "TODO: Write your email address" : git_user_email } template(File.join("newgem/Gemfile.tt"), File.join(target, "Gemfile"), opts) template(File.join("newgem/Rakefile.tt"), File.join(target, "Rakefile"), opts) template(File.join("newgem/LICENSE.tt"), File.join(target, "LICENSE"), opts) template(File.join("newgem/README.md.tt"), File.join(target, "README.md"), opts) template(File.join("newgem/gitignore.tt"), File.join(target, ".gitignore"), opts) template(File.join("newgem/newgem.gemspec.tt"), File.join(target, "#{dir_name}.gemspec"), opts) template(File.join("newgem/lib/newgem.rb.tt"), File.join(target, "lib/#{dir_name}.rb"), opts) template(File.join("newgem/lib/pawnee/newgem/version.rb.tt"), File.join(target, "lib/#{folder_name}/version.rb"), opts) template(File.join("newgem/lib/pawnee/newgem/base.rb.tt"), File.join(target, "lib/#{folder_name}/base.rb"), opts) template(File.join("newgem/spec/spec_helper.rb.tt"), File.join(target, "spec/spec_helper.rb"), opts) template(File.join("newgem/spec/base_spec.rb.tt"), File.join(target, "spec/base_spec.rb"), opts) template(File.join("newgem/spec/vagrant/Vagrantfile.tt"), File.join(target, "spec/vagrant/Vagrantfile"), opts) template(File.join("newgem/spec/vagrant/vagrant.rb.tt"), File.join(target, "spec/vagrant/vagrant.rb"), opts) if [:bin] template(File.join("newgem/bin/newgem.tt"), File.join(target, 'bin', name), opts) end Bundler.ui.info "Initializating git repo in #{target}" Dir.chdir(target) { `git init`; `git add .` } end |