simplenote 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,6 @@
1
+ Autotest.add_hook :initialize do |at|
2
+ at.clear_mappings
3
+
4
+ at.add_mapping(%r{^test/.*_test\.rb$}) {|f, _| [f] }
5
+ at.add_mapping(%r{^lib/(.*)\.rb$}) {|_, m| ["test/#{m[1]}_test.rb"]}
6
+ end
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,5 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Simon Jefford
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,17 @@
1
+ = simplenote
2
+
3
+ A dead simple gem for accessing SimpleNote notes via its API
4
+
5
+ == Note on Patches/Pull Requests
6
+
7
+ * Fork the project.
8
+ * Make your feature addition or bug fix.
9
+ * Add tests for it. This is important so I don't break it in a
10
+ future version unintentionally.
11
+ * Commit, do not mess with rakefile, version, or history.
12
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
13
+ * Send me a pull request. Bonus points for topic branches.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2009 Simon Jefford. See LICENSE for details.
@@ -0,0 +1,61 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "simplenote"
8
+ gem.summary = %Q{Simple wrapper for the SimpleNote HTTP API}
9
+ gem.description = %Q{Uses HTTParty to present a nice Ruby wrapper for SimpleNote}
10
+ gem.email = "simon.jefford@gmail.com"
11
+ gem.homepage = "http://github.com/simonjefford/simplenote"
12
+ gem.authors = ["Simon Jefford"]
13
+ gem.add_development_dependency "thoughtbot-shoulda"
14
+ gem.add_development_dependency "crack"
15
+ gem.add_development_dependency "jnunemaker-matchy"
16
+ gem.add_development_dependency "jferris-mocha", "=0.9.5.0.1241126838"
17
+ gem.add_runtime_dependency "httparty"
18
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
19
+ end
20
+ Jeweler::GemcutterTasks.new
21
+ rescue LoadError
22
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
23
+ end
24
+
25
+ require 'rake/testtask'
26
+ Rake::TestTask.new(:test) do |test|
27
+ test.libs << 'test'
28
+ test.pattern = 'test/**/*_test.rb'
29
+ test.verbose = true
30
+ end
31
+
32
+ begin
33
+ require 'rcov/rcovtask'
34
+ Rcov::RcovTask.new do |test|
35
+ test.libs << 'test'
36
+ test.pattern = 'test/**/*_test.rb'
37
+ test.verbose = true
38
+ end
39
+ rescue LoadError
40
+ task :rcov do
41
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
42
+ end
43
+ end
44
+
45
+ task :test => :check_dependencies
46
+
47
+ task :default => :test
48
+
49
+ require 'rake/rdoctask'
50
+ Rake::RDocTask.new do |rdoc|
51
+ if File.exist?('VERSION')
52
+ version = File.read('VERSION')
53
+ else
54
+ version = ""
55
+ end
56
+
57
+ rdoc.rdoc_dir = 'rdoc'
58
+ rdoc.title = "simplenote #{version}"
59
+ rdoc.rdoc_files.include('README*')
60
+ rdoc.rdoc_files.include('lib/**/*.rb')
61
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,23 @@
1
+ require 'httparty'
2
+ require 'base64'
3
+ require 'crack'
4
+
5
+ class SimpleNote
6
+ include HTTParty
7
+ attr_reader :token, :email
8
+ base_uri 'https://simple-note.appspot.com/api'
9
+
10
+ def login(email, password)
11
+ encoded_body = Base64.encode64({:email => email, :password => password}.to_params)
12
+ @email = email
13
+ @token = self.class.post "/login", :body => encoded_body
14
+ end
15
+
16
+ def get_index
17
+ self.class.get "/index", :query => { :auth => token, :email => email }, :format => :json
18
+ end
19
+
20
+ def get_note(key)
21
+ self.class.get "/note", :query => { :key => key, :auth => token, :email => email }
22
+ end
23
+ end
@@ -0,0 +1,66 @@
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{simplenote}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Simon Jefford"]
12
+ s.date = %q{2009-09-03}
13
+ s.description = %q{Uses HTTParty to present a nice Ruby wrapper for SimpleNote}
14
+ s.email = %q{simon.jefford@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".autotest",
21
+ ".document",
22
+ ".gitignore",
23
+ "LICENSE",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "lib/simplenote.rb",
28
+ "simplenote.gemspec",
29
+ "test/simplenote_test.rb",
30
+ "test/test_helper.rb"
31
+ ]
32
+ s.homepage = %q{http://github.com/simonjefford/simplenote}
33
+ s.rdoc_options = ["--charset=UTF-8"]
34
+ s.require_paths = ["lib"]
35
+ s.rubygems_version = %q{1.3.5}
36
+ s.summary = %q{Simple wrapper for the SimpleNote HTTP API}
37
+ s.test_files = [
38
+ "test/simplenote_test.rb",
39
+ "test/test_helper.rb"
40
+ ]
41
+
42
+ if s.respond_to? :specification_version then
43
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
44
+ s.specification_version = 3
45
+
46
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
47
+ s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
48
+ s.add_development_dependency(%q<crack>, [">= 0"])
49
+ s.add_development_dependency(%q<jnunemaker-matchy>, [">= 0"])
50
+ s.add_development_dependency(%q<jferris-mocha>, ["= 0.9.5.0.1241126838"])
51
+ s.add_runtime_dependency(%q<httparty>, [">= 0"])
52
+ else
53
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
54
+ s.add_dependency(%q<crack>, [">= 0"])
55
+ s.add_dependency(%q<jnunemaker-matchy>, [">= 0"])
56
+ s.add_dependency(%q<jferris-mocha>, ["= 0.9.5.0.1241126838"])
57
+ s.add_dependency(%q<httparty>, [">= 0"])
58
+ end
59
+ else
60
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
61
+ s.add_dependency(%q<crack>, [">= 0"])
62
+ s.add_dependency(%q<jnunemaker-matchy>, [">= 0"])
63
+ s.add_dependency(%q<jferris-mocha>, ["= 0.9.5.0.1241126838"])
64
+ s.add_dependency(%q<httparty>, [">= 0"])
65
+ end
66
+ end
@@ -0,0 +1,52 @@
1
+ require 'test_helper'
2
+
3
+ class SimpleNoteTest < Test::Unit::TestCase
4
+ context "login" do
5
+ setup do
6
+ SimpleNote.stubs(:post).returns("token")
7
+ @simplenote = SimpleNote.new
8
+ @email = "validaccount@example.com"
9
+ @password = "correctpassword"
10
+ @simplenote.login(@email, @password)
11
+ end
12
+
13
+ should "store the returned token" do
14
+ @simplenote.token.should == "token"
15
+ end
16
+
17
+ should "store the email" do
18
+ @simplenote.email.should == @email
19
+ end
20
+
21
+ should "post to /login with email and password base 64 encoded" do
22
+ expected_body = Base64.encode64({ :email => @email, :password => @password}.to_params)
23
+ assert_received(SimpleNote, :post) do |expect|
24
+ expect.with "/login", :body => expected_body
25
+ end
26
+ end
27
+ end
28
+
29
+ context "get_index" do
30
+ setup do
31
+ # TODO - test helper to construct urls given a SimpleNote object
32
+ @url = "https://simple-note.appspot.com/api/index?email=me%40example.com&auth=token"
33
+ body = '[{"key":"notekey", "modify":"2009-09-02 12:00:00.000000", "key":"AB1234"}]'
34
+ FakeWeb.register_uri(:get, @url, :body => body)
35
+ @simplenote = SimpleNote.new
36
+ @simplenote.stubs(:token).returns("token")
37
+ @simplenote.stubs(:email).returns("me@example.com")
38
+ @index = @simplenote.get_index
39
+ end
40
+
41
+ should "return an Array" do
42
+ @index.should be_kind_of(Array)
43
+ end
44
+
45
+ context "returned array" do
46
+ should "contain a single Hash" do
47
+ @index.length.should == 1
48
+ @index[0].should be_kind_of(Hash)
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,12 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require 'simplenote'
8
+ %w(httparty matchy fakeweb mocha base64 crack).each { |x| require x }
9
+ FakeWeb.allow_net_connect = false
10
+
11
+ class Test::Unit::TestCase
12
+ end
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: simplenote
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Simon Jefford
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-09-03 00:00:00 +01:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: thoughtbot-shoulda
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: crack
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: jnunemaker-matchy
37
+ type: :development
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: jferris-mocha
47
+ type: :development
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "="
52
+ - !ruby/object:Gem::Version
53
+ version: 0.9.5.0.1241126838
54
+ version:
55
+ - !ruby/object:Gem::Dependency
56
+ name: httparty
57
+ type: :runtime
58
+ version_requirement:
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: "0"
64
+ version:
65
+ description: Uses HTTParty to present a nice Ruby wrapper for SimpleNote
66
+ email: simon.jefford@gmail.com
67
+ executables: []
68
+
69
+ extensions: []
70
+
71
+ extra_rdoc_files:
72
+ - LICENSE
73
+ - README.rdoc
74
+ files:
75
+ - .autotest
76
+ - .document
77
+ - .gitignore
78
+ - LICENSE
79
+ - README.rdoc
80
+ - Rakefile
81
+ - VERSION
82
+ - lib/simplenote.rb
83
+ - simplenote.gemspec
84
+ - test/simplenote_test.rb
85
+ - test/test_helper.rb
86
+ has_rdoc: true
87
+ homepage: http://github.com/simonjefford/simplenote
88
+ licenses: []
89
+
90
+ post_install_message:
91
+ rdoc_options:
92
+ - --charset=UTF-8
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: "0"
100
+ version:
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: "0"
106
+ version:
107
+ requirements: []
108
+
109
+ rubyforge_project:
110
+ rubygems_version: 1.3.5
111
+ signing_key:
112
+ specification_version: 3
113
+ summary: Simple wrapper for the SimpleNote HTTP API
114
+ test_files:
115
+ - test/simplenote_test.rb
116
+ - test/test_helper.rb