xorcist 1.0.0-java → 1.0.1-java

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: 04bd83615c3ecb37774b18b88e159f458585658c
4
- data.tar.gz: 074ce686948c516e4c3fddda714de029ae6d612e
3
+ metadata.gz: e3ec97ff082d6a11f9f91c2b890dc1b702a7e554
4
+ data.tar.gz: 4c4b5dc875918295ac25fff1e8b5dbc5918470c0
5
5
  SHA512:
6
- metadata.gz: 655eab50ca30c1e09f21c990bb096fc5b6301c6f67fa1f829e5a8478cd7e9f386fb533ede86f191fa14ad80bd18382070e6f95af2834e078aa1d1dc455152647
7
- data.tar.gz: da4117f1799fc026ebe325d06d16053b9955a7432cf5e3fc95d443797e12bc536423b67e08ce85c4ce12be24571141e8e5fcb0ec04cb03da4274f8ef5bd2bda3
6
+ metadata.gz: bfe6eb7464fad71d6eba8e8937384ff9638221fecd7971eff3e77904740111faf5a27d7ee28f976209a3a2bd1fd23583dfcd087ffa70916d642e9da06868b1ac
7
+ data.tar.gz: e84e02571301a9e8f2ac8dc4ac404153b81e8dd832d96b8f29cdf0789d98fd94a0663d5947e3c4fbaaa676131d1b4aad7ae4b94b43b09f69a11f1291a7dea73b
data/README.md CHANGED
@@ -11,8 +11,10 @@ Blazing-fast-cross-platform-monkey-patch-free string XOR. Yes, that means JRuby
11
11
  require 'xorcist'
12
12
 
13
13
  a, b = 'a', 'b'
14
- Xorcist.xor(a, b)
15
- Xorcist.xor!(a, b)
14
+ Xorcist.xor(a, b) # => "\u0003"
15
+ a # => 'a'
16
+ Xorcist.xor!(a, b) # => "\u0003"
17
+ a # => "\u0003"
16
18
  ```
17
19
 
18
20
  You can `include Xorcist` to expose its methods:
@@ -46,30 +48,35 @@ require 'xorcist/string_methods'
46
48
  String.include(Xorcist::StringMethods)
47
49
  ```
48
50
 
51
+ ## Encodings
52
+
53
+ Note the precise encoding `xor`'s output is undefined in the v1.0.x releases. In MRI `xor!` will return a string using your default encoding. With JRuby, `xor!` will return an ASCII-8BIT string.
54
+
49
55
  ## Benchmarks
50
56
 
51
- Disclaimer: these are run from my craptop. Run 'em yourself with `bin/benchmark`.
57
+ Disclaimer: these are run from my craptop. Run 'em yourself with `bin/benchmark`. You'll need to have [`benchmark-ips`](https://github.com/evanphx/benchmark-ips) installed.
52
58
 
53
59
  ### MRI 2.2.1
54
60
 
55
61
  ```
56
62
  Calculating -------------------------------------
57
- ruby 11.136k i/100ms
58
- xorcist 71.472k i/100ms
63
+ ruby 26.378k i/100ms
64
+ xorcist 73.291k i/100ms
59
65
  -------------------------------------------------
60
- ruby 144.198k1.3%) i/s - 723.840k
61
- xorcist 2.155M0.7%) i/s - 10.792M
66
+ ruby 376.513k0.5%) i/s - 1.899M
67
+ xorcist 2.150M3.9%) i/s - 10.774M
62
68
  ```
63
69
 
64
70
  ### JRuby 1.7.19
65
71
 
66
72
  ```
73
+ Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar
67
74
  Calculating -------------------------------------
68
- ruby 142.000 i/100ms
69
- xorcist 88.006k i/100ms
75
+ ruby 31.795k i/100ms
76
+ xorcist 118.084k i/100ms
70
77
  -------------------------------------------------
71
- ruby 3.113k32.6%) i/s - 11.218k in 5.781000s
72
- xorcist 3.184M32.9%) i/s - 12.321M
78
+ ruby 978.078k11.2%) i/s - 4.801M
79
+ xorcist 3.897M14.1%) i/s - 19.012M
73
80
  ```
74
81
 
75
82
  ## Installation
@@ -98,7 +105,8 @@ The gem is available as open source under the terms of the [MIT License](http://
98
105
 
99
106
  ## Special Thanks To...
100
107
 
101
- - [Steve Sloan][http://www.finagle.org] for his [fast_xor gem][https://github.com/CodeMonkeySteve/fast_xor] from which most of the tests are borrowed
102
- - [James Coglan][http://jcoglan.com] for his [guide on writing a JRuby Java extension][https://blog.jcoglan.com/2012/08/02/your-first-ruby-native-extension-java/]
108
+ - [Steve Sloan](http://www.finagle.org) for his [fast_xor gem](https://github.com/CodeMonkeySteve/fast_xor) from which most of the tests are borrowed
109
+ - [James Coglan](http://jcoglan.com) for his [guide on writing a JRuby Java extension](https://blog.jcoglan.com/2012/08/02/your-first-ruby-native-extension-java/)
110
+ - [Thomas Leitner](https://github.com/gettalong) for a faster pure Ruby XOR implementation that's used in the benchmark
103
111
  - To all [contributers](https://github.com/fny/xorcist/graphs/contributors)! :beers:
104
112
 
data/lib/xorcist.jar CHANGED
Binary file
@@ -1,3 +1,3 @@
1
1
  module Xorcist
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
metadata CHANGED
@@ -1,25 +1,25 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xorcist
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: java
6
6
  authors:
7
7
  - Faraz Yashar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-13 00:00:00.000000000 Z
11
+ date: 2015-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  version_requirements: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.10'
20
20
  requirement: !ruby/object:Gem::Requirement
21
21
  requirements:
22
- - - ~>
22
+ - - "~>"
23
23
  - !ruby/object:Gem::Version
24
24
  version: '1.10'
25
25
  prerelease: false
@@ -28,12 +28,12 @@ dependencies:
28
28
  name: minitest
29
29
  version_requirements: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: 5.7.0
34
34
  requirement: !ruby/object:Gem::Requirement
35
35
  requirements:
36
- - - ~>
36
+ - - "~>"
37
37
  - !ruby/object:Gem::Version
38
38
  version: 5.7.0
39
39
  prerelease: false
@@ -42,12 +42,12 @@ dependencies:
42
42
  name: rake
43
43
  version_requirements: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '10.0'
48
48
  requirement: !ruby/object:Gem::Requirement
49
49
  requirements:
50
- - - ~>
50
+ - - "~>"
51
51
  - !ruby/object:Gem::Version
52
52
  version: '10.0'
53
53
  prerelease: false
@@ -56,14 +56,14 @@ dependencies:
56
56
  name: rake-compiler
57
57
  version_requirements: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: 0.9.5
62
62
  requirement: !ruby/object:Gem::Requirement
63
63
  requirements:
64
- - - '>='
64
+ - - "~>"
65
65
  - !ruby/object:Gem::Version
66
- version: '0'
66
+ version: 0.9.5
67
67
  prerelease: false
68
68
  type: :development
69
69
  description: Blazing-fast-cross-platform-monkey-patch-free string XOR. Yes, that means JRuby too.
@@ -74,18 +74,11 @@ extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
76
  - README.md
77
- - ext/xorcist/Xorcist.java
78
- - ext/xorcist/XorcistService.java
79
- - ext/xorcist/extconf.rb
80
- - ext/xorcist/xorcist.c
81
77
  - lib/xorcist.jar
82
78
  - lib/xorcist.rb
83
79
  - lib/xorcist/refinements.rb
84
80
  - lib/xorcist/string_methods.rb
85
81
  - lib/xorcist/version.rb
86
- - test/refinements_test.rb
87
- - test/test_helper.rb
88
- - test/xorcist_test.rb
89
82
  homepage: https://github.com/fny/xorcist
90
83
  licenses:
91
84
  - MIT
@@ -96,17 +89,17 @@ require_paths:
96
89
  - lib
97
90
  required_ruby_version: !ruby/object:Gem::Requirement
98
91
  requirements:
99
- - - '>='
92
+ - - ">="
100
93
  - !ruby/object:Gem::Version
101
94
  version: '0'
102
95
  required_rubygems_version: !ruby/object:Gem::Requirement
103
96
  requirements:
104
- - - '>='
97
+ - - ">="
105
98
  - !ruby/object:Gem::Version
106
99
  version: '0'
107
100
  requirements: []
108
101
  rubyforge_project:
109
- rubygems_version: 2.4.5
102
+ rubygems_version: 2.4.8
110
103
  signing_key:
111
104
  specification_version: 4
112
105
  summary: Blazing-fast-cross-platform-monkey-patch-free string XOR
@@ -1,22 +0,0 @@
1
- import org.jruby.anno.JRubyMethod;
2
- import org.jruby.runtime.ThreadContext;
3
- import org.jruby.runtime.builtin.IRubyObject;
4
- import org.jruby.RubyString;
5
- import org.jruby.util.ByteList;
6
-
7
- public class Xorcist {
8
- @JRubyMethod(name = "xor!", module = true)
9
- public static RubyString xorInPlace(ThreadContext context, IRubyObject self, RubyString x, RubyString y) {
10
- byte[] xBytes = x.getBytes();
11
- byte[] yBytes = y.getBytes();
12
-
13
- int length = yBytes.length < xBytes.length ? yBytes.length : xBytes.length;
14
-
15
- for(int i = 0; i < length; i++) {
16
- xBytes[i] = (byte) (xBytes[i] ^ yBytes[i]);
17
- }
18
-
19
- x.setValue(new ByteList(xBytes));
20
- return x;
21
- }
22
- }
@@ -1,14 +0,0 @@
1
- import java.io.IOException;
2
-
3
- import org.jruby.Ruby;
4
- import org.jruby.RubyModule;
5
- import org.jruby.runtime.load.BasicLibraryService;
6
-
7
- public class XorcistService implements BasicLibraryService {
8
- @Override
9
- public boolean basicLoad(final Ruby runtime) throws IOException {
10
- RubyModule xorcist = runtime.defineModule("Xorcist");
11
- xorcist.defineAnnotatedMethods(Xorcist.class);
12
- return true;
13
- }
14
- }
@@ -1,4 +0,0 @@
1
- require 'mkmf'
2
- extension_name = 'xorcist'
3
- dir_config(extension_name)
4
- create_makefile(extension_name)
@@ -1,36 +0,0 @@
1
- #include "ruby.h"
2
-
3
- VALUE Xorcist = Qnil;
4
-
5
- void Init_xorcist();
6
-
7
- VALUE xor_in_place(VALUE x, VALUE y, VALUE self);
8
-
9
- VALUE xor_in_place(VALUE self, VALUE x, VALUE y) {
10
- const char *src = 0;
11
- char *dest = 0;
12
- size_t len;
13
- size_t y_len;
14
-
15
- rb_str_modify(x);
16
- dest = RSTRING_PTR(x);
17
- len = RSTRING_LEN(x);
18
-
19
- src = RSTRING_PTR(y);
20
- y_len = RSTRING_LEN(y);
21
-
22
- if (y_len < len) {
23
- len = y_len;
24
- }
25
-
26
- for (; len--; ++dest, ++src) {
27
- *dest ^= *src;
28
- }
29
-
30
- return x;
31
- }
32
-
33
- void Init_xorcist() {
34
- Xorcist = rb_define_module("Xorcist");
35
- rb_define_module_function(Xorcist, "xor!", xor_in_place, 2);
36
- }
@@ -1,23 +0,0 @@
1
- require 'test_helper'
2
-
3
- if RUBY_ENGINE != 'jruby' && RUBY_ENGINE != 'rbx' && RUBY_VERSION >= '2.0.0'
4
- require 'xorcist/refinements'
5
-
6
- class RefinementsTest < Minitest::Test
7
- using Xorcist::Refinements
8
-
9
- def test_xor
10
- assert_equal ZERO, X.xor(X)
11
- assert_equal ONE, X.xor(INVX)
12
- assert_equal X, X.xor(ZERO)
13
- assert_equal INVX, X.xor(ONE)
14
- end
15
-
16
- def test_xor_in_place
17
- a = "String"
18
- b = a
19
- b.xor!(X)
20
- assert_equal(a, b)
21
- end
22
- end
23
- end
data/test/test_helper.rb DELETED
@@ -1,11 +0,0 @@
1
- require 'xorcist'
2
-
3
- require 'minitest'
4
- require 'minitest/autorun'
5
- require 'minitest/pride'
6
-
7
- LEN = 16
8
- ZERO = ([0x00].pack('C') * LEN).freeze
9
- ONE = ([0xFF].pack('C') * LEN).freeze
10
- X = (0...LEN).collect { rand 256 }.pack('C*').freeze
11
- INVX = (0...LEN).collect { |i| X[i].ord ^ 0xFF }.pack('C*').freeze
data/test/xorcist_test.rb DELETED
@@ -1,42 +0,0 @@
1
- require 'test_helper'
2
-
3
- class XorcistTest < Minitest::Test
4
- include Xorcist
5
-
6
- def test_xor
7
- assert_equal ZERO, xor(X, X)
8
- assert_equal ONE, xor(X, INVX)
9
- assert_equal X, xor(X, ZERO)
10
- assert_equal INVX, xor(X, ONE)
11
- end
12
-
13
- def test_xor_in_place
14
- a = "String"
15
- b = a
16
- xor!(b, X)
17
- assert_equal(a, b)
18
- end
19
-
20
- #
21
- # Tests for different string storage behaviors in MRI.
22
- # See http://patshaughnessy.net/2012/1/4/never-create-ruby-strings-longer-than-23-characters
23
- # for details.
24
- # Might as well run them in other Rubies too.
25
- #
26
-
27
- def test_embedded_string
28
- a = "Embedded string"
29
- assert a.size <= 23
30
- b = a.dup
31
- xor!(b, X)
32
- refute_equal(a, b)
33
- end
34
-
35
- def test_heap_string
36
- a = "A very long string that's stored on the heap"
37
- assert a.size > 24
38
- b = a.dup
39
- xor!(b, X*2)
40
- refute_equal(a, b)
41
- end
42
- end