From 51bc408ee49203062e07380ca7075d276ae8211d Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 18 Aug 2011 17:37:35 -0400 Subject: [PATCH 1/2] updated readme, added default jquery/prototype based on Rails.version --- README.rdoc | 1 + devisable.gemspec | 2 +- .../devisable/devisable_generator.rb | 18 +++++++++++++----- 3 files changed, 15 insertions(+), 6 deletions(-) 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..229e548 100644 --- a/lib/generators/devisable/devisable_generator.rb +++ b/lib/generators/devisable/devisable_generator.rb @@ -93,11 +93,12 @@ 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 + puts "############### " + Rails.version + " " + version.inspect + " " + @@actual_configuration_options['jslibrary'] + " ###########" end end.parse! execute @@ -408,6 +409,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 From f5f7f7dd32338e60d57e188cdc933b1d4864b7f3 Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 19 Aug 2011 12:13:53 -0400 Subject: [PATCH 2/2] debugging line causing massive failure --- lib/generators/devisable/devisable_generator.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/generators/devisable/devisable_generator.rb b/lib/generators/devisable/devisable_generator.rb index 229e548..0fabe3e 100644 --- a/lib/generators/devisable/devisable_generator.rb +++ b/lib/generators/devisable/devisable_generator.rb @@ -98,7 +98,6 @@ def initialize(*runtime_args) lib = 'prototype' if j =~ /prototype/i @@actual_configuration_options['jslibrary'] = lib - puts "############### " + Rails.version + " " + version.inspect + " " + @@actual_configuration_options['jslibrary'] + " ###########" end end.parse! execute