Class: Ruby::App

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#project_optionsObject

Returns the value of attribute project_options.



45
46
47
# File 'lib/ruby_app.rb', line 45

def project_options
  @project_options
end

Class Method Details

.source_rootObject



47
48
49
50
# File 'lib/ruby_app.rb', line 47

def self.source_root
  # template_path(__FILE__)
  File.join(File.dirname(__FILE__), '..', 'templates')      
end

Instance Method Details

#create_rootObject



78
79
80
81
82
# File 'lib/ruby_app.rb', line 78

def create_root 
  self.destination_root = File.expand_path(app_name, destination_root)    
  empty_directory '.'
  FileUtils.cd(destination_root)
end

#default_settingsObject



71
72
73
74
75
76
# File 'lib/ruby_app.rb', line 71

def default_settings
  @project_options ||= options.dup 
  [:rspec2, :cucumber, :license, :autotest, :bundler].each{|key| project_options[key] ||= true}  
  project_options[:mock_lib] ||= 'mocha'           
  project_options[:readme] ||= 'markdown'          
end

#install_gemsObject



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/ruby_app.rb', line 84

def install_gems    
  return nil if !project_options[:install_gems] 
  gems = []
  gems << "heckle" if project_options[:heckle]
  gems << "rcov" if project_options[:rcov]
  gems << "fakefs" if project_options[:fakefs]
  gems << "cucumber" if project_options[:cucumber]      
  gems << "ZenTest autotest-growl autotest-fsevent" if project_options[:autotest]            
  gems << "#{project_options[:mock_lib]}"
  gems << "require-me" if project_options[:require_me]
  gems << "bundler" if project_options[:bundler]      
  gems << "shoulda" if project_options[:shoulda]      
  gems << "test-unit" if project_options[:test_unit]      
  gems << "rake" if project_options[:rake]      
  gems << "jeweler" if project_options[:jeweler]
  gems << "timecop" if project_options[:timecop]                  
  
  gems << "#{project_options[:factory_lib]}"
  run "gem install rspec --pre" if project_options[:rspec]
  run "gem install #{gems.join(' ')}"      
end

#load_local_settingsObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/ruby_app.rb', line 52

def load_local_settings
  local_settings_file = File.join(ENV['HOME'], '.rubyapp')
  if File.exist? local_settings_file
    str = File.open(local_settings_file).read
    arr = str.split(/\n|,|:/).map{|s| s.strip}.map do |n| 
      case n
      when "true"
        true
      when "false" 
        false
      else 
        n
      end
    end
    local_settings = Hash[*arr]        
    @project_options = local_settings.merge(options)
  end
end

#main_runnerObject



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/ruby_app.rb', line 106

def main_runner
  say "rubyapp v.0.1.1"            
  if project_options[:jeweler]
    run "jeweler #{appname}" 
  else
    create_app
  end
  create_gemfile if !skip? :bundler, 'Use Bundler?'
  create_binaries if !skip? :binaries, 'Create binaries?'
  configure_cucumber if !skip? :cucumber, 'Use Cucumber?'
  configure_rspec2 if project_options[:rspec2]
  configure_autotest if !skip? :autotest, 'Use autotest?'
  configure_shoulda if project_options[:shoulda]  
  configure_test_unit if project_options[:test_unit]
  create_gitignore
  create_readme
  create_signatures if project_options[:signatures] 
  copy_licence if !skip? :license, 'Use MIT license?'
  autotest_feature_notice if project_options[:cucumber]       
end