evernote-thrift 1.23.0 → 1.23.1
Sign up to get free protection for your applications and to get access to all the features.
- data/evernote-thrift.gemspec +1 -1
- data/lib/Evernote/EDAM/errors_constants.rb +5 -4
- data/lib/Evernote/EDAM/errors_types.rb +118 -117
- data/lib/Evernote/EDAM/limits_constants.rb +148 -147
- data/lib/Evernote/EDAM/limits_types.rb +5 -4
- data/lib/Evernote/EDAM/note_store.rb +4989 -4989
- data/lib/Evernote/EDAM/note_store_constants.rb +5 -4
- data/lib/Evernote/EDAM/note_store_types.rb +1078 -1077
- data/lib/Evernote/EDAM/types_constants.rb +11 -10
- data/lib/Evernote/EDAM/types_types.rb +2196 -2166
- data/lib/Evernote/EDAM/user_store.rb +603 -603
- data/lib/Evernote/EDAM/user_store_constants.rb +7 -6
- data/lib/Evernote/EDAM/user_store_types.rb +284 -283
- data/lib/thrift.rb +2 -0
- data/lib/thrift/bytes.rb +131 -0
- data/lib/thrift/protocol/base_protocol.rb +97 -10
- data/lib/thrift/protocol/binary_protocol.rb +15 -7
- data/lib/thrift/protocol/compact_protocol.rb +13 -4
- data/lib/thrift/protocol/json_protocol.rb +765 -0
- data/lib/thrift/struct.rb +1 -1
- data/lib/thrift/struct_union.rb +3 -3
- data/lib/thrift/transport/base_transport.rb +22 -20
- data/lib/thrift/transport/buffered_transport.rb +17 -11
- data/lib/thrift/transport/framed_transport.rb +12 -11
- data/lib/thrift/transport/http_client_transport.rb +6 -4
- data/lib/thrift/transport/io_stream_transport.rb +2 -2
- data/lib/thrift/transport/memory_buffer_transport.rb +6 -6
- data/lib/thrift/transport/socket.rb +4 -2
- metadata +4 -2
data/lib/thrift/struct.rb
CHANGED
data/lib/thrift/struct_union.rb
CHANGED
@@ -101,7 +101,7 @@ module Thrift
|
|
101
101
|
end
|
102
102
|
iprot.read_set_end
|
103
103
|
else
|
104
|
-
value = iprot.read_type(field
|
104
|
+
value = iprot.read_type(field)
|
105
105
|
end
|
106
106
|
value
|
107
107
|
end
|
@@ -110,7 +110,7 @@ module Thrift
|
|
110
110
|
if is_container? field[:type]
|
111
111
|
write_container(oprot, value, field)
|
112
112
|
else
|
113
|
-
oprot.write_type(field
|
113
|
+
oprot.write_type(field, value)
|
114
114
|
end
|
115
115
|
end
|
116
116
|
|
@@ -189,4 +189,4 @@ module Thrift
|
|
189
189
|
"[" + buf.join(", ") + "]"
|
190
190
|
end
|
191
191
|
end
|
192
|
-
end
|
192
|
+
end
|
@@ -35,22 +35,14 @@ module Thrift
|
|
35
35
|
end
|
36
36
|
|
37
37
|
module TransportUtils
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
def self.set_string_byte(string, index, byte)
|
44
|
-
string.setbyte(index, byte)
|
45
|
-
end
|
46
|
-
else
|
47
|
-
def self.get_string_byte(string, index)
|
48
|
-
string[index]
|
49
|
-
end
|
38
|
+
# Deprecated: Use Thrift::Bytes instead
|
39
|
+
def self.get_string_byte(string, index)
|
40
|
+
Bytes.get_string_byte(string, index)
|
41
|
+
end
|
50
42
|
|
51
|
-
|
52
|
-
|
53
|
-
|
43
|
+
# Deprecated: Use Thrift::Bytes instead
|
44
|
+
def self.set_string_byte(string, index, byte)
|
45
|
+
Bytes.set_string_byte(string, index, byte)
|
54
46
|
end
|
55
47
|
end
|
56
48
|
|
@@ -61,6 +53,11 @@ module Thrift
|
|
61
53
|
|
62
54
|
def close; end
|
63
55
|
|
56
|
+
# Reads a number of bytes from the transports. In Ruby 1.9+, the String returned will have a BINARY (aka ASCII8BIT) encoding.
|
57
|
+
#
|
58
|
+
# sz - The number of bytes to read from the transport.
|
59
|
+
#
|
60
|
+
# Returns a String acting as a byte buffer.
|
64
61
|
def read(sz)
|
65
62
|
raise NotImplementedError
|
66
63
|
end
|
@@ -68,7 +65,7 @@ module Thrift
|
|
68
65
|
# Returns an unsigned byte as a Fixnum in the range (0..255).
|
69
66
|
def read_byte
|
70
67
|
buf = read_all(1)
|
71
|
-
return
|
68
|
+
return Bytes.get_string_byte(buf, 0)
|
72
69
|
end
|
73
70
|
|
74
71
|
# Reads size bytes and copies them into buffer[0..size].
|
@@ -76,14 +73,14 @@ module Thrift
|
|
76
73
|
tmp = read_all(size)
|
77
74
|
i = 0
|
78
75
|
tmp.each_byte do |byte|
|
79
|
-
|
76
|
+
Bytes.set_string_byte(buffer, i, byte)
|
80
77
|
i += 1
|
81
78
|
end
|
82
79
|
i
|
83
80
|
end
|
84
81
|
|
85
82
|
def read_all(size)
|
86
|
-
return
|
83
|
+
return Bytes.empty_byte_buffer if size <= 0
|
87
84
|
buf = read(size)
|
88
85
|
while (buf.length < size)
|
89
86
|
chunk = read(size - buf.length)
|
@@ -92,7 +89,12 @@ module Thrift
|
|
92
89
|
|
93
90
|
buf
|
94
91
|
end
|
95
|
-
|
92
|
+
|
93
|
+
# Writes the byte buffer to the transport. In Ruby 1.9+, the buffer will be forced into BINARY encoding.
|
94
|
+
#
|
95
|
+
# buf - A String acting as a byte buffer.
|
96
|
+
#
|
97
|
+
# Returns nothing.
|
96
98
|
def write(buf); end
|
97
99
|
alias_method :<<, :write
|
98
100
|
|
@@ -104,4 +106,4 @@ module Thrift
|
|
104
106
|
return trans
|
105
107
|
end
|
106
108
|
end
|
107
|
-
end
|
109
|
+
end
|
@@ -24,8 +24,8 @@ module Thrift
|
|
24
24
|
|
25
25
|
def initialize(transport)
|
26
26
|
@transport = transport
|
27
|
-
@wbuf =
|
28
|
-
@rbuf =
|
27
|
+
@wbuf = Bytes.empty_byte_buffer
|
28
|
+
@rbuf = Bytes.empty_byte_buffer
|
29
29
|
@index = 0
|
30
30
|
end
|
31
31
|
|
@@ -44,12 +44,12 @@ module Thrift
|
|
44
44
|
|
45
45
|
def read(sz)
|
46
46
|
@index += sz
|
47
|
-
ret = @rbuf.slice(@index - sz, sz) ||
|
47
|
+
ret = @rbuf.slice(@index - sz, sz) || Bytes.empty_byte_buffer
|
48
48
|
|
49
49
|
if ret.length == 0
|
50
50
|
@rbuf = @transport.read([sz, DEFAULT_BUFFER].max)
|
51
51
|
@index = sz
|
52
|
-
ret = @rbuf.slice(0, sz) ||
|
52
|
+
ret = @rbuf.slice(0, sz) || Bytes.empty_byte_buffer
|
53
53
|
end
|
54
54
|
|
55
55
|
ret
|
@@ -65,9 +65,15 @@ module Thrift
|
|
65
65
|
# The read buffer has some data now, read a single byte. Using get_string_byte() avoids
|
66
66
|
# allocating a temp string of size 1 unnecessarily.
|
67
67
|
@index += 1
|
68
|
-
return
|
68
|
+
return Bytes.get_string_byte(@rbuf, @index - 1)
|
69
69
|
end
|
70
70
|
|
71
|
+
# Reads a number of bytes from the transport into the buffer passed.
|
72
|
+
#
|
73
|
+
# buffer - The String (byte buffer) to write data to; this is assumed to have a BINARY encoding.
|
74
|
+
# size - The number of bytes to read from the transport and write to the buffer.
|
75
|
+
#
|
76
|
+
# Returns the number of bytes read.
|
71
77
|
def read_into_buffer(buffer, size)
|
72
78
|
i = 0
|
73
79
|
while i < size
|
@@ -78,8 +84,8 @@ module Thrift
|
|
78
84
|
end
|
79
85
|
|
80
86
|
# The read buffer has some data now, so copy bytes over to the output buffer.
|
81
|
-
byte =
|
82
|
-
|
87
|
+
byte = Bytes.get_string_byte(@rbuf, @index)
|
88
|
+
Bytes.set_string_byte(buffer, i, byte)
|
83
89
|
@index += 1
|
84
90
|
i += 1
|
85
91
|
end
|
@@ -87,13 +93,13 @@ module Thrift
|
|
87
93
|
end
|
88
94
|
|
89
95
|
def write(buf)
|
90
|
-
@wbuf << buf
|
96
|
+
@wbuf << Bytes.force_binary_encoding(buf)
|
91
97
|
end
|
92
98
|
|
93
99
|
def flush
|
94
|
-
|
100
|
+
unless @wbuf.empty?
|
95
101
|
@transport.write(@wbuf)
|
96
|
-
@wbuf =
|
102
|
+
@wbuf = Bytes.empty_byte_buffer
|
97
103
|
end
|
98
104
|
|
99
105
|
@transport.flush
|
@@ -105,4 +111,4 @@ module Thrift
|
|
105
111
|
return BufferedTransport.new(transport)
|
106
112
|
end
|
107
113
|
end
|
108
|
-
end
|
114
|
+
end
|
@@ -22,8 +22,8 @@ module Thrift
|
|
22
22
|
class FramedTransport < BaseTransport
|
23
23
|
def initialize(transport, read=true, write=true)
|
24
24
|
@transport = transport
|
25
|
-
@rbuf =
|
26
|
-
@wbuf =
|
25
|
+
@rbuf = Bytes.empty_byte_buffer
|
26
|
+
@wbuf = Bytes.empty_byte_buffer
|
27
27
|
@read = read
|
28
28
|
@write = write
|
29
29
|
@index = 0
|
@@ -44,12 +44,12 @@ module Thrift
|
|
44
44
|
def read(sz)
|
45
45
|
return @transport.read(sz) unless @read
|
46
46
|
|
47
|
-
return
|
47
|
+
return Bytes.empty_byte_buffer if sz <= 0
|
48
48
|
|
49
49
|
read_frame if @index >= @rbuf.length
|
50
50
|
|
51
51
|
@index += sz
|
52
|
-
@rbuf.slice(@index - sz, sz) ||
|
52
|
+
@rbuf.slice(@index - sz, sz) || Bytes.empty_byte_buffer
|
53
53
|
end
|
54
54
|
|
55
55
|
def read_byte
|
@@ -60,7 +60,7 @@ module Thrift
|
|
60
60
|
# The read buffer has some data now, read a single byte. Using get_string_byte() avoids
|
61
61
|
# allocating a temp string of size 1 unnecessarily.
|
62
62
|
@index += 1
|
63
|
-
return
|
63
|
+
return Bytes.get_string_byte(@rbuf, @index - 1)
|
64
64
|
end
|
65
65
|
|
66
66
|
def read_into_buffer(buffer, size)
|
@@ -69,18 +69,18 @@ module Thrift
|
|
69
69
|
read_frame if @index >= @rbuf.length
|
70
70
|
|
71
71
|
# The read buffer has some data now, so copy bytes over to the output buffer.
|
72
|
-
byte =
|
73
|
-
|
72
|
+
byte = Bytes.get_string_byte(@rbuf, @index)
|
73
|
+
Bytes.set_string_byte(buffer, i, byte)
|
74
74
|
@index += 1
|
75
75
|
i += 1
|
76
76
|
end
|
77
77
|
i
|
78
78
|
end
|
79
79
|
|
80
|
-
|
81
|
-
def write(buf,sz=nil)
|
80
|
+
def write(buf, sz=nil)
|
82
81
|
return @transport.write(buf) unless @write
|
83
82
|
|
83
|
+
buf = Bytes.force_binary_encoding(buf)
|
84
84
|
@wbuf << (sz ? buf[0...sz] : buf)
|
85
85
|
end
|
86
86
|
|
@@ -92,10 +92,11 @@ module Thrift
|
|
92
92
|
return @transport.flush unless @write
|
93
93
|
|
94
94
|
out = [@wbuf.length].pack('N')
|
95
|
+
# Array#pack should return a BINARY encoded String, so it shouldn't be necessary to force encoding
|
95
96
|
out << @wbuf
|
96
97
|
@transport.write(out)
|
97
98
|
@transport.flush
|
98
|
-
@wbuf =
|
99
|
+
@wbuf = Bytes.empty_byte_buffer
|
99
100
|
end
|
100
101
|
|
101
102
|
private
|
@@ -113,4 +114,4 @@ module Thrift
|
|
113
114
|
return FramedTransport.new(transport)
|
114
115
|
end
|
115
116
|
end
|
116
|
-
end
|
117
|
+
end
|
@@ -29,14 +29,14 @@ module Thrift
|
|
29
29
|
def initialize(url, proxy_addr = nil, proxy_port = nil)
|
30
30
|
@url = URI url
|
31
31
|
@headers = default_headers
|
32
|
-
@outbuf =
|
32
|
+
@outbuf = Bytes.empty_byte_buffer
|
33
33
|
@proxy_addr = proxy_addr
|
34
34
|
@proxy_port = proxy_port
|
35
35
|
end
|
36
36
|
|
37
37
|
def open?; true end
|
38
38
|
def read(sz); @inbuf.read sz end
|
39
|
-
def write(buf); @outbuf << buf end
|
39
|
+
def write(buf); @outbuf << Bytes.force_binary_encoding(buf) end
|
40
40
|
|
41
41
|
def add_headers(headers)
|
42
42
|
@headers = @headers.merge(headers)
|
@@ -46,8 +46,10 @@ module Thrift
|
|
46
46
|
http = Net::HTTP.new @url.host, @url.port, @proxy_addr, @proxy_port
|
47
47
|
http.use_ssl = @url.scheme == "https"
|
48
48
|
resp = http.post(@url.request_uri, @outbuf, @headers)
|
49
|
-
|
50
|
-
|
49
|
+
data = resp.body
|
50
|
+
data = Bytes.force_binary_encoding(data)
|
51
|
+
@inbuf = StringIO.new data
|
52
|
+
@outbuf = Bytes.empty_byte_buffer
|
51
53
|
end
|
52
54
|
|
53
55
|
private
|
@@ -32,8 +32,8 @@ module Thrift
|
|
32
32
|
|
33
33
|
def open?; not @input.closed? or not @output.closed? end
|
34
34
|
def read(sz); @input.read(sz) end
|
35
|
-
def write(buf); @output.write(buf) end
|
35
|
+
def write(buf); @output.write(Bytes.force_binary_encoding(buf)) end
|
36
36
|
def close; @input.close; @output.close end
|
37
37
|
def to_io; @input end # we're assuming this is used in a IO.select for reading
|
38
38
|
end
|
39
|
-
end
|
39
|
+
end
|
@@ -28,7 +28,7 @@ module Thrift
|
|
28
28
|
# this behavior is no longer required. If you wish to change it
|
29
29
|
# go ahead, just make sure the specs pass
|
30
30
|
def initialize(buffer = nil)
|
31
|
-
@buf = buffer
|
31
|
+
@buf = buffer ? Bytes.force_binary_encoding(buffer) : Bytes.empty_byte_buffer
|
32
32
|
@index = 0
|
33
33
|
end
|
34
34
|
|
@@ -48,7 +48,7 @@ module Thrift
|
|
48
48
|
|
49
49
|
# this method does not use the passed object directly but copies it
|
50
50
|
def reset_buffer(new_buf = '')
|
51
|
-
@buf.replace new_buf
|
51
|
+
@buf.replace Bytes.force_binary_encoding(new_buf)
|
52
52
|
@index = 0
|
53
53
|
end
|
54
54
|
|
@@ -72,7 +72,7 @@ module Thrift
|
|
72
72
|
|
73
73
|
def read_byte
|
74
74
|
raise EOFError.new("Not enough bytes remain in buffer") if @index >= @buf.size
|
75
|
-
val =
|
75
|
+
val = Bytes.get_string_byte(@buf, @index)
|
76
76
|
@index += 1
|
77
77
|
if @index >= GARBAGE_BUFFER_SIZE
|
78
78
|
@buf = @buf.slice(@index..-1)
|
@@ -87,8 +87,8 @@ module Thrift
|
|
87
87
|
raise EOFError.new("Not enough bytes remain in buffer") if @index >= @buf.size
|
88
88
|
|
89
89
|
# The read buffer has some data now, so copy bytes over to the output buffer.
|
90
|
-
byte =
|
91
|
-
|
90
|
+
byte = Bytes.get_string_byte(@buf, @index)
|
91
|
+
Bytes.set_string_byte(buffer, i, byte)
|
92
92
|
@index += 1
|
93
93
|
i += 1
|
94
94
|
end
|
@@ -100,7 +100,7 @@ module Thrift
|
|
100
100
|
end
|
101
101
|
|
102
102
|
def write(wbuf)
|
103
|
-
@buf << wbuf
|
103
|
+
@buf << Bytes.force_binary_encoding(wbuf)
|
104
104
|
end
|
105
105
|
|
106
106
|
def flush
|
@@ -34,8 +34,9 @@ module Thrift
|
|
34
34
|
|
35
35
|
def open
|
36
36
|
begin
|
37
|
-
addrinfo = ::Socket::getaddrinfo(@host, @port).first
|
37
|
+
addrinfo = ::Socket::getaddrinfo(@host, @port, nil, ::Socket::SOCK_STREAM).first
|
38
38
|
@handle = ::Socket.new(addrinfo[4], ::Socket::SOCK_STREAM, 0)
|
39
|
+
@handle.setsockopt(::Socket::IPPROTO_TCP, ::Socket::TCP_NODELAY, 1)
|
39
40
|
sockaddr = ::Socket.sockaddr_in(addrinfo[1], addrinfo[3])
|
40
41
|
begin
|
41
42
|
@handle.connect_nonblock(sockaddr)
|
@@ -60,6 +61,7 @@ module Thrift
|
|
60
61
|
|
61
62
|
def write(str)
|
62
63
|
raise IOError, "closed stream" unless open?
|
64
|
+
str = Bytes.force_binary_encoding(str)
|
63
65
|
begin
|
64
66
|
if @timeout.nil? or @timeout == 0
|
65
67
|
@handle.write(str)
|
@@ -134,4 +136,4 @@ module Thrift
|
|
134
136
|
@handle
|
135
137
|
end
|
136
138
|
end
|
137
|
-
end
|
139
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: evernote-thrift
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.23.
|
4
|
+
version: 1.23.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-11 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: This SDK contains wrapper code used to call the Evernote Cloud API from
|
15
15
|
Ruby.
|
@@ -36,6 +36,7 @@ files:
|
|
36
36
|
- lib/Evernote/EDAM/user_store_constants.rb
|
37
37
|
- lib/Evernote/EDAM/user_store_types.rb
|
38
38
|
- lib/evernote-thrift.rb
|
39
|
+
- lib/thrift/bytes.rb
|
39
40
|
- lib/thrift/client.rb
|
40
41
|
- lib/thrift/core_ext/fixnum.rb
|
41
42
|
- lib/thrift/core_ext.rb
|
@@ -45,6 +46,7 @@ files:
|
|
45
46
|
- lib/thrift/protocol/binary_protocol.rb
|
46
47
|
- lib/thrift/protocol/binary_protocol_accelerated.rb
|
47
48
|
- lib/thrift/protocol/compact_protocol.rb
|
49
|
+
- lib/thrift/protocol/json_protocol.rb
|
48
50
|
- lib/thrift/serializer/deserializer.rb
|
49
51
|
- lib/thrift/serializer/serializer.rb
|
50
52
|
- lib/thrift/server/base_server.rb
|