xorcist 1.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2de9dd2f8528b30b41521656e48ba9b4a1e5e39f
4
- data.tar.gz: d791dcdd4766e8aef412047954e1504464ee6584
3
+ metadata.gz: e60583bfba07126835c5def71dbfd1997f504a22
4
+ data.tar.gz: 13cf6b74ab9ea7ae040148ce130e24665c73bd25
5
5
  SHA512:
6
- metadata.gz: d9f69c450e68d80ca5cf76d32a72930ba8e3436ef1252ada6808eebc85273d4de805579a6f60a2c9e4924c514dd6ce653d5e9fc1c634f8c33c8a9e70f39ea611
7
- data.tar.gz: 859066a86e1c7879f378d202adef1c179fba1f4d6f913ac4fcd161d575a4c2e86a2926745e0e8a13a0f153fba3d862a604cc03ea89742130c9c29b5cc4a4062c
6
+ metadata.gz: 391f4eae4f0422e52ad1e52ddd500f23c23373a4a1d2c8e5004c70dc3a4f21364e8d9e3fedfc4fabb2bf8a31e72129477fdca5efb0709f136005eecfcaaff99a
7
+ data.tar.gz: 7d884189cb4f58d98ce01a6dd72ff97d1e95507c292f3960f7b345220c3e87af040eb5cd57800cb147fe7122e6c636b01b6349843e43092ed7546962ff1260bb
data/README.md CHANGED
@@ -15,6 +15,7 @@ Xorcist.xor(a, b) # => "\u0003"
15
15
  a # => 'a'
16
16
  Xorcist.xor!(a, b) # => "\u0003"
17
17
  a # => "\u0003"
18
+ Xorcist.xor!(a.freeze, b) # => RuntimeError!
18
19
  ```
19
20
 
20
21
  You can `include Xorcist` to expose its methods:
@@ -70,7 +71,7 @@ Calculating -------------------------------------
70
71
  ### JRuby 1.7.19
71
72
 
72
73
  ```
73
- Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar
74
+ Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar
74
75
  Calculating -------------------------------------
75
76
  ruby 31.795k i/100ms
76
77
  xorcist 118.084k i/100ms
@@ -1,4 +1,4 @@
1
1
  require 'mkmf'
2
2
  extension_name = 'xorcist'
3
3
  dir_config(extension_name)
4
- create_makefile(extension_name)
4
+ create_makefile('xorcist/xorcist')
@@ -4,7 +4,7 @@ VALUE Xorcist = Qnil;
4
4
 
5
5
  void Init_xorcist();
6
6
 
7
- VALUE xor_in_place(VALUE x, VALUE y, VALUE self);
7
+ VALUE xor_in_place(VALUE self, VALUE x, VALUE y);
8
8
 
9
9
  VALUE xor_in_place(VALUE self, VALUE x, VALUE y) {
10
10
  const char *src = 0;
@@ -12,6 +12,16 @@ VALUE xor_in_place(VALUE self, VALUE x, VALUE y) {
12
12
  size_t len;
13
13
  size_t y_len;
14
14
 
15
+ if (TYPE(x) != T_STRING) {
16
+ rb_raise( rb_eTypeError, "first argument must be a String" );
17
+ return Qnil;
18
+ }
19
+
20
+ if (TYPE(y) != T_STRING) {
21
+ rb_raise( rb_eTypeError, "second argument must be a String" );
22
+ return Qnil;
23
+ }
24
+
15
25
  rb_str_modify(x);
16
26
  dest = RSTRING_PTR(x);
17
27
  len = RSTRING_LEN(x);
data/lib/xorcist.rb CHANGED
@@ -1,10 +1,10 @@
1
1
  require 'xorcist/version'
2
2
 
3
3
  if RUBY_ENGINE == 'jruby'
4
- require 'jruby'
4
+ require 'java'
5
5
  require File.expand_path('../xorcist.jar', __FILE__)
6
6
  else
7
- require File.expand_path('../xorcist.so', __FILE__)
7
+ require 'xorcist/xorcist'
8
8
  end
9
9
 
10
10
  module Xorcist
@@ -12,4 +12,18 @@ module Xorcist
12
12
  def xor(x, y)
13
13
  xor!(x.dup, y)
14
14
  end
15
+
16
+ # rb_str_modify isn't blowing up for frozen strings under Rubinius, so we'll
17
+ # hack in a fix here
18
+ if RUBY_ENGINE == 'rbx'
19
+ alias_method :_xor!, :xor!
20
+ remove_method :xor!
21
+ def xor!(x, y)
22
+ if x.frozen?
23
+ raise(RuntimeError, "can't modify frozen String")
24
+ else
25
+ _xor!(x, y)
26
+ end
27
+ end
28
+ end
15
29
  end
@@ -1,3 +1,3 @@
1
1
  module Xorcist
2
- VERSION = '1.0.1'
2
+ VERSION = '1.1.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xorcist
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Faraz Yashar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-25 00:00:00.000000000 Z
11
+ date: 2018-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -102,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
102
  version: '0'
103
103
  requirements: []
104
104
  rubyforge_project:
105
- rubygems_version: 2.4.6
105
+ rubygems_version: 2.6.11
106
106
  signing_key:
107
107
  specification_version: 4
108
108
  summary: Blazing-fast-cross-platform-monkey-patch-free string XOR