challah 0.7.1 → 0.8.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. data/CHANGELOG.md +4 -0
  2. data/lib/challah.rb +5 -0
  3. data/lib/challah/plugins.rb +41 -0
  4. data/lib/challah/railtie.rb +14 -0
  5. data/lib/challah/user.rb +17 -0
  6. data/lib/challah/version.rb +1 -1
  7. data/test/plugins_test.rb +65 -0
  8. data/vendor/bundle/bin/convert_to_should_syntax +7 -3
  9. data/vendor/bundle/bin/erubis +7 -3
  10. data/vendor/bundle/bin/rackup +7 -3
  11. data/vendor/bundle/bin/rails +7 -3
  12. data/vendor/bundle/bin/rake +7 -3
  13. data/vendor/bundle/bin/rake2thor +7 -3
  14. data/vendor/bundle/bin/rdiscount +7 -3
  15. data/vendor/bundle/bin/rdoc +7 -3
  16. data/vendor/bundle/bin/ri +7 -3
  17. data/vendor/bundle/bin/thor +7 -3
  18. data/vendor/bundle/bin/tilt +7 -3
  19. data/vendor/bundle/bin/tt +7 -3
  20. data/vendor/bundle/bin/yard +7 -3
  21. data/vendor/bundle/bin/yardoc +7 -3
  22. data/vendor/bundle/bin/yri +7 -3
  23. data/vendor/bundle/gems/bcrypt-ruby-3.0.1/ext/mri/Makefile +49 -23
  24. data/vendor/bundle/gems/bcrypt-ruby-3.0.1/ext/mri/bcrypt_ext.bundle +0 -0
  25. data/vendor/bundle/gems/bcrypt-ruby-3.0.1/ext/mri/bcrypt_ext.o +0 -0
  26. data/vendor/bundle/gems/bcrypt-ruby-3.0.1/ext/mri/crypt.o +0 -0
  27. data/vendor/bundle/gems/bcrypt-ruby-3.0.1/ext/mri/crypt_blowfish.o +0 -0
  28. data/vendor/bundle/gems/bcrypt-ruby-3.0.1/ext/mri/crypt_gensalt.o +0 -0
  29. data/vendor/bundle/gems/bcrypt-ruby-3.0.1/ext/mri/wrapper.o +0 -0
  30. data/vendor/bundle/gems/bcrypt-ruby-3.0.1/lib/bcrypt_ext.bundle +0 -0
  31. data/vendor/bundle/gems/json-1.7.4/ext/json/ext/generator/Makefile +49 -23
  32. data/vendor/bundle/gems/json-1.7.4/ext/json/ext/generator/generator.bundle +0 -0
  33. data/vendor/bundle/gems/json-1.7.4/ext/json/ext/generator/generator.o +0 -0
  34. data/vendor/bundle/gems/json-1.7.4/ext/json/ext/parser/Makefile +49 -23
  35. data/vendor/bundle/gems/json-1.7.4/ext/json/ext/parser/parser.bundle +0 -0
  36. data/vendor/bundle/gems/json-1.7.4/ext/json/ext/parser/parser.o +0 -0
  37. data/vendor/bundle/gems/json-1.7.4/lib/json/ext/generator.bundle +0 -0
  38. data/vendor/bundle/gems/json-1.7.4/lib/json/ext/parser.bundle +0 -0
  39. data/vendor/bundle/gems/rdiscount-1.6.8/ext/Csio.o +0 -0
  40. data/vendor/bundle/gems/rdiscount-1.6.8/ext/Makefile +49 -23
  41. data/vendor/bundle/gems/rdiscount-1.6.8/ext/basename.o +0 -0
  42. data/vendor/bundle/gems/rdiscount-1.6.8/ext/css.o +0 -0
  43. data/vendor/bundle/gems/rdiscount-1.6.8/ext/docheader.o +0 -0
  44. data/vendor/bundle/gems/rdiscount-1.6.8/ext/dumptree.o +0 -0
  45. data/vendor/bundle/gems/rdiscount-1.6.8/ext/emmatch.o +0 -0
  46. data/vendor/bundle/gems/rdiscount-1.6.8/ext/generate.o +0 -0
  47. data/vendor/bundle/gems/rdiscount-1.6.8/ext/html5.o +0 -0
  48. data/vendor/bundle/gems/rdiscount-1.6.8/ext/markdown.o +0 -0
  49. data/vendor/bundle/gems/rdiscount-1.6.8/ext/mkdio.o +0 -0
  50. data/vendor/bundle/gems/rdiscount-1.6.8/ext/mkmf.log +5 -5
  51. data/vendor/bundle/gems/rdiscount-1.6.8/ext/rdiscount.bundle +0 -0
  52. data/vendor/bundle/gems/rdiscount-1.6.8/ext/rdiscount.o +0 -0
  53. data/vendor/bundle/gems/rdiscount-1.6.8/ext/resource.o +0 -0
  54. data/vendor/bundle/gems/rdiscount-1.6.8/ext/tags.o +0 -0
  55. data/vendor/bundle/gems/rdiscount-1.6.8/ext/toc.o +0 -0
  56. data/vendor/bundle/gems/rdiscount-1.6.8/ext/xml.o +0 -0
  57. data/vendor/bundle/gems/rdiscount-1.6.8/lib/rdiscount.bundle +0 -0
  58. data/vendor/bundle/gems/sqlite3-1.3.6/ext/sqlite3/Makefile +49 -23
  59. data/vendor/bundle/gems/sqlite3-1.3.6/ext/sqlite3/backup.o +0 -0
  60. data/vendor/bundle/gems/sqlite3-1.3.6/ext/sqlite3/database.o +0 -0
  61. data/vendor/bundle/gems/sqlite3-1.3.6/ext/sqlite3/exception.o +0 -0
  62. data/vendor/bundle/gems/sqlite3-1.3.6/ext/sqlite3/mkmf.log +91 -59
  63. data/vendor/bundle/gems/sqlite3-1.3.6/ext/sqlite3/sqlite3.o +0 -0
  64. data/vendor/bundle/gems/sqlite3-1.3.6/ext/sqlite3/sqlite3_native.bundle +0 -0
  65. data/vendor/bundle/gems/sqlite3-1.3.6/ext/sqlite3/statement.o +0 -0
  66. data/vendor/bundle/gems/sqlite3-1.3.6/lib/sqlite3/sqlite3_native.bundle +0 -0
  67. data/vendor/bundle/specifications/actionmailer-3.2.7.gemspec +1 -1
  68. data/vendor/bundle/specifications/actionpack-3.2.7.gemspec +1 -1
  69. data/vendor/bundle/specifications/activemodel-3.2.7.gemspec +1 -1
  70. data/vendor/bundle/specifications/activerecord-3.2.7.gemspec +1 -1
  71. data/vendor/bundle/specifications/activeresource-3.2.7.gemspec +1 -1
  72. data/vendor/bundle/specifications/activesupport-3.2.7.gemspec +1 -1
  73. data/vendor/bundle/specifications/arel-3.0.2.gemspec +1 -1
  74. data/vendor/bundle/specifications/bcrypt-ruby-3.0.1.gemspec +1 -1
  75. data/vendor/bundle/specifications/builder-3.0.0.gemspec +1 -1
  76. data/vendor/bundle/specifications/erubis-2.7.0.gemspec +1 -1
  77. data/vendor/bundle/specifications/factory_girl-3.6.1.gemspec +1 -1
  78. data/vendor/bundle/specifications/highline-1.6.13.gemspec +1 -1
  79. data/vendor/bundle/specifications/hike-1.2.1.gemspec +1 -1
  80. data/vendor/bundle/specifications/i18n-0.6.0.gemspec +1 -1
  81. data/vendor/bundle/specifications/journey-1.0.4.gemspec +1 -1
  82. data/vendor/bundle/specifications/json-1.7.4.gemspec +1 -1
  83. data/vendor/bundle/specifications/mail-2.4.4.gemspec +1 -1
  84. data/vendor/bundle/specifications/metaclass-0.0.1.gemspec +1 -1
  85. data/vendor/bundle/specifications/mime-types-1.19.gemspec +1 -1
  86. data/vendor/bundle/specifications/mocha-0.12.2.gemspec +1 -1
  87. data/vendor/bundle/specifications/multi_json-1.3.6.gemspec +1 -1
  88. data/vendor/bundle/specifications/polyglot-0.3.3.gemspec +1 -1
  89. data/vendor/bundle/specifications/rack-1.4.1.gemspec +1 -1
  90. data/vendor/bundle/specifications/rack-cache-1.2.gemspec +1 -1
  91. data/vendor/bundle/specifications/rack-ssl-1.3.2.gemspec +1 -1
  92. data/vendor/bundle/specifications/rack-test-0.6.1.gemspec +1 -1
  93. data/vendor/bundle/specifications/rails-3.2.7.gemspec +1 -1
  94. data/vendor/bundle/specifications/railties-3.2.7.gemspec +1 -1
  95. data/vendor/bundle/specifications/rake-0.9.2.2.gemspec +1 -1
  96. data/vendor/bundle/specifications/rdiscount-1.6.8.gemspec +1 -1
  97. data/vendor/bundle/specifications/rdoc-3.12.gemspec +1 -1
  98. data/vendor/bundle/specifications/shoulda-3.1.1.gemspec +1 -1
  99. data/vendor/bundle/specifications/shoulda-context-1.0.0.gemspec +1 -1
  100. data/vendor/bundle/specifications/shoulda-matchers-1.2.0.gemspec +1 -1
  101. data/vendor/bundle/specifications/simplecov-0.6.4.gemspec +1 -1
  102. data/vendor/bundle/specifications/simplecov-html-0.5.3.gemspec +1 -1
  103. data/vendor/bundle/specifications/sprockets-2.1.3.gemspec +1 -1
  104. data/vendor/bundle/specifications/sqlite3-1.3.6.gemspec +1 -1
  105. data/vendor/bundle/specifications/thor-0.15.4.gemspec +1 -1
  106. data/vendor/bundle/specifications/tilt-1.3.3.gemspec +1 -1
  107. data/vendor/bundle/specifications/treetop-1.4.10.gemspec +1 -1
  108. data/vendor/bundle/specifications/tzinfo-0.3.33.gemspec +1 -1
  109. data/vendor/bundle/specifications/yard-0.8.2.1.gemspec +1 -1
  110. metadata +7 -5
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## Challah 0.8.0 (Unreleased)
2
+
3
+ * Enabled plugin abilties through `Challah.register_plugin`. This restores the ability to use permissions and roles through the [challah-rolls gem](https://github.com/jdtornow/challah-rolls).
4
+
1
5
  ## Challah 0.7.1
2
6
 
3
7
  * Ensure users can be looked up by username as case insensitive value. Allows logins posted from iOS devices (with initial caps) to be valid usernames even when stored as caps.
data/lib/challah.rb CHANGED
@@ -8,6 +8,8 @@ module Challah
8
8
 
9
9
  autoload :Controller, 'challah/controller'
10
10
  autoload :Encrypter, 'challah/encrypter'
11
+ autoload :Techniques, 'challah/techniques'
12
+ autoload :Plugins, 'challah/plugins'
11
13
  autoload :Random, 'challah/random'
12
14
  autoload :Session, 'challah/session'
13
15
  autoload :Techniques, 'challah/techniques'
@@ -41,6 +43,9 @@ module Challah
41
43
  # Default registered authentication techiques.
42
44
  register_technique :api_key, ApiKeyTechnique
43
45
  register_technique :password, PasswordTechnique
46
+
47
+ extend Plugins
48
+ @plugins ||= {}
44
49
  end
45
50
 
46
51
  require 'challah/railtie' if defined?(Rails)
@@ -0,0 +1,41 @@
1
+ module Challah
2
+ # Plugins are used to extend the functionality of Challah.
3
+ module Plugins
4
+ # A simple DSL for registering a plugin
5
+ class Plugin
6
+ attr_reader :active_record, :action_controller, :user_extensions, :user_init_methods
7
+
8
+ def initialize
9
+ @active_record ||= []
10
+ @action_controller ||= []
11
+ @user_extensions ||= []
12
+ @user_init_methods ||= []
13
+ end
14
+
15
+ # When active_record or action_controller is loaded, run the given block
16
+ def on_load(framework, &block)
17
+ return unless [ :active_record, :action_controller ].include?(framework)
18
+ instance_variable_get("@#{framework}") << block
19
+ end
20
+
21
+ # Pass a module name to include it in the base User model after challah_user
22
+ # is run
23
+ def extend_user(module_name, init_method = nil)
24
+ @user_extensions << module_name
25
+ @user_init_methods << init_method unless init_method.nil?
26
+ end
27
+ end
28
+
29
+ # Register a new plugin.
30
+ def register_plugin(name, &block)
31
+ plugin = Plugin.new
32
+ plugin.instance_eval(&block)
33
+ @plugins[name] = plugin
34
+ end
35
+
36
+ # Get the list of all plugins
37
+ def plugins
38
+ @plugins
39
+ end
40
+ end
41
+ end
@@ -30,6 +30,13 @@ module Challah
30
30
  :logged_in?,
31
31
  :signed_in?
32
32
  )
33
+
34
+ # Load any ActionController/Challah plugins
35
+ Challah.plugins.values.each do |plugin|
36
+ plugin.action_controller.each do |proc|
37
+ proc.call
38
+ end
39
+ end
33
40
  end
34
41
  end
35
42
 
@@ -40,6 +47,13 @@ module Challah
40
47
 
41
48
  ActiveRecord::Base.send(:extend, Challah::User)
42
49
  ActiveRecord::Base.send(:include, Challah::Audit)
50
+
51
+ # Load any ActiveRecord/Challah plugins
52
+ Challah.plugins.values.each do |plugin|
53
+ plugin.active_record.each do |proc|
54
+ proc.call
55
+ end
56
+ end
43
57
  end
44
58
  end
45
59
  end
data/lib/challah/user.rb CHANGED
@@ -1,4 +1,19 @@
1
1
  module Challah
2
+ class << self
3
+ # Loop through all registered plugins and extend User functionality.
4
+ def include_user_plugins!
5
+ Challah.plugins.values.each do |plugin|
6
+ plugin.user_extensions.each do |mod|
7
+ ::User.send(:extend, mod)
8
+ end
9
+
10
+ plugin.user_init_methods.each do |method_name|
11
+ ::User.send(method_name)
12
+ end
13
+ end
14
+ end
15
+ end
16
+
2
17
  module User
3
18
  def challah_user
4
19
  unless included_modules.include?(InstanceMethods)
@@ -59,6 +74,8 @@ module Challah
59
74
  :session_count,
60
75
  :updated_by
61
76
  end
77
+
78
+ Challah.include_user_plugins!
62
79
  end
63
80
 
64
81
  module ClassMethods
@@ -1,3 +1,3 @@
1
1
  module Challah
2
- VERSION = "0.7.1" unless defined?(::Challah::VERSION)
2
+ VERSION = "0.8.0.pre" unless defined?(::Challah::VERSION)
3
3
  end
@@ -0,0 +1,65 @@
1
+ require 'helper'
2
+
3
+ class TestPlugins < ActiveSupport::TestCase
4
+ include Challah
5
+
6
+ class PluginContext
7
+ def self.setup_active_record
8
+ end
9
+
10
+ def self.setup_controllers
11
+ end
12
+ end
13
+
14
+ module UserStuff
15
+ def set_me_up
16
+ include AndMore
17
+ end
18
+
19
+ module AndMore
20
+ def hey_baller
21
+ "whatsup"
22
+ end
23
+ end
24
+ end
25
+
26
+ context "The plugin loader" do
27
+ should "be able to load a plugin and any dependencies" do
28
+ assert_equal false, Challah.plugins.has_key?(:tester)
29
+
30
+ Challah.register_plugin :tester do
31
+ on_load :active_record do
32
+ PluginContext.setup_active_record
33
+ end
34
+
35
+ on_load :action_controller do
36
+ PluginContext.setup_controllers
37
+ end
38
+ end
39
+
40
+ assert_equal true, Challah.plugins.has_key?(:tester)
41
+ assert_equal 1, Challah.plugins[:tester].active_record.size
42
+ assert_equal 1, Challah.plugins[:tester].action_controller.size
43
+
44
+ PluginContext.expects(:setup_active_record).once
45
+ PluginContext.expects(:setup_controllers).once
46
+
47
+ Challah::Engine.setup_active_record!
48
+ Challah::Engine.setup_action_controller!
49
+ end
50
+
51
+ should "be able to include a module when loading Challah::User" do
52
+ assert_equal false, ::User.included_modules.include?(UserStuff::AndMore)
53
+
54
+ Challah.register_plugin :user_mods do
55
+ extend_user UserStuff, :set_me_up
56
+ end
57
+
58
+ Challah.include_user_plugins!
59
+
60
+ assert_equal true, ::User.included_modules.include?(UserStuff::AndMore)
61
+
62
+ assert_equal "whatsup", ::User.new().hey_baller
63
+ end
64
+ end
65
+ end
@@ -10,9 +10,13 @@ require 'rubygems'
10
10
 
11
11
  version = ">= 0"
12
12
 
13
- if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
14
- version = $1
15
- ARGV.shift
13
+ if ARGV.first
14
+ str = ARGV.first
15
+ str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
16
+ if str =~ /\A_(.*)_\z/
17
+ version = $1
18
+ ARGV.shift
19
+ end
16
20
  end
17
21
 
18
22
  gem 'shoulda-context', version
@@ -10,9 +10,13 @@ require 'rubygems'
10
10
 
11
11
  version = ">= 0"
12
12
 
13
- if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
14
- version = $1
15
- ARGV.shift
13
+ if ARGV.first
14
+ str = ARGV.first
15
+ str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
16
+ if str =~ /\A_(.*)_\z/
17
+ version = $1
18
+ ARGV.shift
19
+ end
16
20
  end
17
21
 
18
22
  gem 'erubis', version
@@ -10,9 +10,13 @@ require 'rubygems'
10
10
 
11
11
  version = ">= 0"
12
12
 
13
- if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
14
- version = $1
15
- ARGV.shift
13
+ if ARGV.first
14
+ str = ARGV.first
15
+ str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
16
+ if str =~ /\A_(.*)_\z/
17
+ version = $1
18
+ ARGV.shift
19
+ end
16
20
  end
17
21
 
18
22
  gem 'rack', version
@@ -10,9 +10,13 @@ require 'rubygems'
10
10
 
11
11
  version = ">= 0"
12
12
 
13
- if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
14
- version = $1
15
- ARGV.shift
13
+ if ARGV.first
14
+ str = ARGV.first
15
+ str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
16
+ if str =~ /\A_(.*)_\z/
17
+ version = $1
18
+ ARGV.shift
19
+ end
16
20
  end
17
21
 
18
22
  gem 'railties', version
@@ -10,9 +10,13 @@ require 'rubygems'
10
10
 
11
11
  version = ">= 0"
12
12
 
13
- if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
14
- version = $1
15
- ARGV.shift
13
+ if ARGV.first
14
+ str = ARGV.first
15
+ str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
16
+ if str =~ /\A_(.*)_\z/
17
+ version = $1
18
+ ARGV.shift
19
+ end
16
20
  end
17
21
 
18
22
  gem 'rake', version
@@ -10,9 +10,13 @@ require 'rubygems'
10
10
 
11
11
  version = ">= 0"
12
12
 
13
- if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
14
- version = $1
15
- ARGV.shift
13
+ if ARGV.first
14
+ str = ARGV.first
15
+ str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
16
+ if str =~ /\A_(.*)_\z/
17
+ version = $1
18
+ ARGV.shift
19
+ end
16
20
  end
17
21
 
18
22
  gem 'thor', version
@@ -10,9 +10,13 @@ require 'rubygems'
10
10
 
11
11
  version = ">= 0"
12
12
 
13
- if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
14
- version = $1
15
- ARGV.shift
13
+ if ARGV.first
14
+ str = ARGV.first
15
+ str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
16
+ if str =~ /\A_(.*)_\z/
17
+ version = $1
18
+ ARGV.shift
19
+ end
16
20
  end
17
21
 
18
22
  gem 'rdiscount', version
@@ -10,9 +10,13 @@ require 'rubygems'
10
10
 
11
11
  version = ">= 0"
12
12
 
13
- if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
14
- version = $1
15
- ARGV.shift
13
+ if ARGV.first
14
+ str = ARGV.first
15
+ str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
16
+ if str =~ /\A_(.*)_\z/
17
+ version = $1
18
+ ARGV.shift
19
+ end
16
20
  end
17
21
 
18
22
  gem 'rdoc', version
data/vendor/bundle/bin/ri CHANGED
@@ -10,9 +10,13 @@ require 'rubygems'
10
10
 
11
11
  version = ">= 0"
12
12
 
13
- if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
14
- version = $1
15
- ARGV.shift
13
+ if ARGV.first
14
+ str = ARGV.first
15
+ str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
16
+ if str =~ /\A_(.*)_\z/
17
+ version = $1
18
+ ARGV.shift
19
+ end
16
20
  end
17
21
 
18
22
  gem 'rdoc', version
@@ -10,9 +10,13 @@ require 'rubygems'
10
10
 
11
11
  version = ">= 0"
12
12
 
13
- if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
14
- version = $1
15
- ARGV.shift
13
+ if ARGV.first
14
+ str = ARGV.first
15
+ str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
16
+ if str =~ /\A_(.*)_\z/
17
+ version = $1
18
+ ARGV.shift
19
+ end
16
20
  end
17
21
 
18
22
  gem 'thor', version
@@ -10,9 +10,13 @@ require 'rubygems'
10
10
 
11
11
  version = ">= 0"
12
12
 
13
- if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
14
- version = $1
15
- ARGV.shift
13
+ if ARGV.first
14
+ str = ARGV.first
15
+ str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
16
+ if str =~ /\A_(.*)_\z/
17
+ version = $1
18
+ ARGV.shift
19
+ end
16
20
  end
17
21
 
18
22
  gem 'tilt', version
data/vendor/bundle/bin/tt CHANGED
@@ -10,9 +10,13 @@ require 'rubygems'
10
10
 
11
11
  version = ">= 0"
12
12
 
13
- if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
14
- version = $1
15
- ARGV.shift
13
+ if ARGV.first
14
+ str = ARGV.first
15
+ str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
16
+ if str =~ /\A_(.*)_\z/
17
+ version = $1
18
+ ARGV.shift
19
+ end
16
20
  end
17
21
 
18
22
  gem 'treetop', version
@@ -10,9 +10,13 @@ require 'rubygems'
10
10
 
11
11
  version = ">= 0"
12
12
 
13
- if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
14
- version = $1
15
- ARGV.shift
13
+ if ARGV.first
14
+ str = ARGV.first
15
+ str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
16
+ if str =~ /\A_(.*)_\z/
17
+ version = $1
18
+ ARGV.shift
19
+ end
16
20
  end
17
21
 
18
22
  gem 'yard', version
@@ -10,9 +10,13 @@ require 'rubygems'
10
10
 
11
11
  version = ">= 0"
12
12
 
13
- if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
14
- version = $1
15
- ARGV.shift
13
+ if ARGV.first
14
+ str = ARGV.first
15
+ str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
16
+ if str =~ /\A_(.*)_\z/
17
+ version = $1
18
+ ARGV.shift
19
+ end
16
20
  end
17
21
 
18
22
  gem 'yard', version