rubymisc 0.0.2 → 0.0.3

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.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 @ipoval (Ivan Povalyukhin)
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README CHANGED
@@ -26,12 +26,21 @@
26
26
  #errors_with_message
27
27
  e10: begin; raise 'Timeout socket'; rescue errors_with_message(/socket/); p 'socket E'; end
28
28
 
29
+ #ASSERT
30
+ e11: ASSERT { fail SecurityError.new('Fail message!') }
31
+
29
32
  2.3 Integer
30
33
 
31
34
  #percent_of
32
- e11: 50.percent_of(100) # => 50.0
35
+ e12: 50.percent_of(100) # => 50.0
36
+
37
+ 2.4 String
38
+
39
+ #^
40
+ e13: 'rubymisc' ^ 'test' # => "\u0006\u0010\u0011\r\u0019\f\u0000\u0017"
41
+
42
+ 2.5 ActiveRecord::Base
33
43
 
34
- 2.4 ActiveRecord::Base
35
44
  .validates_url
36
45
  .validates_email
37
46
  .validates_image_url
@@ -5,10 +5,10 @@ module Rubymisc
5
5
  def ASSERT(&block)
6
6
  begin
7
7
  yield
8
- rescue StandardError => e
8
+ rescue Exception => e
9
9
  STDERR.puts e.inspect
10
10
  STDERR.puts e.backtrace
11
- raise RuntimeError, "#{e.message}", caller
11
+ # raise e.class, "#{e.message}", caller
12
12
  end
13
13
  end
14
14
 
@@ -0,0 +1,12 @@
1
+ # encoding: utf-8
2
+
3
+ module Rubymisc
4
+ module String
5
+ def ^(key)
6
+ key_num = key.bytes.cycle
7
+ bytes.map { |byte| byte ^ key_num.next }.pack('C*').force_encoding(self.encoding)
8
+ end
9
+ end
10
+ end
11
+
12
+ ::String.module_eval 'include Rubymisc::String'
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Rubymisc
4
- VERSION = '0.0.2'
4
+ VERSION = '0.0.3'
5
5
  end
data/lib/rubymisc.rb CHANGED
@@ -6,6 +6,13 @@ end
6
6
  require 'rubymisc/ext/object'
7
7
  require 'rubymisc/ext/integer'
8
8
  require 'rubymisc/ext/float'
9
+ require 'rubymisc/ext/string'
10
+
9
11
  require 'rubymisc/regex'
10
12
  require 'rubymisc/exceptional'
11
13
  require 'rubymisc/version'
14
+
15
+ __END__
16
+ ###
17
+ # Copyright (C) 2011 Ivan Povalyukhin.
18
+ ###
data/rubymisc.gemspec CHANGED
@@ -23,8 +23,11 @@ Gem::Specification.new do |s|
23
23
  s.required_ruby_version = '>= 1.9.3'
24
24
  s.required_rubygems_version = '>= 1.3.5'
25
25
 
26
+ s.extra_rdoc_files = ['README']
27
+ s.license = 'MIT'
28
+
26
29
  { rspec: '~> 2.8.0.rc1',
27
- rake: '~> 0.9.2',
30
+ rake: '~> 0.9.2.2',
28
31
  bundler: '~> 1.0.21',
29
32
  simplecov: '~> 0.5.4' }.each { |lib, v| s.add_development_dependency lib, v }
30
33
  end
@@ -4,9 +4,9 @@ require 'spec_helper'
4
4
 
5
5
  describe Rubymisc::Exceptional do
6
6
  describe '#ASSERT' do
7
- specify 'catches failing block and raises RuntimeError' do
8
- failing_proc = -> { fail 'Fail message!' }
9
- expect { ASSERT &failing_proc }.to raise_error RuntimeError
7
+ specify 'catches failing block and swallows the exception' do
8
+ failing_proc = -> { fail SecurityError.new('Fail message!') }
9
+ expect { ASSERT &failing_proc }.not_to raise_error
10
10
  end
11
11
 
12
12
  specify 'ok block does not raise error' do
@@ -0,0 +1,17 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Rubymisc::String do
6
+ let(:test_string) { 'rubymisc' }
7
+
8
+ describe '#^' do
9
+ context 'given string key as an argument', :string_key => 'test' do
10
+ specify "returns the result of xor operation between the receiver's bytes and the string_key's bytes" do
11
+ test_string.should respond_to(:^)
12
+ test_string.should_not == test_string ^ example.metadata[:string_key]
13
+ test_string.should == test_string ^ example.metadata[:string_key] ^ example.metadata[:string_key]
14
+ end
15
+ end
16
+ end
17
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubymisc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-03 00:00:00.000000000 Z
12
+ date: 2011-12-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: :rspec
16
- requirement: &2152630760 !ruby/object:Gem::Requirement
16
+ requirement: &2160347660 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,21 +21,21 @@ dependencies:
21
21
  version: 2.8.0.rc1
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *2152630760
24
+ version_requirements: *2160347660
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: :rake
27
- requirement: &2152629820 !ruby/object:Gem::Requirement
27
+ requirement: &2160343120 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
31
31
  - !ruby/object:Gem::Version
32
- version: 0.9.2
32
+ version: 0.9.2.2
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2152629820
35
+ version_requirements: *2160343120
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: :bundler
38
- requirement: &2152627020 !ruby/object:Gem::Requirement
38
+ requirement: &2160338560 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.0.21
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2152627020
46
+ version_requirements: *2160338560
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: :simplecov
49
- requirement: &2152622180 !ruby/object:Gem::Requirement
49
+ requirement: &2160329500 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,17 +54,19 @@ dependencies:
54
54
  version: 0.5.4
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2152622180
57
+ version_requirements: *2160329500
58
58
  description: Miscellaneous and humble tool-set of useful Ruby.
59
59
  email:
60
60
  - ipoval@ya.ru
61
61
  executables: []
62
62
  extensions: []
63
- extra_rdoc_files: []
63
+ extra_rdoc_files:
64
+ - README
64
65
  files:
65
66
  - .gitignore
66
67
  - .rvmrc
67
68
  - Gemfile
69
+ - LICENSE
68
70
  - README
69
71
  - Rakefile
70
72
  - lib/rubymisc.rb
@@ -73,6 +75,7 @@ files:
73
75
  - lib/rubymisc/ext/float.rb
74
76
  - lib/rubymisc/ext/integer.rb
75
77
  - lib/rubymisc/ext/object.rb
78
+ - lib/rubymisc/ext/string.rb
76
79
  - lib/rubymisc/regex.rb
77
80
  - lib/rubymisc/regex/manual.rb
78
81
  - lib/rubymisc/version.rb
@@ -81,6 +84,7 @@ files:
81
84
  - spec/rubymisc/ext/float_spec.rb
82
85
  - spec/rubymisc/ext/integer_spec.rb
83
86
  - spec/rubymisc/ext/object_spec.rb
87
+ - spec/rubymisc/ext/string_spec.rb
84
88
  - spec/rubymisc/regex/manual_spec.rb
85
89
  - spec/rubymisc/regex_spec.rb
86
90
  - spec/rubymisc/version_spec.rb
@@ -88,7 +92,8 @@ files:
88
92
  - spec/spec.rake
89
93
  - spec/spec_helper.rb
90
94
  homepage: https://github.com/ipoval/rubymisc
91
- licenses: []
95
+ licenses:
96
+ - MIT
92
97
  post_install_message:
93
98
  rdoc_options: []
94
99
  require_paths:
@@ -116,6 +121,7 @@ test_files:
116
121
  - spec/rubymisc/ext/float_spec.rb
117
122
  - spec/rubymisc/ext/integer_spec.rb
118
123
  - spec/rubymisc/ext/object_spec.rb
124
+ - spec/rubymisc/ext/string_spec.rb
119
125
  - spec/rubymisc/regex/manual_spec.rb
120
126
  - spec/rubymisc/regex_spec.rb
121
127
  - spec/rubymisc/version_spec.rb