diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/evernote.rb | 6 | ||||
| -rw-r--r-- | lib/evernote/client.rb | 17 | ||||
| -rw-r--r-- | lib/evernote/note_store.rb | 10 | ||||
| -rw-r--r-- | lib/thrift.rb | 64 |
4 files changed, 75 insertions, 22 deletions
diff --git a/lib/evernote.rb b/lib/evernote.rb index d12c9b6..52bf11f 100644 --- a/lib/evernote.rb +++ b/lib/evernote.rb @@ -1,10 +1,12 @@ require 'rubygems' -require 'thrift_client' + +thrift_path = File.expand_path(File.dirname(__FILE__) + "/../vendor") +$LOAD_PATH.unshift thrift_path +require 'thrift' gen_rb_path = File.expand_path(File.dirname(__FILE__) + "/../vendor/gen-rb") $LOAD_PATH.unshift gen_rb_path $LOAD_PATH.unshift "#{gen_rb_path}/evernote/edam" require "#{gen_rb_path}/evernote" -require "evernote/client" require "evernote/user_store" require "evernote/note_store" diff --git a/lib/evernote/client.rb b/lib/evernote/client.rb deleted file mode 100644 index 6293f17..0000000 --- a/lib/evernote/client.rb +++ /dev/null @@ -1,17 +0,0 @@ -module Evernote - class Client - - THRIFT_DEFAULTS = { - :transport => Thrift::HTTPClientTransport - }.freeze - - def initialize(klass, url, thrift_client_options = {}) - thrift_opts = THRIFT_DEFAULTS.merge(thrift_client_options) - @client = ThriftClient.new(klass, url, thrift_opts) - end - - def method_missing(name, *args, &block) - @client.send(name, *args, &block) - end - end -end diff --git a/lib/evernote/note_store.rb b/lib/evernote/note_store.rb index 218d4c9..5c8f225 100644 --- a/lib/evernote/note_store.rb +++ b/lib/evernote/note_store.rb @@ -1,11 +1,15 @@ module Evernote class NoteStore - def initialize(uri, thrift_client_options = {}) - @client = Evernote::Client.new(Evernote::EDAM::NoteStore::NoteStore::Client, uri, thrift_client_options) + def initialize(notestore_url, access_token) + notestore_transport = Thrift::HTTPClientTransport.new(notestore_url) + notestore_protocol = Thrift::BinaryProtocol.new(notestore_transport) + @notestore = Evernote::EDAM::NoteStore::NoteStore::Client.new(notestore_protocol) + @access_token = access_token end + # Camelize the method names for ruby consistency and push the access_token to the front of the args array def method_missing(name, *args, &block) - @client.send(name, *args, &block) + @notestore.send(name.to_s.camelize(:lower), *(args.unshift(@access_token)), &block) end end end diff --git a/lib/thrift.rb b/lib/thrift.rb new file mode 100644 index 0000000..02d67b8 --- /dev/null +++ b/lib/thrift.rb @@ -0,0 +1,64 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +# Contains some contributions under the Thrift Software License. +# Please see doc/old-thrift-license.txt in the Thrift distribution for +# details. + +$:.unshift File.dirname(__FILE__) + +require 'thrift/core_ext' +require 'thrift/exceptions' +require 'thrift/types' +require 'thrift/processor' +require 'thrift/client' +require 'thrift/struct' +require 'thrift/union' +require 'thrift/struct_union' + +# serializer +require 'thrift/serializer/serializer' +require 'thrift/serializer/deserializer' + +# protocol +require 'thrift/protocol/base_protocol' +require 'thrift/protocol/binary_protocol' +require 'thrift/protocol/binary_protocol_accelerated' +require 'thrift/protocol/compact_protocol' + +# transport +require 'thrift/transport/base_transport' +require 'thrift/transport/base_server_transport' +require 'thrift/transport/socket' +require 'thrift/transport/server_socket' +require 'thrift/transport/unix_socket' +require 'thrift/transport/unix_server_socket' +require 'thrift/transport/buffered_transport' +require 'thrift/transport/framed_transport' +require 'thrift/transport/http_client_transport' +require 'thrift/transport/io_stream_transport' +require 'thrift/transport/memory_buffer_transport' + +# server +require 'thrift/server/base_server' +require 'thrift/server/nonblocking_server' +require 'thrift/server/simple_server' +require 'thrift/server/threaded_server' +require 'thrift/server/thread_pool_server' + +require 'thrift/thrift_native' |
