todoist 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,10 +1,2 @@
1
- begin
2
- require 'spec'
3
- rescue LoadError
4
- require 'rubygems'
5
- gem 'rspec'
6
- require 'spec'
7
- end
8
-
9
- $:.unshift(File.dirname(__FILE__) + '/../lib')
10
- require 'todoist'
1
+ require 'rubygems'
2
+ require 'bacon'
@@ -1,10 +1,7 @@
1
- require File.dirname(__FILE__) + '/spec_helper.rb'
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
2
 
3
- # Time to add your specs!
4
- # http://rspec.info/
5
- describe "Place your specs here" do
6
-
7
- it "find this spec in spec directory" do
3
+ describe 'Todoist' do
4
+ it "is" do
5
+ true.should.equal true
8
6
  end
9
-
10
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: todoist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Stott
@@ -9,79 +9,65 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-07-09 00:00:00 +01:00
13
- default_executable:
12
+ date: 2009-10-06 00:00:00 +01:00
13
+ default_executable: todoist
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: json
16
+ name: highline
17
17
  type: :runtime
18
18
  version_requirement:
19
19
  version_requirements: !ruby/object:Gem::Requirement
20
20
  requirements:
21
- - - ">="
21
+ - - ~>
22
22
  - !ruby/object:Gem::Version
23
- version: 1.1.2
23
+ version: "1.5"
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
- name: hoe
27
- type: :development
26
+ name: thor
27
+ type: :runtime
28
28
  version_requirement:
29
29
  version_requirements: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: 1.7.0
33
+ version: "0.9"
34
34
  version:
35
- description: A gem which provides an interface for interacting with the todoist.com service.
36
- email:
37
- - jonathan.stott@gmail.com
38
- executables: []
39
-
35
+ - !ruby/object:Gem::Dependency
36
+ name: httparty
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: "0.3"
44
+ version:
45
+ description: The todoist gem offers convinience methods and wrappers for the todoist list management service, easing retrival and parsing of the responses. It also offers a simple command-line client.
46
+ email: jonathan.stott@gmail.com
47
+ executables:
48
+ - todoist
40
49
  extensions: []
41
50
 
42
51
  extra_rdoc_files:
43
- - History.txt
44
- - License.txt
45
- - Manifest.txt
46
- - README.txt
47
- - website/index.txt
52
+ - LICENSE
53
+ - README
48
54
  files:
49
- - History.txt
50
- - License.txt
51
- - Manifest.txt
52
- - README.txt
53
55
  - Rakefile
54
- - config/hoe.rb
55
- - config/requirements.rb
56
56
  - lib/todoist.rb
57
- - lib/todoist/connection.rb
58
- - lib/todoist/errors.rb
59
- - lib/todoist/version.rb
60
- - script/console
61
- - script/destroy
62
- - script/generate
63
- - script/txt2html
64
- - setup.rb
65
- - spec/spec.opts
57
+ - lib/todoist/base.rb
58
+ - lib/todoist/project.rb
59
+ - lib/todoist/task.rb
66
60
  - spec/spec_helper.rb
67
61
  - spec/todoist_spec.rb
68
- - tasks/deployment.rake
69
- - tasks/environment.rake
70
- - tasks/rspec.rake
71
- - tasks/website.rake
72
- - test/test_helper.rb
73
- - test/test_todoist.rb
74
- - website/index.html
75
- - website/index.txt
76
- - website/javascripts/rounded_corners_lite.inc.js
77
- - website/stylesheets/screen.css
78
- - website/template.html.erb
62
+ - LICENSE
63
+ - README
79
64
  has_rdoc: true
80
- homepage: http://todoist.rubyforge.org
81
- post_install_message: ""
65
+ homepage: http://github.com/namelessjon/todoist
66
+ licenses: []
67
+
68
+ post_install_message:
82
69
  rdoc_options:
83
- - --main
84
- - README.txt
70
+ - --charset=UTF-8
85
71
  require_paths:
86
72
  - lib
87
73
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -98,11 +84,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
84
  version:
99
85
  requirements: []
100
86
 
101
- rubyforge_project: todoist
102
- rubygems_version: 1.2.0
87
+ rubyforge_project:
88
+ rubygems_version: 1.3.5
103
89
  signing_key:
104
- specification_version: 2
105
- summary: A gem which provides an interface for interacting with the todoist.com service.
90
+ specification_version: 3
91
+ summary: a library for interacting with the Todoist public API
106
92
  test_files:
107
- - test/test_helper.rb
108
- - test/test_todoist.rb
93
+ - spec/todoist_spec.rb
94
+ - spec/spec_helper.rb
@@ -1,4 +0,0 @@
1
- == 0.0.1 2008-06-25
2
-
3
- * 1 major enhancement:
4
- * Initial release
@@ -1,20 +0,0 @@
1
- Copyright (c) 2008 Jonathan Stott
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.
@@ -1,30 +0,0 @@
1
- History.txt
2
- License.txt
3
- Manifest.txt
4
- README.txt
5
- Rakefile
6
- config/hoe.rb
7
- config/requirements.rb
8
- lib/todoist.rb
9
- lib/todoist/connection.rb
10
- lib/todoist/errors.rb
11
- lib/todoist/version.rb
12
- script/console
13
- script/destroy
14
- script/generate
15
- script/txt2html
16
- setup.rb
17
- spec/spec.opts
18
- spec/spec_helper.rb
19
- spec/todoist_spec.rb
20
- tasks/deployment.rake
21
- tasks/environment.rake
22
- tasks/rspec.rake
23
- tasks/website.rake
24
- test/test_helper.rb
25
- test/test_todoist.rb
26
- website/index.html
27
- website/index.txt
28
- website/javascripts/rounded_corners_lite.inc.js
29
- website/stylesheets/screen.css
30
- website/template.html.erb
data/README.txt DELETED
@@ -1,55 +0,0 @@
1
- = todoist
2
-
3
- * todoist.rubyforge.com
4
-
5
- == DESCRIPTION:
6
-
7
- A gem to provide a simple API for interacting with the todoist.com task manager
8
- website. This should not be confused with the previous todoist gem released by
9
- the same author and then removed.
10
-
11
- It should soon function a lot better, and with a much saner interface, and
12
- without the need to explicitly pass collections around and such.
13
-
14
- == FEATURES/PROBLEMS:
15
-
16
- * FIX (list of features or problems)
17
-
18
- == SYNOPSIS:
19
-
20
- FIX (code sample of usage)
21
-
22
- == REQUIREMENTS:
23
-
24
- * json gem
25
-
26
- == INSTALL:
27
-
28
- Very simple
29
-
30
- sudo gem install todoist
31
-
32
- == LICENSE:
33
-
34
- (The MIT License)
35
-
36
- Copyright (c) 2008 Jonathan Stott
37
-
38
- Permission is hereby granted, free of charge, to any person obtaining
39
- a copy of this software and associated documentation files (the
40
- 'Software'), to deal in the Software without restriction, including
41
- without limitation the rights to use, copy, modify, merge, publish,
42
- distribute, sublicense, and/or sell copies of the Software, and to
43
- permit persons to whom the Software is furnished to do so, subject to
44
- the following conditions:
45
-
46
- The above copyright notice and this permission notice shall be
47
- included in all copies or substantial portions of the Software.
48
-
49
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
50
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
51
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
52
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
53
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
54
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
55
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,73 +0,0 @@
1
- require 'todoist/version'
2
-
3
- AUTHOR = 'Jonathan Stott' # can also be an array of Authors
4
- EMAIL = "jonathan.stott@gmail.com"
5
- DESCRIPTION = "A gem which provides an interface for interacting with the todoist.com service."
6
- GEM_NAME = 'todoist' # what ppl will type to install your gem
7
- RUBYFORGE_PROJECT = 'todoist' # The unix name for your project
8
- HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
9
- DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
10
- EXTRA_DEPENDENCIES = [
11
- ['json', '>= 1.1.2']
12
- ] # An array of rubygem dependencies [name, version]
13
-
14
- @config_file = "~/.rubyforge/user-config.yml"
15
- @config = nil
16
- RUBYFORGE_USERNAME = "unknown"
17
- def rubyforge_username
18
- unless @config
19
- begin
20
- @config = YAML.load(File.read(File.expand_path(@config_file)))
21
- rescue
22
- puts <<-EOS
23
- ERROR: No rubyforge config file found: #{@config_file}
24
- Run 'rubyforge setup' to prepare your env for access to Rubyforge
25
- - See http://newgem.rubyforge.org/rubyforge.html for more details
26
- EOS
27
- exit
28
- end
29
- end
30
- RUBYFORGE_USERNAME.replace @config["username"]
31
- end
32
-
33
-
34
- REV = nil
35
- # UNCOMMENT IF REQUIRED:
36
- # REV = YAML.load(`svn info`)['Revision']
37
- VERS = Todoist::VERSION::STRING + (REV ? ".#{REV}" : "")
38
- RDOC_OPTS = ['--quiet', '--title', 'todoist documentation',
39
- "--opname", "index.html",
40
- "--line-numbers",
41
- "--main", "README.rdoc",
42
- "--inline-source"]
43
-
44
- class Hoe
45
- def extra_deps
46
- @extra_deps.reject! { |x| Array(x).first == 'hoe' }
47
- @extra_deps
48
- end
49
- end
50
-
51
- # Generate all the Rake tasks
52
- # Run 'rake -T' to see list of generated tasks (from gem root directory)
53
- $hoe = Hoe.new(GEM_NAME, VERS) do |p|
54
- p.developer(AUTHOR, EMAIL)
55
- p.description = DESCRIPTION
56
- p.summary = DESCRIPTION
57
- p.url = HOMEPATH
58
- p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
59
- p.test_globs = ["test/**/test_*.rb"]
60
- p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
61
-
62
- # == Optional
63
- p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
64
- p.extra_deps = EXTRA_DEPENDENCIES
65
-
66
- #p.spec_extras = {} # A hash of extra values to set in the gemspec.
67
- end
68
-
69
- CHANGES = $hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
70
- PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
71
- $hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
72
- $hoe.rsync_args = '-av --delete --ignore-errors'
73
- $hoe.spec.post_install_message = File.open(File.dirname(__FILE__) + "/../PostInstall.txt").read rescue ""
@@ -1,15 +0,0 @@
1
- require 'fileutils'
2
- include FileUtils
3
-
4
- require 'rubygems'
5
- %w[rake hoe newgem rubigen].each do |req_gem|
6
- begin
7
- require req_gem
8
- rescue LoadError
9
- puts "This Rakefile requires the '#{req_gem}' RubyGem."
10
- puts "Installation: gem install #{req_gem} -y"
11
- exit
12
- end
13
- end
14
-
15
- $:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
@@ -1,109 +0,0 @@
1
-
2
- module Todoist
3
- ##
4
- # It is the connection module's responsibility to make all requests to the
5
- # todoist API, and to deserialize the response into a Hash. Before any
6
- # requests are made to the todoist service, the connection information should
7
- # be provided via the setup method.
8
- module Connection
9
-
10
- @@url_base = 'todoist.com'
11
- @@api_base = '/API'
12
- @@is_set_up = false
13
-
14
- ##
15
- #
16
- # This method should be called before all others to initialize the
17
- # variables needed for any API requests, the API key and if the account is
18
- # premium or not. No actual request is made at this stage.
19
- #
20
- # @param [String] api_key The todoist API key, findable in your preferences
21
- # @param [Boolean] premium Is the account premium? If set to true, API
22
- # requests are made via https. Not required and
23
- # defaults to false.
24
- #
25
- def self.setup(api_key, premium = false)
26
- @@is_set_up = true
27
- @@api_key = api_key
28
- @@premium = premium
29
- end
30
-
31
- ##
32
- #
33
- # Instantiates and makes a query to the given API method with the provided
34
- # request keys.
35
- #
36
- # The response is parsed from the JSON to native ruby objects as appropriate
37
- #
38
- # @param [String] api_method The API method to call. Must be supplied.
39
- # @param [Hash] keys An array of keys to be included in the URL.
40
- # This shouldn't include the token
41
- #
42
- # @return [Hash] The response, parsed from the JSON
43
- #
44
- # @raise [NotSetupError] The connection has not been set up
45
- # @raise [TokenNotCorrect] The server returned a message indicating a bad
46
- # token was sent
47
- # @raise [InvalidAPICall] The request was made to an invalid API address
48
- # @raise [BadResponse] The server didn't return a 200 (and wasn't a bad
49
- # token or a 404)
50
- #
51
- def self.api_request(api_method, keys={})
52
- raise(NotSetupError, "Call Todoist::Connection.setup before making any API requests") unless @@is_set_up
53
-
54
- # first, construct our URL string
55
- request = construct_request_string(api_method, keys)
56
-
57
- # next, make our request
58
- response = make_api_request(request)
59
-
60
- return JSON.parse(response)
61
- end
62
-
63
- protected
64
-
65
- # constructs a request string from the method and the keys passed in, adding
66
- # the token
67
- def self.construct_request_string(api_method, keys={})
68
- # convert our hash of keys into an appropriate array.
69
- urlized_keys = jsonized_url_array(keys)
70
- urlized_keys.unshift "token=#{@@api_key}"
71
-
72
- return "#{@@api_base}/#{api_method}?#{urlized_keys.join('&')}"
73
- end
74
-
75
- # converts the keys to a JSONized array, and CGI escapes them
76
- def self.jsonized_url_array(keys={})
77
- array = keys.inject([]) do |array, h|
78
- jsonized = h[1].to_json
79
- escaped = CGI.escape(jsonized)
80
- array << "#{h[0]}=#{escaped}"
81
- end
82
- return array
83
- end
84
-
85
- # makes a request from the todoist API
86
- def self.make_api_request(request)
87
- port = (@@premium) ? 443 : 80
88
- http = Net::HTTP.new(@@url_base, port)
89
- http.use_ssl = @@premium
90
-
91
- new_request = Net::HTTP::Get.new(request)
92
-
93
- # actually make our request!
94
- response = http.request(new_request)
95
-
96
- if response.code == '200'
97
- return response.body
98
- else
99
- if response.code == '404'
100
- raise InvalidAPICall
101
- elsif response.code == '500' && response.body =~ /Token not correct!/
102
- raise TokenNotCorrect
103
- else
104
- raise(BadResponse,"#{response.code} - #{response.body})")
105
- end
106
- end
107
- end
108
- end
109
- end