erlang-etf 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +3 -0
  3. data/Gemfile +10 -0
  4. data/README.md +3 -3
  5. data/Rakefile +3 -0
  6. data/erlang-etf.gemspec +0 -3
  7. data/lib/erlang/etf/atom.rb +28 -3
  8. data/lib/erlang/etf/atom_utf8.rb +27 -2
  9. data/lib/erlang/etf/binary.rb +10 -3
  10. data/lib/erlang/etf/bit_binary.rb +9 -5
  11. data/lib/erlang/etf/export.rb +12 -4
  12. data/lib/erlang/etf/extensions.rb +0 -19
  13. data/lib/erlang/etf/extensions/array.rb +0 -2
  14. data/lib/erlang/etf/extensions/big_decimal.rb +0 -2
  15. data/lib/erlang/etf/extensions/erlang-export.rb +0 -2
  16. data/lib/erlang/etf/extensions/erlang-list.rb +0 -2
  17. data/lib/erlang/etf/extensions/erlang-nil.rb +0 -2
  18. data/lib/erlang/etf/extensions/erlang-pid.rb +0 -2
  19. data/lib/erlang/etf/extensions/erlang-string.rb +13 -4
  20. data/lib/erlang/etf/extensions/erlang-tuple.rb +0 -2
  21. data/lib/erlang/etf/extensions/false_class.rb +0 -2
  22. data/lib/erlang/etf/extensions/float.rb +0 -2
  23. data/lib/erlang/etf/extensions/hash.rb +0 -2
  24. data/lib/erlang/etf/extensions/integer.rb +0 -2
  25. data/lib/erlang/etf/extensions/nil_class.rb +0 -2
  26. data/lib/erlang/etf/extensions/object.rb +0 -2
  27. data/lib/erlang/etf/extensions/regexp.rb +0 -2
  28. data/lib/erlang/etf/extensions/string.rb +0 -2
  29. data/lib/erlang/etf/extensions/symbol.rb +0 -2
  30. data/lib/erlang/etf/extensions/time.rb +0 -2
  31. data/lib/erlang/etf/extensions/true_class.rb +0 -2
  32. data/lib/erlang/etf/float.rb +9 -4
  33. data/lib/erlang/etf/fun.rb +26 -12
  34. data/lib/erlang/etf/integer.rb +7 -3
  35. data/lib/erlang/etf/large_big.rb +10 -5
  36. data/lib/erlang/etf/large_tuple.rb +6 -1
  37. data/lib/erlang/etf/list.rb +10 -5
  38. data/lib/erlang/etf/new_float.rb +7 -3
  39. data/lib/erlang/etf/new_fun.rb +47 -25
  40. data/lib/erlang/etf/new_reference.rb +14 -9
  41. data/lib/erlang/etf/nil.rb +8 -4
  42. data/lib/erlang/etf/pid.rb +13 -7
  43. data/lib/erlang/etf/port.rb +12 -6
  44. data/lib/erlang/etf/reference.rb +19 -10
  45. data/lib/erlang/etf/small_atom.rb +13 -6
  46. data/lib/erlang/etf/small_atom_utf8.rb +8 -3
  47. data/lib/erlang/etf/small_big.rb +14 -6
  48. data/lib/erlang/etf/small_integer.rb +7 -3
  49. data/lib/erlang/etf/small_tuple.rb +6 -2
  50. data/lib/erlang/etf/string.rb +6 -1
  51. data/lib/erlang/etf/version.rb +1 -1
  52. data/spec/erlang/etf/extensions/erlang-string_spec.rb +19 -4
  53. data/spec/erlang/etf/extensions/erlang-tuple_spec.rb +2 -1
  54. data/spec/erlang/etf/extensions/hash_spec.rb +3 -3
  55. data/spec/erlang/etf/large_tuple_spec.rb +1 -1
  56. data/spec/erlang_spec.rb +2 -1
  57. metadata +3 -44
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 195a05d3181de002ad6dff10e6994d94f722e8b2
4
- data.tar.gz: 18a71520747f118760e31724f9dc135ebdc38dde
3
+ metadata.gz: 0df02c49c6d963c92a155665d854c29c64d4d506
4
+ data.tar.gz: 1f4365a62a0b2ee16b87fa688cba57ee0b4a89f9
5
5
  SHA512:
6
- metadata.gz: c97cd0e64ceaf45946b042117c7cab7cb4654dcb325df611e4f35fdc323970b13b42317901d074ae1daaafff8901959332446e4737e53d37cdd5d874fafe0c5f
7
- data.tar.gz: 2723c6b9376a9e1b235a5e195f30329f777f53b0c841f19bd4ebb44d975d2190d91b6fe2ab61be68711819c8fc5b8fbfe8c1ad83ad703d17fb000b1635d10972
6
+ metadata.gz: 40c84fcbf9312de7a5d9e0e057651743764fe6172e72c8c7e66a80fd4fd693b826235b83f010410f0ff086295f81186f3f4b9630b23276a432b6ad0a26af018b
7
+ data.tar.gz: f167a812a0f03ab72ea546cf3cf47947a9192e921de500439130932c11a33283fdad27f3a3d3b9e195c5b4b560d9a3b4f773d4b523598e421259d9ffdfba1b0a
@@ -0,0 +1,3 @@
1
+ --no-private
2
+ --main README.md
3
+ --markup markdown
data/Gemfile CHANGED
@@ -1,4 +1,14 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ platforms :ruby do
4
+ group :development do
5
+ gem "pry"
6
+ gem "pry-doc"
7
+ gem "redcarpet"
8
+ gem "simplecov", require: false
9
+ gem "yard"
10
+ end
11
+ end
12
+
3
13
  # Specify your gem's dependencies in erlang-etf.gemspec
4
14
  gemspec
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Erlang::Etf
1
+ # Erlang::ETF
2
2
 
3
3
  [![Build Status](https://travis-ci.org/potatosalad/erlang-etf.png)](https://travis-ci.org/potatosalad/erlang-etf)
4
4
 
@@ -26,14 +26,14 @@ $ gem install erlang-etf
26
26
 
27
27
  ## Usage
28
28
 
29
- ### Erlang.term_to_binary(term)
29
+ ### `Erlang.term_to_binary(term)`
30
30
 
31
31
  ```ruby
32
32
  Erlang.term_to_binary(:atom)
33
33
  # => "\x83s\x04atom"
34
34
  ```
35
35
 
36
- ### Erlang.binary_to_term(binary)
36
+ ### `Erlang.binary_to_term(binary)`
37
37
 
38
38
  ```ruby
39
39
  Erlang.binary_to_term("\x83s\x04atom")
data/Rakefile CHANGED
@@ -1,5 +1,8 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rspec/core/rake_task"
3
+ require "yard"
4
+
5
+ YARD::Rake::YardocTask.new(:doc)
3
6
 
4
7
  RSpec::Core::RakeTask.new(:spec)
5
8
 
@@ -22,9 +22,6 @@ Gem::Specification.new do |spec|
22
22
  spec.add_dependency "erlang-terms"
23
23
 
24
24
  spec.add_development_dependency "bundler", "~> 1.3"
25
- spec.add_development_dependency "pry"
26
- spec.add_development_dependency "pry-doc"
27
25
  spec.add_development_dependency "rake"
28
26
  spec.add_development_dependency "rspec"
29
- spec.add_development_dependency "simplecov"
30
27
  end
@@ -7,10 +7,14 @@ module Erlang
7
7
  # 100 | Len | AtomName
8
8
  #
9
9
  # An atom is stored with a 2 byte unsigned length in big-endian
10
- # order, followed by Len numbers of 8 bit Latin1 characters that
11
- # forms the AtomName.
10
+ # order, followed by `Len` numbers of 8 bit Latin1 characters that
11
+ # forms the `AtomName`.
12
12
  #
13
- # Note: The maximum allowed value for Len is 255.
13
+ # **Note:** The maximum allowed value for `Len` is 255.
14
+ #
15
+ # (see [`ATOM_EXT`])
16
+ #
17
+ # [`ATOM_EXT`]: http://erlang.org/doc/apps/erts/erl_ext_dist.html#ATOM_EXT
14
18
  #
15
19
  class Atom
16
20
  include Term
@@ -22,22 +26,43 @@ module Erlang
22
26
  end
23
27
 
24
28
  undef deserialize_atom_name
29
+ # @private
25
30
  def deserialize_atom_name(buffer)
26
31
  self.atom_name = buffer.read(len).from_utf8_binary
27
32
  end
28
33
 
29
34
  undef serialize_atom_name
35
+ # @private
30
36
  def serialize_atom_name(buffer)
31
37
  buffer << atom_name.to_utf8_binary
32
38
  end
33
39
 
34
40
  finalize
35
41
 
42
+ # Instantiate the new atom.
43
+ #
44
+ # @example Instantiate the atom.
45
+ # Erlang::ETF::Atom.new("test")
46
+ # # => #<Erlang::ETF::Atom @tag=100 @len=4 @atom_name="test">
47
+ #
48
+ # @param [ ::String ] atom_name The `AtomName` as a string.
49
+ #
50
+ # @since 1.0.0
36
51
  def initialize(atom_name)
37
52
  @atom_name = atom_name
38
53
  @len = atom_name.to_s.bytesize
39
54
  end
40
55
 
56
+ # Evolve to native ruby.
57
+ #
58
+ # @example Evolve to native ruby.
59
+ # atom = Erlang::ETF::Atom.new("test")
60
+ # atom.__ruby_evolve__
61
+ # # => :test
62
+ #
63
+ # @return [ ::Symbol ] The `AtomName` as a symbol.
64
+ #
65
+ # @since 1.0.0
41
66
  def __ruby_evolve__
42
67
  atom_name.intern
43
68
  end
@@ -7,8 +7,12 @@ module Erlang
7
7
  # 118 | Len | AtomName
8
8
  #
9
9
  # An atom is stored with a 2 byte unsigned length in big-endian
10
- # order, followed by Len bytes containing the AtomName encoded in
11
- # UTF-8.
10
+ # order, followed by `Len` bytes containing the `AtomName` encoded
11
+ # in UTF-8.
12
+ #
13
+ # (see [`ATOM_UTF8_EXT`])
14
+ #
15
+ # [`ATOM_UTF8_EXT`]: http://erlang.org/doc/apps/erts/erl_ext_dist.html#ATOM_UTF8_EXT
12
16
  #
13
17
  class AtomUTF8
14
18
  include Term
@@ -20,22 +24,43 @@ module Erlang
20
24
  end
21
25
 
22
26
  undef deserialize_atom_name
27
+ # @private
23
28
  def deserialize_atom_name(buffer)
24
29
  self.atom_name = buffer.read(len).from_utf8_binary
25
30
  end
26
31
 
27
32
  undef serialize_atom_name
33
+ # @private
28
34
  def serialize_atom_name(buffer)
29
35
  buffer << atom_name.to_utf8_binary
30
36
  end
31
37
 
32
38
  finalize
33
39
 
40
+ # Instantiate the new UTF-8 atom.
41
+ #
42
+ # @example Instantiate the UTF-8 atom.
43
+ # Erlang::ETF::AtomUTF8.new("Ωmega")
44
+ # # => #<Erlang::ETF::AtomUTF8 @tag=118 @len=5 @atom_name="Ωmega">
45
+ #
46
+ # @param [ ::String ] atom_name The `AtomName` as a string.
47
+ #
48
+ # @since 1.0.0
34
49
  def initialize(atom_name)
35
50
  @atom_name = atom_name
36
51
  @len = atom_name.to_s.bytesize
37
52
  end
38
53
 
54
+ # Evolve to native ruby.
55
+ #
56
+ # @example Evolve to native ruby.
57
+ # atom_utf8 = Erlang::ETF::AtomUTF8.new("Ωmega")
58
+ # atom_utf8.__ruby_evolve__
59
+ # # => :'Ωmega'
60
+ #
61
+ # @return [ ::Symbol ] The `AtomName` as a symbol.
62
+ #
63
+ # @since 1.0.0
39
64
  def __ruby_evolve__
40
65
  atom_name.intern
41
66
  end
@@ -7,9 +7,16 @@ module Erlang
7
7
  # 109 | Len | Data
8
8
  #
9
9
  # Binaries are generated with bit syntax expression or with
10
- # list_to_binary/1, term_to_binary/1, or as input from binary
11
- # ports.
12
- # The Len length field is an unsigned 4 byte integer (big endian).
10
+ # [`list_to_binary/1`], [`term_to_binary/1`], or as input from
11
+ # binary ports.
12
+ #
13
+ # The `Len` length field is an unsigned 4 byte integer (big endian).
14
+ #
15
+ # (see [`BINARY_EXT`])
16
+ #
17
+ # [`list_to_binary/1`]: http://erlang.org/doc/man/erlang.html#list_to_binary-1
18
+ # [`term_to_binary/1`]: http://erlang.org/doc/man/erlang.html#term_to_binary-1
19
+ # [`BINARY_EXT`]: http://erlang.org/doc/apps/erts/erl_ext_dist.html#BINARY_EXT
13
20
  #
14
21
  class Binary
15
22
  include Term
@@ -2,17 +2,21 @@ module Erlang
2
2
  module ETF
3
3
 
4
4
  #
5
- # 1 | 4 | 1 | Len
6
- # -- | --- | ---- | ----
7
- # 77 | Len | Bits | Data
5
+ # 1 | 4 | 1 | Len
6
+ # --- | --- | ---- | ----
7
+ # 77 | Len | Bits | Data
8
8
  #
9
9
  # This term represents a bitstring whose length in bits is not a
10
10
  # multiple of 8 (created using the bit syntax in R12B and later).
11
- # The Len field is an unsigned 4 byte integer (big endian).
12
- # The Bits field is the number of bits that are used in the last
11
+ # The `Len` field is an unsigned 4 byte integer (big endian).
12
+ # The `Bits` field is the number of bits that are used in the last
13
13
  # byte in the data field, counting from the most significant bit
14
14
  # towards the least significant.
15
15
  #
16
+ # (see [`BIT_BINARY_EXT`])
17
+ #
18
+ # [`BIT_BINARY_EXT`]: http://erlang.org/doc/apps/erts/erl_ext_dist.html#BIT_BINARY_EXT
19
+ #
16
20
  class BitBinary
17
21
  include Term
18
22
 
@@ -6,12 +6,20 @@ module Erlang
6
6
  # --- | ------ | -------- | -----
7
7
  # 113 | Module | Function | Arity
8
8
  #
9
- # This term is the encoding for external funs: fun M:F/A.
9
+ # This term is the encoding for external funs: `fun M:F/A`.
10
10
  #
11
- # Module and Function are atoms (encoded using ATOM_EXT,
12
- # SMALL_ATOM_EXT or ATOM_CACHE_REF).
11
+ # `Module` and `Function` are atoms (encoded using [`ATOM_EXT`],
12
+ # [`SMALL_ATOM_EXT`] or [`ATOM_CACHE_REF`]).
13
13
  #
14
- # Arity is an integer encoded using SMALL_INTEGER_EXT.
14
+ # `Arity` is an integer encoded using [`SMALL_INTEGER_EXT`].
15
+ #
16
+ # (see [`EXPORT_EXT`])
17
+ #
18
+ # [`ATOM_EXT`]: http://erlang.org/doc/apps/erts/erl_ext_dist.html#ATOM_EXT
19
+ # [`SMALL_ATOM_EXT`]: http://erlang.org/doc/apps/erts/erl_ext_dist.html#SMALL_ATOM_EXT
20
+ # [`ATOM_CACHE_REF`]: http://erlang.org/doc/apps/erts/erl_ext_dist.html#ATOM_CACHE_REF
21
+ # [`SMALL_INTEGER_EXT`]: http://erlang.org/doc/apps/erts/erl_ext_dist.html#SMALL_INTEGER_EXT
22
+ # [`EXPORT_EXT`]: http://erlang.org/doc/apps/erts/erl_ext_dist.html#EXPORT_EXT
15
23
  #
16
24
  class Export
17
25
  include Term
@@ -6,7 +6,6 @@ module Erlang
6
6
 
7
7
  # @private
8
8
  class ::Object
9
- extend Erlang::ETF::Extensions::Object::ClassMethods
10
9
  include Erlang::ETF::Extensions::Object
11
10
  end
12
11
  end
@@ -26,37 +25,31 @@ module Erlang
26
25
 
27
26
  # @private
28
27
  class ::Erlang::Export
29
- extend Erlang::ETF::Extensions::ErlangExport::ClassMethods
30
28
  include Erlang::ETF::Extensions::ErlangExport
31
29
  end
32
30
 
33
31
  # @private
34
32
  class ::Erlang::List
35
- extend Erlang::ETF::Extensions::ErlangList::ClassMethods
36
33
  include Erlang::ETF::Extensions::ErlangList
37
34
  end
38
35
 
39
36
  # @private
40
37
  class ::Erlang::Nil
41
- extend Erlang::ETF::Extensions::ErlangNil::ClassMethods
42
38
  include Erlang::ETF::Extensions::ErlangNil
43
39
  end
44
40
 
45
41
  # @private
46
42
  class ::Erlang::Pid
47
- extend Erlang::ETF::Extensions::ErlangPid::ClassMethods
48
43
  include Erlang::ETF::Extensions::ErlangPid
49
44
  end
50
45
 
51
46
  # @private
52
47
  class ::Erlang::String
53
- extend Erlang::ETF::Extensions::ErlangString::ClassMethods
54
48
  include Erlang::ETF::Extensions::ErlangString
55
49
  end
56
50
 
57
51
  # @private
58
52
  class ::Erlang::Tuple
59
- extend Erlang::ETF::Extensions::ErlangTuple::ClassMethods
60
53
  include Erlang::ETF::Extensions::ErlangTuple
61
54
  end
62
55
  end
@@ -82,73 +75,61 @@ module Erlang
82
75
 
83
76
  # @private
84
77
  class ::Array
85
- extend Erlang::ETF::Extensions::Array::ClassMethods
86
78
  include Erlang::ETF::Extensions::Array
87
79
  end
88
80
 
89
81
  # @private
90
82
  class ::BigDecimal
91
- extend Erlang::ETF::Extensions::BigDecimal::ClassMethods
92
83
  include Erlang::ETF::Extensions::BigDecimal
93
84
  end
94
85
 
95
86
  # @private
96
87
  class ::FalseClass
97
- extend Erlang::ETF::Extensions::FalseClass::ClassMethods
98
88
  include Erlang::ETF::Extensions::FalseClass
99
89
  end
100
90
 
101
91
  # @private
102
92
  class ::Float
103
- extend Erlang::ETF::Extensions::Float::ClassMethods
104
93
  include Erlang::ETF::Extensions::Float
105
94
  end
106
95
 
107
96
  # @private
108
97
  class ::Hash
109
- extend Erlang::ETF::Extensions::Hash::ClassMethods
110
98
  include Erlang::ETF::Extensions::Hash
111
99
  end
112
100
 
113
101
  # @private
114
102
  class ::Integer
115
- extend Erlang::ETF::Extensions::Integer::ClassMethods
116
103
  include Erlang::ETF::Extensions::Integer
117
104
  end
118
105
 
119
106
  # @private
120
107
  class ::NilClass
121
- extend Erlang::ETF::Extensions::NilClass::ClassMethods
122
108
  include Erlang::ETF::Extensions::NilClass
123
109
  end
124
110
 
125
111
  # @private
126
112
  class ::Regexp
127
- extend Erlang::ETF::Extensions::Regexp::ClassMethods
128
113
  include Erlang::ETF::Extensions::Regexp
129
114
  end
130
115
 
131
116
  # @private
132
117
  class ::String
133
- extend Erlang::ETF::Extensions::String::ClassMethods
134
118
  include Erlang::ETF::Extensions::String
135
119
  end
136
120
 
137
121
  # @private
138
122
  class ::Symbol
139
- extend Erlang::ETF::Extensions::Symbol::ClassMethods
140
123
  include Erlang::ETF::Extensions::Symbol
141
124
  end
142
125
 
143
126
  # @private
144
127
  class ::Time
145
- extend Erlang::ETF::Extensions::Time::ClassMethods
146
128
  include Erlang::ETF::Extensions::Time
147
129
  end
148
130
 
149
131
  # @private
150
132
  class ::TrueClass
151
- extend Erlang::ETF::Extensions::TrueClass::ClassMethods
152
133
  include Erlang::ETF::Extensions::TrueClass
153
134
  end
154
135
 
@@ -21,8 +21,6 @@ module Erlang
21
21
  end
22
22
  end
23
23
 
24
- module ClassMethods
25
- end
26
24
  end
27
25
  end
28
26
  end
@@ -14,8 +14,6 @@ module Erlang
14
14
  ETF::Float.new(self)
15
15
  end
16
16
 
17
- module ClassMethods
18
- end
19
17
  end
20
18
  end
21
19
  end
@@ -18,8 +18,6 @@ module Erlang
18
18
  )
19
19
  end
20
20
 
21
- module ClassMethods
22
- end
23
21
  end
24
22
  end
25
23
  end
@@ -23,8 +23,6 @@ module Erlang
23
23
  end
24
24
  end
25
25
 
26
- module ClassMethods
27
- end
28
26
  end
29
27
  end
30
28
  end
@@ -14,8 +14,6 @@ module Erlang
14
14
  ETF::Nil.new
15
15
  end
16
16
 
17
- module ClassMethods
18
- end
19
17
  end
20
18
  end
21
19
  end
@@ -14,8 +14,6 @@ module Erlang
14
14
  ETF::Pid.new(node.to_s.intern.__erlang_evolve__, id, serial, creation)
15
15
  end
16
16
 
17
- module ClassMethods
18
- end
19
17
  end
20
18
  end
21
19
  end