diff --git a/README.rdoc b/README.rdoc index 2dd4b31..95fec99 100644 --- a/README.rdoc +++ b/README.rdoc @@ -41,6 +41,7 @@ Runtime Options: -s, [--sudo] # Use sudo for the gem install commands (for non rvm/osx users) -u, [--url] # Rool url for your app in development -C, [--cucumber] # Include cucumber tests, currently does not support oauth + -j, [--jslibrary] # write out javascript partials using the jquery or prototype. will default to prototype if Rails.version < 3.1.x Devise Options (used with the -c command) diff --git a/devisable.gemspec b/devisable.gemspec index 719109c..6010cb4 100644 --- a/devisable.gemspec +++ b/devisable.gemspec @@ -5,7 +5,7 @@ Gem::Specification.new do |s| s.name = %q{devisable} - s.version = "0.1.3" + s.version = "0.2.0" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Scott Sampson", "Jeremiah Hemphill"] diff --git a/lib/generators/devisable/devisable_generator.rb b/lib/generators/devisable/devisable_generator.rb index 653497f..0fabe3e 100644 --- a/lib/generators/devisable/devisable_generator.rb +++ b/lib/generators/devisable/devisable_generator.rb @@ -93,11 +93,11 @@ def initialize(*runtime_args) @@actual_configuration_options['cucumber'] = true end opts.on("-j", "--jslibrary (jquery|prototype)", String, "write out using the jquery or prototype libraries") do |j| - if j =~ /jquery/i - @@actual_configuration_options['jslibrary'] = 'jquery' - elsif j =~ /prototype/i - @@actual_configuration_options['jslibrary'] = 'prototype' - end + # otherwise use command lines options + lib = 'jquery' if j =~ /jquery/i + lib = 'prototype' if j =~ /prototype/i + + @@actual_configuration_options['jslibrary'] = lib end end.parse! execute @@ -408,6 +408,13 @@ def new_project #adds the javascript for the role permissions checkboxes def add_javascript + # if no jslibrary has been selected yet + if @@actual_configuration_options['jslibrary'] == '' + # if the version is >= 3.1.0, then jquery is the default. otherwise, prototype + version = Rails.version.split('.').collect{|t|t.to_i} + @@actual_configuration_options['jslibrary'] = (version[0] >= 3 && version[1] >= 1) ? 'jquery' : 'prototype' + end + rep_str = load_erb_string('partials/_permission_manage_' + @@actual_configuration_options['jslibrary'] + '.js') append_to_file "public/javascripts/application.js", rep_str end