boss-protocol 1.4.3 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5874e8e0bafe28f14f96860d9e91ea38d0ab1783
4
- data.tar.gz: ba1ce2c78a5f90e304f1e9bdc4fe7d3c4617df4e
3
+ metadata.gz: e4eaaed01911c7a0f9f26769286b8d16c445cede
4
+ data.tar.gz: 6d7e1918eff5176c1c5741e4ef49ae616353e343
5
5
  SHA512:
6
- metadata.gz: 1f6d6ca3de1a97e307cafd2aef68e983d21e62d4b237849ebc181d1e83200c845d83d6ab64f1f3eb2f829eb79a0cf93e91e933f507e72ba9dcf31985ee56936c
7
- data.tar.gz: 21bbd5e2bff93811da4eac812bcf01c0103a4b95f28a85c7e361731e422f6f87f840b52bf0d858ce08fee289212d4abbef5efb622202e3671c3ffa7f7fd6c4b2
6
+ metadata.gz: 664c0548aee50b3657b24911f7bbc9e970ddb20067652f4e0399fa9782575c020eeea423a46b33a97c398a70958262ecf3b6e87c4ecf751c589ca3f4da2140bd
7
+ data.tar.gz: 671744b293ace6d9d207185b6bf08d7a35e388815a503689f4d4ef746514523f35e44967b03ee05d73f2c71190e95a718da44f7e524e2023d1d449f19e95aca8
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 sergeych
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # Boss Protocol
2
-
2
+
3
3
  Supported version: 1.4 (stream mode with no caching, regular cached mode)
4
4
 
5
5
  BOSS is an acronym for Binary Object Streaming Specification.
@@ -47,6 +47,11 @@ Supported types:
47
47
 
48
48
  There is a working JAVA implemetation also.
49
49
 
50
+ ## Latest news:
51
+
52
+ - added 2.4+ language compatibility (no more Fixnum/Bignum)
53
+ - added simplified Boss.pack()/Boss.unpack() interface
54
+
50
55
  ## Installation
51
56
 
52
57
  Add this line to your application's Gemfile:
@@ -67,14 +72,14 @@ Or install it yourself as:
67
72
  => false
68
73
  1.9.3-p327 :012 > data = { 'test' => [1, 2, -1.22, 'great!'] }
69
74
  => {"test"=>[1, 2, -1.22, "great!"]}
70
- 1.9.3-p327 :013 > x = Boss.dump data
75
+ 1.9.3-p327 :013 > x = Boss.pack data
71
76
  => "\x0F#test&\b\x109\x85\xEBQ\xB8\x1E\x85\xF3\xBF3great!"
72
- 1.9.3-p327 :014 > Marshal.dump data
77
+ 1.9.3-p327 :014 > Marshal.unpack data
73
78
  => "\x04\b{\x06I\"\ttest\x06:\x06ET[\ti\x06i\af\n-1.22I\"\vgreat!\x06;\x00T"
74
79
 
75
80
  Note that boss representation is smaller than ruby's Marshal one
76
81
 
77
- 1.9.3-p327 :015 > Boss.load(x) == data
82
+ 1.9.3-p327 :015 > Boss.unpack(x) == data
78
83
  => true
79
84
 
80
85
  To use the transparent compression:
@@ -83,11 +88,11 @@ To use the transparent compression:
83
88
  => nil
84
89
  1.9.3-p327 :014 > data.length
85
90
  => 139264
86
- 1.9.3-p327 :015 > x = Boss.dump_compressed(data); nil
91
+ 1.9.3-p327 :015 > x = Boss.pack_compress(data); nil
87
92
  => nil
88
93
  1.9.3-p327 :016 > x.length
89
94
  => 147
90
- 1.9.3-p327 :017 > data == Boss.load(x)
95
+ 1.9.3-p327 :017 > data == Boss.unpack(x)
91
96
  => true
92
97
 
93
98
  ## Streaming sample
@@ -9,9 +9,10 @@ Gem::Specification.new do |gem|
9
9
  gem.authors = ["sergeych"]
10
10
  gem.email = ["real.sergeych@gmail.com"]
11
11
  gem.description = %q{Binary streamable bit-effective protocol to effectively store object tree hierarchies}
12
- gem.summary = %q{Traversable and streamable to protocol supports lists, hashes, caching,
13
- compression and more}
14
- gem.homepage = ""
12
+ gem.summary = %q{Traversable and streamable to protocol supports lists, hashes, caching, datetime, texts,
13
+ unlimited integers, floats, compression and more}
14
+ gem.homepage = "https://github.com/sergeych/boss_protocol"
15
+ gem.licenses = ["MIT"]
15
16
 
16
17
  gem.files = `git ls-files`.split($/)
17
18
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
@@ -19,5 +20,5 @@ compression and more}
19
20
  gem.require_paths = ["lib"]
20
21
 
21
22
  #gem.add_dependency 'bzip2-ruby'
22
- gem.add_development_dependency "rspec", '>= 2.14.0'
23
+ gem.add_development_dependency "rspec", '~> 2.14'
23
24
  end
@@ -56,6 +56,12 @@ require 'zlib'
56
56
 
57
57
  module Boss
58
58
 
59
+ if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.4.0')
60
+ Bignum = Integer
61
+ Fixnum = Integer
62
+ end
63
+
64
+
59
65
  class NotSupportedException < StandardError;
60
66
  end
61
67
  # Basic types
@@ -96,7 +102,7 @@ module Boss
96
102
  XT_STREAM_MODE = 16
97
103
 
98
104
  def checkArg(cond, msg=nil)
99
- raise ArgumentError unless cond
105
+ raise ArgumentError, msg unless cond
100
106
  end
101
107
 
102
108
  class UnknownTypeException < Exception;
@@ -218,7 +224,6 @@ module Boss
218
224
  wrenc ob.to_i
219
225
  else
220
226
  error = "error: not supported object: #{ob}, #{ob.class}"
221
- p error
222
227
  raise NotSupportedException, error
223
228
  end
224
229
  self
@@ -544,5 +549,20 @@ module Boss
544
549
  roots.each { |r| f.put_compressed r }
545
550
  f.string
546
551
  end
552
+
553
+ # Pack object into compressed Boss representation
554
+ def Boss.pack_compress(object)
555
+ dump_compressed object
556
+ end
557
+
558
+ # Pack object to the BOSS binary (same as Boss#dump)
559
+ def Boss.pack object
560
+ Boss.dump object
561
+ end
562
+
563
+ # Unpack object from the BOSS binary (same as Boss#load(src))
564
+ def Boss.unpack object
565
+ Boss.load object
566
+ end
547
567
  end
548
568
 
@@ -1,3 +1,3 @@
1
1
  module Boss
2
- VERSION = "1.4.3"
2
+ VERSION = "1.5.0"
3
3
  end
@@ -298,6 +298,11 @@ describe 'Boss' do
298
298
  last['result']['foo'].should == 'bar'
299
299
  end
300
300
 
301
+ it 'has shortcuts' do
302
+ source = ['foo', 'bar', { 'hello' => 'world' }]
303
+ Boss.unpack(Boss.pack source).should == source
304
+ end
305
+
301
306
  def round_check(ob)
302
307
  ob.should == Boss.load(Boss.dump(ob))
303
308
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boss-protocol
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.3
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - sergeych
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-22 00:00:00.000000000 Z
11
+ date: 2017-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.14.0
19
+ version: '2.14'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 2.14.0
26
+ version: '2.14'
27
27
  description: Binary streamable bit-effective protocol to effectively store object
28
28
  tree hierarchies
29
29
  email:
@@ -35,6 +35,7 @@ files:
35
35
  - ".gitignore"
36
36
  - ".rspec"
37
37
  - Gemfile
38
+ - LICENSE
38
39
  - LICENSE.txt
39
40
  - README.md
40
41
  - Rakefile
@@ -44,8 +45,9 @@ files:
44
45
  - samples/testp.rb
45
46
  - spec/boss_spec.rb
46
47
  - spec/spec_helper.rb
47
- homepage: ''
48
- licenses: []
48
+ homepage: https://github.com/sergeych/boss_protocol
49
+ licenses:
50
+ - MIT
49
51
  metadata: {}
50
52
  post_install_message:
51
53
  rdoc_options: []
@@ -63,11 +65,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
63
65
  version: '0'
64
66
  requirements: []
65
67
  rubyforge_project:
66
- rubygems_version: 2.5.1
68
+ rubygems_version: 2.6.11
67
69
  signing_key:
68
70
  specification_version: 4
69
- summary: Traversable and streamable to protocol supports lists, hashes, caching, compression
70
- and more
71
+ summary: Traversable and streamable to protocol supports lists, hashes, caching, datetime,
72
+ texts, unlimited integers, floats, compression and more
71
73
  test_files:
72
74
  - spec/boss_spec.rb
73
75
  - spec/spec_helper.rb