Class: RailsKarma::Installer
- Inherits:
-
Object
- Object
- RailsKarma::Installer
- Defined in:
- lib/rails_karma/tasks.rb
Class Method Summary collapse
- .copy_angularjs_files ⇒ Object
- .copy_angularjs_resource_files ⇒ Object
- .copy_karma_config ⇒ Object
- .copy_test_spec ⇒ Object
- .create_karma_dir ⇒ Object
- .ignore_node_modules ⇒ Object
- .install_karma_lib ⇒ Object
- .make_vendor_dir ⇒ Object
- .rails_resource_dir ⇒ Object
- .vendor_dir ⇒ Object
Class Method Details
.copy_angularjs_files ⇒ Object
77 78 79 80 81 82 83 |
# File 'lib/rails_karma/tasks.rb', line 77 def self.copy_angularjs_files angular_files = ['angular.js', 'angular-cookies.js', 'angular-loader.js', 'angular-resource.js', 'angular-sanitize.js', 'angular-mocks.js'] angular_files.each do |file_name| path = File.join(Gem.loaded_specs['angularjs-rails'].full_gem_path, 'vendor', 'assets', 'javascripts', file_name) FileUtils.cp path, File.join(vendor_dir,File.basename(path)) end end |
.copy_angularjs_resource_files ⇒ Object
85 86 87 88 |
# File 'lib/rails_karma/tasks.rb', line 85 def self.copy_angularjs_resource_files rails_resource_lib = File.join(Gem.loaded_specs['angularjs-rails-resource'].full_gem_path, 'vendor', 'assets', 'javascripts', 'angularjs', 'rails', 'resource') FileUtils.cp_r rails_resource_lib, rails_resource_dir end |
.copy_karma_config ⇒ Object
90 91 92 93 94 95 96 97 |
# File 'lib/rails_karma/tasks.rb', line 90 def self.copy_karma_config config_source = File.join(Gem.loaded_specs['rails_karma'].full_gem_path, 'files', 'karma.conf.js') config_target = File.join(Rails.root, 'config', 'karma.conf.js') unless File.exists?(config_target) puts './config/karma.conf.js' FileUtils.cp_r config_source, config_target end end |
.copy_test_spec ⇒ Object
106 107 108 109 110 111 112 113 |
# File 'lib/rails_karma/tasks.rb', line 106 def self.copy_test_spec test_spec = File.join(Gem.loaded_specs['rails_karma'].full_gem_path, 'files', 'karma_test.coffee') target = File.join(Rails.root, 'karma', 'karma_test.coffee') unless File.exists?(target) puts './karma/karma_test.coffee' FileUtils.cp test_spec, target end end |
.create_karma_dir ⇒ Object
99 100 101 102 103 104 |
# File 'lib/rails_karma/tasks.rb', line 99 def self.create_karma_dir unless Dir.exists?('karma') puts './karma' Dir.mkdir 'karma' end end |
.ignore_node_modules ⇒ Object
51 52 53 54 55 56 |
# File 'lib/rails_karma/tasks.rb', line 51 def self.ignore_node_modules unless File.open('.gitignore') {|f| f.read.include? 'node_modules'} puts 'adding node_modules to .gitignore' File.open('.gitignore', 'a') {|f| f.write "node_modules\n"} end end |
.install_karma_lib ⇒ Object
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/rails_karma/tasks.rb', line 40 def self.install_karma_lib unless File.exists?('package.json') puts './package.json' File.open('package.json', 'w') {|f| f.write '{}'} end unless File.open('package.json') {|f| f.read.include? 'karma'} puts 'installing karma' puts `npm install karma --save-dev` end end |
.make_vendor_dir ⇒ Object
66 67 68 69 70 71 72 73 74 75 |
# File 'lib/rails_karma/tasks.rb', line 66 def self.make_vendor_dir unless Dir.exists?(vendor_dir) puts "mkdir #{vendor_dir}" Dir.mkdir vendor_dir end unless Dir.exists?(rails_resource_dir) puts "mkdir #{rails_resource_dir}" Dir.mkdir rails_resource_dir end end |
.rails_resource_dir ⇒ Object
62 63 64 |
# File 'lib/rails_karma/tasks.rb', line 62 def self.rails_resource_dir File.join(vendor_dir, 'angularjs-rails-resource') end |
.vendor_dir ⇒ Object
58 59 60 |
# File 'lib/rails_karma/tasks.rb', line 58 def self.vendor_dir File.join('vendor', 'assets', 'javascripts', 'rails_karma') end |