goot 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 787fb23a81fec2cda86a0b9f54bb8bf353a1728b
4
+ data.tar.gz: e712af29ab09479a004ff1f00e0d2d566bffb8a6
5
+ SHA512:
6
+ metadata.gz: cce86e953ed2548fc6fdcd8ae3cb523be8b8d71e48150e859293b9563243258b386db96e27f55a45a3d05786e7f42934dadf38ce7119e9414161dccbd0d0e492
7
+ data.tar.gz: b3121239463c237759df547bb11c6ac6ea3042794d36011939c57d4112e693c4e255a3c80f74f4af8459bc16676ea248dd6b9f65aa64142fe475baaca054603a
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in gtasks.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Conner McDaniel
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,25 @@
1
+ # goot
2
+
3
+ A command-line interface to Google Tasks das ist goot.
4
+
5
+ ## Installation
6
+
7
+ gem install goot
8
+
9
+ ## Usage
10
+
11
+ # Prints a summary of tasklists and their indexes
12
+ goot summary
13
+ goot s
14
+
15
+ # Lists tasks in a given list (0 by default)
16
+ goot list
17
+ goot l -l 1
18
+
19
+ # Toggle a task by index
20
+ goot toggle 3
21
+ goot t 3 -l 1
22
+
23
+ # Clear completed tasks
24
+ goot clear
25
+ goot c -l 1
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ lib = File.expand_path(File.dirname(__FILE__) + '/../lib')
4
+ $LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)
5
+
6
+ require 'thor'
7
+ require 'goot'
8
+
9
+ GoogleTasks::CLI.start
@@ -0,0 +1 @@
1
+ {"installed":{"auth_uri":"https://accounts.google.com/o/oauth2/auth","client_secret":"NQ_V2kO5wb23htl2UajEaTbv","token_uri":"https://accounts.google.com/o/oauth2/token","client_email":"","redirect_uris":["urn:ietf:wg:oauth:2.0:oob","oob"],"client_x509_cert_url":"","client_id":"757292415321.apps.googleusercontent.com","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs"}}
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'goot/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "goot"
8
+ spec.version = GoogleTasks::VERSION
9
+ spec.authors = ["Conner McDaniel"]
10
+ spec.email = ["connermcd@gmail.com"]
11
+ spec.summary = %q{A command-line interface to Google Tasks das ist goot.}
12
+ spec.description = %q{A command-line interface to Google Tasks das ist goot.}
13
+ spec.homepage = "https://github.com/connermcd/goot"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "thor", "~> 0.19.0"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.5"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "pry"
26
+ spec.add_development_dependency "rspec", "~> 2.5"
27
+ end
@@ -0,0 +1,3 @@
1
+ require 'goot/version'
2
+ require 'goot/google_api'
3
+ require 'goot/cli'
@@ -0,0 +1,78 @@
1
+ class GoogleTasks::CLI < Thor
2
+ include Thor::Actions
3
+
4
+ def initialize(*args)
5
+ super
6
+ @api = GoogleTasks::GoogleAPI.new
7
+ end
8
+
9
+ desc "list", "Displays available tasks for a given tasklist"
10
+ method_option :aliases => "l"
11
+ method_option :tasklist, :aliases => "-l", :type => :numeric, :default => 0
12
+ def list
13
+ tab = ' '
14
+ depths = {}
15
+
16
+ tasklist = @api.get_tasklist(options[:tasklist])
17
+ tasks = @api.get_tasks(tasklist)
18
+
19
+ say tasklist.title, :green
20
+ tasks.each.with_index do |task, i|
21
+ next if task.deleted
22
+
23
+ status = task.status == 'completed' ? '✓' : '▢'
24
+
25
+ depth = 1
26
+ depth += depths[task.parent] if depths.include? task.parent
27
+ depths[task.id] = depth
28
+
29
+ say "#{tab * depth} #{status} #{i}: #{task.title}"
30
+ say "#{tab * (depth + 1)} Notes: #{task.notes}", :yellow if task.notes
31
+ end
32
+ end
33
+
34
+ desc "summary", "Displays all task lists and their task counts"
35
+ method_option :aliases => "s"
36
+ def summary
37
+ @api.get_lists.each.with_index do |tasklist, i|
38
+ tasks = @api.get_tasks(tasklist)
39
+ say "#{i} #{tasklist.title} (#{tasks.size})"
40
+ end
41
+ end
42
+
43
+ desc "toggle", "Toggles a given task"
44
+ method_option :aliases => "t"
45
+ method_option :tasklist, :aliases => "-l", :type => :numeric, :default => 0
46
+ def toggle(index)
47
+ tasklist = @api.get_tasklist(options[:tasklist])
48
+ tasks = @api.get_tasks(tasklist).map(&:to_hash)
49
+
50
+ task = tasks[index.to_i]
51
+ task['status'] = task['completed'].nil? ? 'completed' : 'needsAction'
52
+ task.delete 'completed'
53
+ @api.update_task(tasklist, task)
54
+
55
+ toggle_children = lambda do |parent|
56
+ children = tasks.select { |t| t['parent'] == parent['id'] }
57
+ children.each do |t|
58
+ t['status'] = task['status']
59
+ t.delete 'completed'
60
+ @api.update_task(tasklist, t)
61
+ toggle_children.call(t)
62
+ end
63
+ end
64
+ toggle_children.call(task)
65
+
66
+ invoke :list, [], :tasklist => options[:tasklist]
67
+ end
68
+
69
+ desc "clear", "Clears completed tasks"
70
+ method_option :aliases => "c"
71
+ method_option :tasklist, :aliases => "-l", :type => :numeric, :default => 0
72
+ def clear
73
+ tasklist = @api.get_tasklist(options[:tasklist])
74
+ @api.clear_tasks(tasklist)
75
+
76
+ invoke :list, [], :tasklist => options[:tasklist]
77
+ end
78
+ end
@@ -0,0 +1,81 @@
1
+ require 'google/api_client'
2
+ require 'google/api_client/client_secrets'
3
+ require 'google/api_client/auth/file_storage'
4
+ require 'google/api_client/auth/installed_app'
5
+
6
+ class GoogleTasks::GoogleAPI
7
+
8
+ CREDENTIAL_STORE = File.join(GoogleTasks::CONFIG_DIR, 'gtasks-oauth2.json')
9
+ CLIENT_SECRET_STORE = File.join(GoogleTasks::GEM_ROOT, 'data', 'client_secrets.json')
10
+
11
+ UNCHANGED = 0
12
+ MODIFIED = 1
13
+ DELETED = 2
14
+
15
+ def initialize
16
+ client = Google::APIClient.new(
17
+ :application_name => GoogleTasks::APP_NAME,
18
+ :application_version => GoogleTasks::VERSION
19
+ )
20
+
21
+ file_storage = Google::APIClient::FileStorage.new(CREDENTIAL_STORE)
22
+
23
+ if file_storage.authorization.nil?
24
+ client_secrets = Google::APIClient::ClientSecrets.load(CLIENT_SECRET_STORE)
25
+ flow = Google::APIClient::InstalledAppFlow.new(
26
+ :client_id => client_secrets.client_id,
27
+ :client_secret => client_secrets.client_secret,
28
+ :scope => 'https://www.googleapis.com/auth/tasks'
29
+ )
30
+ client.authorization = flow.authorize(file_storage)
31
+ else
32
+ client.authorization = file_storage.authorization
33
+ end
34
+
35
+ @client = client
36
+ @api = client.discovered_api('tasks', 'v1')
37
+ end
38
+
39
+ def get_lists
40
+ @client.execute(:api_method => @api.tasklists.list).data.items
41
+ end
42
+
43
+ def get_tasklist(index)
44
+ @client.execute(
45
+ :api_method => @api.tasklists.get,
46
+ :parameters => {
47
+ :tasklist => get_lists[index].id
48
+ }
49
+ ).data
50
+ end
51
+
52
+ def get_tasks(tasklist)
53
+ @client.execute(
54
+ :api_method => @api.tasks.list,
55
+ :parameters => {
56
+ :tasklist => tasklist.id
57
+ }
58
+ ).data.items.select { |t| t.status != DELETED }
59
+ end
60
+
61
+ def update_task(tasklist, task)
62
+ @client.execute(
63
+ :api_method => @api.tasks.update,
64
+ :parameters => {
65
+ :tasklist => tasklist.id,
66
+ :task => task['id']
67
+ },
68
+ :body_object => task
69
+ )
70
+ end
71
+
72
+ def clear_tasks(tasklist)
73
+ @client.execute(
74
+ :api_method => @api.tasks.clear,
75
+ :parameters => {
76
+ :tasklist => tasklist.id
77
+ }
78
+ )
79
+ end
80
+
81
+ end
@@ -0,0 +1,8 @@
1
+ module GoogleTasks
2
+ APP_NAME = 'goot'
3
+ VERSION = '0.0.10'
4
+
5
+ GEM_ROOT = File.expand_path('../../..', __FILE__)
6
+ CONFIG_DIR = File.join(ENV['HOME'], '.goot')
7
+ Dir.mkdir(CONFIG_DIR, 0700) if !Dir.exists?(CONFIG_DIR)
8
+ end
metadata ADDED
@@ -0,0 +1,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: goot
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.10
5
+ platform: ruby
6
+ authors:
7
+ - Conner McDaniel
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.19.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.19.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.5'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.5'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2.5'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.5'
83
+ description: A command-line interface to Google Tasks das ist goot.
84
+ email:
85
+ - connermcd@gmail.com
86
+ executables:
87
+ - goot
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - Gemfile
93
+ - LICENSE.txt
94
+ - README.md
95
+ - Rakefile
96
+ - bin/goot
97
+ - data/client_secrets.json
98
+ - goot.gemspec
99
+ - lib/goot.rb
100
+ - lib/goot/cli.rb
101
+ - lib/goot/google_api.rb
102
+ - lib/goot/version.rb
103
+ homepage: https://github.com/connermcd/goot
104
+ licenses:
105
+ - MIT
106
+ metadata: {}
107
+ post_install_message:
108
+ rdoc_options: []
109
+ require_paths:
110
+ - lib
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ requirements: []
122
+ rubyforge_project:
123
+ rubygems_version: 2.2.2
124
+ signing_key:
125
+ specification_version: 4
126
+ summary: A command-line interface to Google Tasks das ist goot.
127
+ test_files: []