20
21
22
23
24
25
26
27
28
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
|
# File 'lib/padrino/angularjs/generators/install.rb', line 20
def add_assets
self.destination_root = options[:root]
if in_app_root?
app = options[:app]
check_app_existence(app)
self.behavior = :revoke if options[:destroy]
unless options[:destroy]
require_dependencies('padrino-sprockets', :require => 'padrino/sprockets', :git => 'https://github.com/nightsailer/padrino-sprockets.git')
end
javascript_root = destination_root(app, '/assets/javascripts')
javascript_file = File.join(javascript_root, 'application.js')
if File.exist?(javascript_file)
insert_into_file javascript_file, "//= require angular\n", :before => "//= require_tree \.\n"
else
empty_directory javascript_root
template 'templates/application.js.tt', javascript_file
end
angularjs_register = "\n register Padrino::Sprockets\n sprockets :paths => Padrino::Angularjs.assets_path\n ANGULARJS\n\n inject_into_file destination_root(app, 'app.rb'), angularjs_register, :after => \"register Padrino::Helpers\\n\"\n\n return if self.behavior == :revoke\n\n say\n say '='*65, :green\n say 'All set for use the AngularJS! Next, follow these steps:', :green\n say '='*65, :green\n say 'Run \"bundle install\"'\n say '='*65, :green\n say\n\n else\n say 'You are not at the root of a Padrino application! (config/boot.rb not found)'\n end\nend\n"
|