evernote 0.9.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.mkd CHANGED
@@ -1,28 +1,25 @@
1
1
  # evernote #
2
2
  This gem is a high level wrapper around Evernote's Thrift-generated ruby code. It bundles up Evernote's thrift-generated code and creates some simple wrapper classes.
3
3
 
4
+ # setup #
5
+ Get yourself a "Client application" API key from Evernote (http://www.evernote.com/about/developer/api/#key), which gives you a "consumer_key" and "consumer_secret" (note that a "web application" API key uses OAuth to authenticate and will not work). Put the key in a YML file or any other place you put configuration information. Also, get yourself a username and password on both their sandbox system (http://sandbox.evernote.com) and live system. You will be using sandbox for testing.
6
+
4
7
  # usage #
5
- Create a config yml:
6
-
7
- sandbox:
8
- username: user
9
- password: password
10
- consumer_key: key
11
- consumer_secret: secret
12
-
13
- production:
14
- username: user
15
- password: password
16
- consumer_key: key
17
- consumer_secret: secret
18
-
19
- Here's an example using the sandbox key:
20
8
 
21
9
  require 'evernote'
22
10
 
23
11
  user_store_url = "https://sandbox.evernote.com/edam/user"
24
- config = File.dirname(__FILE__) + "/config.yml"
25
- user_store = Evernote::UserStore.new(user_store_url, config, "sandbox")
12
+
13
+ config = {
14
+ :username => 'YOUR_USERNAME',
15
+ :password => 'YOUR_PASSWORD',
16
+ :consumer_key => 'YOUR_CONSUMER_KEY_FROM_EVERNOTE',
17
+ :consumer_secret => 'YOUR_CONSUMER_SECRECT_FROM_EVERNOTE'
18
+ }
19
+
20
+ # note, you could also read in your consumer key information from a YML file
21
+
22
+ user_store = Evernote::UserStore.new(user_store_url, config)
26
23
 
27
24
  auth_result = user_store.authenticate
28
25
  user = auth_result.user
data/Rakefile CHANGED
@@ -1,39 +1,16 @@
1
- require 'rubygems'
2
- require 'rake'
3
-
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "evernote"
8
- gem.summary = %Q{High level wrapper for the Evernote API}
9
- gem.email = "chris.sepic@gmail.com"
10
- gem.homepage = "http://github.com/cgs/evernote"
11
- gem.authors = ["Chris Sepic"]
12
- gem.files.include %w{vendor/**/* spec/evernote/auth.yaml}
13
- gem.add_dependency("thrift_client")
14
- gem.add_development_dependency "rspec"
15
- gem.add_development_dependency "yard"
16
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
17
- end
18
- Jeweler::GemcutterTasks.new
19
- rescue LoadError
20
- puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
21
- end
22
-
23
- require 'spec/rake/spectask'
24
- Spec::Rake::SpecTask.new(:spec) do |spec|
25
- spec.libs << 'lib' << 'spec'
26
- spec.spec_files = FileList['spec/**/*_spec.rb']
1
+ require 'rspec/core/rake_task'
2
+ RSpec::Core::RakeTask.new(:spec) do |spec|
3
+ spec.pattern = 'spec/**/*_spec.rb'
4
+ spec.rspec_opts = %w{ --colour }
27
5
  end
28
6
 
29
- Spec::Rake::SpecTask.new(:rcov) do |spec|
30
- spec.libs << 'lib' << 'spec'
7
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
31
8
  spec.pattern = 'spec/**/*_spec.rb'
9
+ spec.rspec_opts = %w{ --colour }
10
+ spec.rcov_opts = %w{ --exclude gems\/,spec\/ -t}
32
11
  spec.rcov = true
33
12
  end
34
13
 
35
- task :spec => :check_dependencies
36
-
37
14
  task :default => :spec
38
15
 
39
16
  begin
@@ -5,13 +5,16 @@ module Evernote
5
5
  class UserStore
6
6
  AuthenticationFailure = Class.new(StandardError)
7
7
 
8
- def initialize(uri, auth_file, auth_env, thrift_client_options = {})
9
- credentials = YAML.load_file(auth_file)[auth_env.to_s]
8
+ def initialize(uri, credentials, thrift_client_options = {})
10
9
 
11
- @consumer_key = credentials["consumer_key"]
12
- @consumer_secret = credentials["consumer_secret"]
13
- @username = credentials["username"]
14
- @password = credentials["password"]
10
+ raise ArgumentError, "credentials must be passed in as a hash" unless credentials.class == Hash
11
+
12
+ credentials=credentials.inject({}) { |h,(k,v)| h[k.to_sym] = v; h } # convert any stringifyed hash keys into symbols
13
+
14
+ @consumer_key = credentials[:consumer_key]
15
+ @consumer_secret = credentials[:consumer_secret]
16
+ @username = credentials[:username]
17
+ @password = credentials[:password]
15
18
 
16
19
  unless @consumer_key && @consumer_secret && @username && @password
17
20
  raise ArgumentError, "'consumer_key', 'consumer_secret', 'username' and 'password' are required"
@@ -0,0 +1,3 @@
1
+ module Evernote
2
+ VERSION = "1.0.0"
3
+ end
@@ -2,44 +2,54 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
2
 
3
3
  describe "Evernote::UserStore" do
4
4
  before(:each) do
5
- @auth_file = File.dirname(__FILE__) + "/auth.yaml"
6
- @env = :sandbox
5
+ @user_store_url = "https://sandbox.evernote.com/edam/user"
6
+ @config = {
7
+ :username => 'cgs',
8
+ :password => 'password',
9
+ :consumer_key => '12345',
10
+ :consumer_secret => 'ABCDE'
11
+ }
7
12
  end
8
13
 
9
14
  it "initializes an Evernote::Client and validate the client code version" do
10
15
  client = mock("Evernote::Client", :checkVersion => true)
11
16
  Evernote::Client.should_receive(:new).with(Evernote::EDAM::UserStore::UserStore::Client, "https://sandbox.evernote.com/edam/user", {}).and_return(client)
12
17
 
13
- Evernote::UserStore.new("https://sandbox.evernote.com/edam/user", @auth_file, @env)
18
+ Evernote::UserStore.new(@user_store_url, @config)
14
19
  end
15
20
 
16
21
  it "should raise an error on init if the version is not up to date" do
17
22
  Evernote::Client.stub!(:new => mock("Evernote::Client", :checkVersion => false))
18
23
 
19
24
  lambda {
20
- Evernote::UserStore.new("https://sandbox.evernote.com/edam/user", @auth_file, @env)
25
+ Evernote::UserStore.new(@user_store_url, @config)
21
26
  }.should raise_error(Evernote::VersionOutOfDate, "The vendored Evernote client code is out of date and needs to be regenerated")
22
27
  end
23
28
 
24
29
  %w(consumer_key consumer_secret username password).each do |credential|
25
30
  it "raises an exception if no #{credential} is set" do
26
31
  lambda {
27
- Evernote::UserStore.new("https://sandbox.evernote.com/edam/user", @auth_file, :invalid)
32
+ Evernote::UserStore.new(@user_store_url, Hash.new)
28
33
  }.should raise_error(ArgumentError, "'consumer_key', 'consumer_secret', 'username' and 'password' are required")
29
34
  end
30
35
  end
31
36
 
32
37
  it "should authenticate" do
33
38
  Evernote::Client.stub!(:new => mock("Evernote::Client", :checkVersion => true))
34
- user_store = Evernote::UserStore.new("https://sandbox.evernote.com/edam/user", @auth_file, @env)
39
+ user_store=Evernote::UserStore.new(@user_store_url, @config)
35
40
  user_store.instance_variable_get(:@client).should_receive(:authenticate).with("cgs", "password", "12345", "ABCDE").and_return(nil)
36
41
 
37
42
  user_store.authenticate
38
43
  end
39
44
 
45
+ it "should raise an exception if the config parameter is not a hash" do
46
+ not_a_hash="hello, I am a string"
47
+ lambda {Evernote::UserStore.new(@user_store_url, not_a_hash)}.should raise_error(ArgumentError, "credentials must be passed in as a hash")
48
+ end
49
+
40
50
  it "should wrap authentication failure" do
41
51
  Evernote::Client.stub!(:new => mock("Evernote::Client", :checkVersion => true))
42
- user_store = Evernote::UserStore.new("https://sandbox.evernote.com/edam/user", @auth_file, @env)
52
+ user_store=Evernote::UserStore.new(@user_store_url, @config)
43
53
  user_store.instance_variable_get(:@client).should_receive(:authenticate).and_raise(Evernote::EDAM::Error::EDAMUserException)
44
54
 
45
55
  lambda {
@@ -49,7 +59,7 @@ describe "Evernote::UserStore" do
49
59
 
50
60
  it "should proxy methods" do
51
61
  Evernote::Client.stub!(:new => mock("Evernote::Client", :checkVersion => true))
52
- user_store = Evernote::UserStore.new("https://sandbox.evernote.com/edam/user", @auth_file, @env)
62
+ user_store=Evernote::UserStore.new(@user_store_url, @config)
53
63
  user_store.instance_variable_get(:@client).should_receive(:foobar).and_return(nil)
54
64
 
55
65
  user_store.foobar
@@ -1,9 +1,9 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__))
2
2
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
3
  require 'evernote'
4
- require 'spec'
5
- require 'spec/autorun'
4
+ require 'rspec'
5
+ require 'yaml'
6
6
 
7
- Spec::Runner.configure do |config|
7
+ RSpec.configure do |config|
8
8
 
9
9
  end
metadata CHANGED
@@ -1,93 +1,68 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: evernote
3
- version: !ruby/object:Gem::Version
4
- hash: 59
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 9
9
- - 0
10
- version: 0.9.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Chris Sepic
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-01-23 00:00:00 -06:00
12
+ date: 2011-06-28 00:00:00.000000000 -05:00
19
13
  default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
22
16
  name: thrift_client
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ requirement: &2165422040 !ruby/object:Gem::Requirement
25
18
  none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 3
30
- segments:
31
- - 0
32
- version: "0"
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
33
23
  type: :runtime
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- name: rspec
37
24
  prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
25
+ version_requirements: *2165422040
26
+ - !ruby/object:Gem::Dependency
27
+ name: rspec
28
+ requirement: &2165421580 !ruby/object:Gem::Requirement
39
29
  none: false
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- hash: 3
44
- segments:
45
- - 0
46
- version: "0"
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
47
34
  type: :development
48
- version_requirements: *id002
49
- - !ruby/object:Gem::Dependency
50
- name: yard
51
35
  prerelease: false
52
- requirement: &id003 !ruby/object:Gem::Requirement
36
+ version_requirements: *2165421580
37
+ - !ruby/object:Gem::Dependency
38
+ name: yard
39
+ requirement: &2165421160 !ruby/object:Gem::Requirement
53
40
  none: false
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- hash: 3
58
- segments:
59
- - 0
60
- version: "0"
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
61
45
  type: :development
62
- version_requirements: *id003
63
- description:
64
- email: chris.sepic@gmail.com
46
+ prerelease: false
47
+ version_requirements: *2165421160
48
+ description: A high level wrapper around Evernote's Thrift-generated ruby code. It
49
+ bundles up Evernote's thrift-generated code and creates some simple wrapper classes.
50
+ email:
51
+ - chris.sepic@gmail.com
65
52
  executables: []
66
-
67
53
  extensions: []
68
-
69
- extra_rdoc_files:
70
- - LICENSE
71
- - README.mkd
72
- files:
73
- - .document
74
- - .gitignore
75
- - LICENSE
76
- - README.mkd
77
- - Rakefile
78
- - VERSION
79
- - evernote.gemspec
80
- - lib/evernote.rb
54
+ extra_rdoc_files: []
55
+ files:
81
56
  - lib/evernote/client.rb
82
57
  - lib/evernote/note_store.rb
83
58
  - lib/evernote/user_store.rb
59
+ - lib/evernote/version.rb
60
+ - lib/evernote.rb
84
61
  - spec/evernote/auth.yaml
85
62
  - spec/evernote/client_spec.rb
86
63
  - spec/evernote/note_store_spec.rb
87
64
  - spec/evernote/user_store_spec.rb
88
- - spec/spec.opts
89
65
  - spec/spec_helper.rb
90
- - vendor/gen-rb/evernote.rb
91
66
  - vendor/gen-rb/evernote/edam/errors_types.rb
92
67
  - vendor/gen-rb/evernote/edam/limits_constants.rb
93
68
  - vendor/gen-rb/evernote/edam/limits_types.rb
@@ -99,42 +74,34 @@ files:
99
74
  - vendor/gen-rb/evernote/edam/user_store.rb
100
75
  - vendor/gen-rb/evernote/edam/user_store_constants.rb
101
76
  - vendor/gen-rb/evernote/edam/user_store_types.rb
77
+ - vendor/gen-rb/evernote.rb
78
+ - LICENSE
79
+ - README.mkd
80
+ - Rakefile
81
+ - .gitignore
102
82
  has_rdoc: true
103
83
  homepage: http://github.com/cgs/evernote
104
84
  licenses: []
105
-
106
85
  post_install_message:
107
- rdoc_options:
108
- - --charset=UTF-8
109
- require_paths:
86
+ rdoc_options: []
87
+ require_paths:
110
88
  - lib
111
- required_ruby_version: !ruby/object:Gem::Requirement
89
+ required_ruby_version: !ruby/object:Gem::Requirement
112
90
  none: false
113
- requirements:
114
- - - ">="
115
- - !ruby/object:Gem::Version
116
- hash: 3
117
- segments:
118
- - 0
119
- version: "0"
120
- required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
96
  none: false
122
- requirements:
123
- - - ">="
124
- - !ruby/object:Gem::Version
125
- hash: 3
126
- segments:
127
- - 0
128
- version: "0"
97
+ requirements:
98
+ - - ! '>='
99
+ - !ruby/object:Gem::Version
100
+ version: 1.3.6
129
101
  requirements: []
130
-
131
102
  rubyforge_project:
132
- rubygems_version: 1.3.7
103
+ rubygems_version: 1.6.2
133
104
  signing_key:
134
105
  specification_version: 3
135
106
  summary: High level wrapper for the Evernote API
136
- test_files:
137
- - spec/evernote/client_spec.rb
138
- - spec/evernote/note_store_spec.rb
139
- - spec/evernote/user_store_spec.rb
140
- - spec/spec_helper.rb
107
+ test_files: []
data/.document DELETED
@@ -1,5 +0,0 @@
1
- README.rdoc
2
- lib/**/*.rb
3
- bin/*
4
- features/**/*.feature
5
- LICENSE
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.9.0
@@ -1,92 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = %q{evernote}
8
- s.version = "0.9.0"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Chris Sepic"]
12
- s.date = %q{2011-01-23}
13
- s.email = %q{chris.sepic@gmail.com}
14
- s.extra_rdoc_files = [
15
- "LICENSE",
16
- "README.mkd"
17
- ]
18
- s.files = [
19
- ".document",
20
- ".gitignore",
21
- "LICENSE",
22
- "README.mkd",
23
- "Rakefile",
24
- "VERSION",
25
- "evernote.gemspec",
26
- "lib/evernote.rb",
27
- "lib/evernote/client.rb",
28
- "lib/evernote/note_store.rb",
29
- "lib/evernote/user_store.rb",
30
- "spec/evernote/auth.yaml",
31
- "spec/evernote/auth.yaml",
32
- "spec/evernote/client_spec.rb",
33
- "spec/evernote/note_store_spec.rb",
34
- "spec/evernote/user_store_spec.rb",
35
- "spec/spec.opts",
36
- "spec/spec_helper.rb",
37
- "vendor/gen-rb/evernote.rb",
38
- "vendor/gen-rb/evernote.rb",
39
- "vendor/gen-rb/evernote/edam/errors_types.rb",
40
- "vendor/gen-rb/evernote/edam/errors_types.rb",
41
- "vendor/gen-rb/evernote/edam/limits_constants.rb",
42
- "vendor/gen-rb/evernote/edam/limits_constants.rb",
43
- "vendor/gen-rb/evernote/edam/limits_types.rb",
44
- "vendor/gen-rb/evernote/edam/limits_types.rb",
45
- "vendor/gen-rb/evernote/edam/note_store.rb",
46
- "vendor/gen-rb/evernote/edam/note_store.rb",
47
- "vendor/gen-rb/evernote/edam/note_store_constants.rb",
48
- "vendor/gen-rb/evernote/edam/note_store_constants.rb",
49
- "vendor/gen-rb/evernote/edam/note_store_types.rb",
50
- "vendor/gen-rb/evernote/edam/note_store_types.rb",
51
- "vendor/gen-rb/evernote/edam/types_constants.rb",
52
- "vendor/gen-rb/evernote/edam/types_constants.rb",
53
- "vendor/gen-rb/evernote/edam/types_types.rb",
54
- "vendor/gen-rb/evernote/edam/types_types.rb",
55
- "vendor/gen-rb/evernote/edam/user_store.rb",
56
- "vendor/gen-rb/evernote/edam/user_store.rb",
57
- "vendor/gen-rb/evernote/edam/user_store_constants.rb",
58
- "vendor/gen-rb/evernote/edam/user_store_constants.rb",
59
- "vendor/gen-rb/evernote/edam/user_store_types.rb",
60
- "vendor/gen-rb/evernote/edam/user_store_types.rb"
61
- ]
62
- s.homepage = %q{http://github.com/cgs/evernote}
63
- s.rdoc_options = ["--charset=UTF-8"]
64
- s.require_paths = ["lib"]
65
- s.rubygems_version = %q{1.3.7}
66
- s.summary = %q{High level wrapper for the Evernote API}
67
- s.test_files = [
68
- "spec/evernote/client_spec.rb",
69
- "spec/evernote/note_store_spec.rb",
70
- "spec/evernote/user_store_spec.rb",
71
- "spec/spec_helper.rb"
72
- ]
73
-
74
- if s.respond_to? :specification_version then
75
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
76
- s.specification_version = 3
77
-
78
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
79
- s.add_runtime_dependency(%q<thrift_client>, [">= 0"])
80
- s.add_development_dependency(%q<rspec>, [">= 0"])
81
- s.add_development_dependency(%q<yard>, [">= 0"])
82
- else
83
- s.add_dependency(%q<thrift_client>, [">= 0"])
84
- s.add_dependency(%q<rspec>, [">= 0"])
85
- s.add_dependency(%q<yard>, [">= 0"])
86
- end
87
- else
88
- s.add_dependency(%q<thrift_client>, [">= 0"])
89
- s.add_dependency(%q<rspec>, [">= 0"])
90
- s.add_dependency(%q<yard>, [">= 0"])
91
- end
92
- end
@@ -1,2 +0,0 @@
1
- --colour
2
- --diff