twido 0.0.1.beta

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,112 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>
7
+ Top Level Namespace
8
+
9
+ &mdash; Documentation by YARD 0.8.3
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ hasFrames = window.top.frames.main ? true : false;
19
+ relpath = '';
20
+ framesUrl = "frames.html#!" + escape(window.location.href);
21
+ </script>
22
+
23
+
24
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
25
+
26
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
27
+
28
+
29
+ </head>
30
+ <body>
31
+ <div id="header">
32
+ <div id="menu">
33
+
34
+ <a href="_index.html">Index</a> &raquo;
35
+
36
+
37
+ <span class="title">Top Level Namespace</span>
38
+
39
+
40
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
41
+ </div>
42
+
43
+ <div id="search">
44
+
45
+ <a class="full_list_link" id="class_list_link"
46
+ href="class_list.html">
47
+ Class List
48
+ </a>
49
+
50
+ <a class="full_list_link" id="method_list_link"
51
+ href="method_list.html">
52
+ Method List
53
+ </a>
54
+
55
+ <a class="full_list_link" id="file_list_link"
56
+ href="file_list.html">
57
+ File List
58
+ </a>
59
+
60
+ </div>
61
+ <div class="clear"></div>
62
+ </div>
63
+
64
+ <iframe id="search_frame"></iframe>
65
+
66
+ <div id="content"><h1>Top Level Namespace
67
+
68
+
69
+
70
+ </h1>
71
+
72
+ <dl class="box">
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+ </dl>
82
+ <div class="clear"></div>
83
+
84
+ <h2>Defined Under Namespace</h2>
85
+ <p class="children">
86
+
87
+
88
+ <strong class="modules">Modules:</strong> <span class='object_link'><a href="Twido.html" title="Twido (module)">Twido</a></span>
89
+
90
+
91
+
92
+
93
+ </p>
94
+
95
+
96
+
97
+
98
+
99
+
100
+
101
+
102
+
103
+ </div>
104
+
105
+ <div id="footer">
106
+ Generated on Mon Dec 17 21:39:20 2012 by
107
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
108
+ 0.8.3 (ruby-1.9.3).
109
+ </div>
110
+
111
+ </body>
112
+ </html>
@@ -0,0 +1,33 @@
1
+ # Copyright 2012 Cody Finn
2
+ # This file is part of Twido.
3
+ #
4
+ # Twido is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # Twido is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with Twido. If not, see <http://www.gnu.org/licenses/>.
16
+
17
+
18
+ require 'aruba/cucumber'
19
+ require 'methadone/cucumber'
20
+
21
+ ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
22
+ LIB_DIR = File.join(File.expand_path(File.dirname(__FILE__)),'..','..','lib')
23
+
24
+ Before do
25
+ # Using "announce" causes massive warnings on 1.9.2
26
+ @puts = true
27
+ @original_rubylib = ENV['RUBYLIB']
28
+ ENV['RUBYLIB'] = LIB_DIR + File::PATH_SEPARATOR + ENV['RUBYLIB'].to_s
29
+ end
30
+
31
+ After do
32
+ ENV['RUBYLIB'] = @original_rubylib
33
+ end
@@ -0,0 +1,86 @@
1
+ # Copyright 2012 Cody Finn
2
+ # This file is part of Twido.
3
+ #
4
+ # Twido is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # Twido is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with Twido. If not, see <http://www.gnu.org/licenses/>.
16
+
17
+ module Twido
18
+ module Authentication
19
+ USER_CONFIG_PATH = File.expand_path('~/.twido.conf')
20
+
21
+ # Public: Checks to see if the config file exists on the user's home folder.
22
+ # Returns true or false
23
+ # Examples
24
+ #
25
+ # self.config_exists?
26
+ # #=> true
27
+ #
28
+ # self.config_exists?
29
+ # #=> false
30
+ def self.config_exists?
31
+ File.exist?(USER_CONFIG_PATH)
32
+ end
33
+
34
+ # Public: Writes the user's twitter login credentials to the config file on the user's home folder.
35
+ # Returns nil
36
+ # credentials - The user's twitter log in credentials.
37
+ # Examples
38
+ #
39
+ # credentials = {consumer_key:'23459878923'...}
40
+ # self.write_credentials_to_config(credentials)
41
+ # #=> nil
42
+ def self.write_credentials_to_config(credentials)
43
+ File.open(USER_CONFIG_PATH, 'w') { |file| file.puts(credentials.to_yaml) }
44
+ end
45
+
46
+ # Public: Loads the user's twitter credentials from the config file on the user's home folder.
47
+ # Returns a hash filled with the credentials.
48
+ # Examples
49
+ #
50
+ # self.load_credentials()
51
+ # # => {consumer_key:'23459878923'...}
52
+
53
+ def self.load_credentials()
54
+ hash = YAML.load_file(USER_CONFIG_PATH)
55
+ end
56
+
57
+ # Public: Creates a new Twitter::Client with the users credentials
58
+ # Returns a Twitter::Client
59
+ # Examples
60
+ #
61
+ # self.authenticate()
62
+ # # => Twitter::Client
63
+
64
+ def self.authenticate
65
+ if self.config_exists?
66
+ if twitter_client = Twitter::Client.new(self.load_credentials())
67
+ twitter_client
68
+ else
69
+ abort 'ERROR: Error authenticating your account, run setup to reconfigure'
70
+ end
71
+ else
72
+ abort 'ERROR: You have not setup twido yet, run twido setup to configure it.'
73
+ end
74
+ end
75
+
76
+ # Public: makes a task done by deleting the tweet it came from
77
+ # Returns nil
78
+ # Examples
79
+ #
80
+ # self.complete_task(tweet)
81
+ # => nil
82
+ def self.complete_task(tweet)
83
+ Twitter::Client.new.status_destroy(id)
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,19 @@
1
+ # Copyright 2012 Cody Finn
2
+ # This file is part of Twido.
3
+ #
4
+ # Twido is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # Twido is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with Twido. If not, see <http://www.gnu.org/licenses/>.
16
+
17
+ module Twido
18
+ VERSION = "0.0.1.beta"
19
+ end
data/lib/twido.rb ADDED
@@ -0,0 +1,149 @@
1
+ # Copyright 2012 Cody Finn
2
+ # This file is part of Twido.
3
+ #
4
+ # Twido is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # Twido is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with Twido. If not, see <http://www.gnu.org/licenses/>.
16
+
17
+ require "twido/version"
18
+ require "twitter"
19
+ require "twido/authentication"
20
+ require "highline/import"
21
+
22
+ module Twido
23
+ # Public: authenticates the user using the authenticate method of the Authentication module
24
+ # Returns a Twitter::Client
25
+ # Examples
26
+ #
27
+ # self.authenticate
28
+ # # => Twitter::Client
29
+ def self.authenticate
30
+ @twitter_client = Twido::Authentication.authenticate
31
+ end
32
+
33
+ # Public: propts the user to set up thier account with the information needed to register thier app
34
+ # Returns nil
35
+ # Examples
36
+ def self.setup
37
+ messege=<<-MESSEGE
38
+ Welcome! Before you can use Twido, you'll first need to register an
39
+ application with Twitter. Just follow the steps below:
40
+ 1. Sign in to the Twitter Developer site and click
41
+ "Create a new application".
42
+ 2. Complete the required fields and submit the form.
43
+ Note: Your application must have a unique name.
44
+ We recommend: "<your handle>/t".
45
+ 3. Go to the Settings tab of your application, and change the
46
+ Access setting to "Read, Write and Access direct messages".
47
+ 4. Go to the Details tab to view the consumer key and secret,
48
+ which you'll need to copy and paste below when prompted.
49
+ MESSEGE
50
+
51
+ user_info = {}
52
+
53
+ puts messege
54
+ user_info[:consumer_key] = ask("Enter consumer key: ") { |q| q.echo = true }
55
+ user_info[:consumer_secret] = ask("Enter consumer secret: ") { |q| q.echo = true }
56
+ user_info[:oauth_token] = ask("Enter Oauth token: ") { |q| q.echo = true }
57
+ user_info[:oauth_token_secret] = ask("Enter Oauth token secret: ") { |q| q.echo = true}
58
+
59
+ Authentication.write_credentials_to_config(user_info)
60
+ end
61
+
62
+ # Public: shows the user the top 10 most recent posts containing "#todo" asks if they completed any tasks if so then it runs them through the complete method
63
+ # Returns an array of tweets, or a messege either confriming completion or confriming no comletion
64
+ # Examples
65
+ #
66
+ # self.list
67
+ # # => [0] task #todo
68
+ # [1] task 2 # todo
69
+ # Did you complete a task?:
70
+ # # => y
71
+ # => TASK COMPLETED
72
+ # self.list
73
+ # # => [0] task #todo
74
+ # [1] task 2 # todo
75
+ # Did you complete a task?:
76
+ # # => n
77
+ # # => Have a good and productive day!
78
+ # self.list
79
+ # # => [0] task #todo
80
+ # [1] task 2 # todo
81
+ # Did you complete a task?:
82
+ # # => g
83
+ # # => TASK ERROR: ACTION NOT RECONIZED
84
+ def self.list(tweets = self.build_list)
85
+ tweets.each_with_index { |tweet, index| puts "[#{index}] #{tweet.text}" }
86
+ end
87
+
88
+ # Public: removes a task from the user's to do list by deleting the tweet and confirming
89
+ # Returns a string stating if task was completed or not
90
+ # Examples
91
+ #
92
+ # self.complete
93
+ # # => [0] Task #todo
94
+ # [1] Task2 #todo
95
+ # Enter task ID:
96
+ # 1
97
+ # Are you sure you completed this task?:
98
+ # y
99
+ # TASK COMPLETED
100
+ # self.complete
101
+ # # => [0] Task #todo
102
+ # [1] Task2 #todo
103
+ # Enter task ID:
104
+ # 0
105
+ # Are you sure you completed this task?:
106
+ # n
107
+ # Have a good and productive day!
108
+ def self.complete
109
+ twitter_client = Authentication.authenticate
110
+ user = twitter_client.user.screen_name
111
+ tweets = self.build_list
112
+ self.list
113
+ complete_index = ask("Enter task ID: ")
114
+ complete = Integer(complete_index)
115
+ tweet_id = tweets[complete].id
116
+ confirm = ask("Are you sure you completed this task?: ")
117
+ case confirm.downcase.to_sym
118
+ when :no, :n
119
+ puts "Have a good and productive day!"
120
+ when :yes, :y
121
+ twitter_client.status_destroy(tweet_id)
122
+ puts "TASK COMPLETED"
123
+ end
124
+ end
125
+
126
+ # Public: adds a task to the user's todo list by tweeting a tweet that the user defines and automaticly adds the "#todo" to the end
127
+ # Returns nil
128
+ # Examples
129
+ #
130
+ # self.task
131
+ # # => What do you have to do?:
132
+ # task
133
+ def self.task
134
+ twitter_client = Authentication.authenticate
135
+ task = ask("What do you have to do?: ") + " #todo"
136
+ twitter_client.update(task)
137
+ end
138
+
139
+ # private: Gets a lsit of tweets with hash tag #todo
140
+ # Retruns Array of tweets
141
+ # Examples
142
+ # self.build_list
143
+ # # => [tweet1, tweet2, ...]
144
+ def self.build_list(count = 10)
145
+ twitter_client = Authentication.authenticate
146
+ user = twitter_client.user.screen_name
147
+ twitter_client.search("#todo", count: count, from:user).statuses
148
+ end
149
+ end
data/twido.gemspec ADDED
@@ -0,0 +1,42 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ # Copyright 2012 Cody Finn
4
+ # This file is part of Twido.
5
+ #
6
+ # Twido is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # Twido is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with Twido. If not, see <http://www.gnu.org/licenses/>.
18
+
19
+ lib = File.expand_path('../lib', __FILE__)
20
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
21
+ require 'twido/version'
22
+
23
+ Gem::Specification.new do |gem|
24
+ gem.name = "twido"
25
+ gem.version = Twido::VERSION
26
+ gem.authors = ["Cody Finn"]
27
+ gem.email = ["finnmann13@gmail.com"]
28
+ gem.description = %q{A command line tool that can update and manage todo list on twitter.}
29
+ gem.summary = %q{Twitter backed CLI to do list.}
30
+ gem.homepage = ""
31
+
32
+ gem.files = `git ls-files`.split($/)
33
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
34
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
35
+ gem.require_paths = ["lib"]
36
+ gem.add_development_dependency('rdoc')
37
+ gem.add_development_dependency('aruba')
38
+ gem.add_development_dependency('rake', '~> 0.9.2')
39
+ gem.add_dependency('methadone', '~> 1.2.3')
40
+ gem.add_dependency('twitter', '~> 4.4.1')
41
+ gem.add_dependency('highline', '~> 1.6.15')
42
+ end
metadata ADDED
@@ -0,0 +1,175 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: twido
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.beta
5
+ prerelease: 6
6
+ platform: ruby
7
+ authors:
8
+ - Cody Finn
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-04-14 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rdoc
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: aruba
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rake
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 0.9.2
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.9.2
62
+ - !ruby/object:Gem::Dependency
63
+ name: methadone
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 1.2.3
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 1.2.3
78
+ - !ruby/object:Gem::Dependency
79
+ name: twitter
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: 4.4.1
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 4.4.1
94
+ - !ruby/object:Gem::Dependency
95
+ name: highline
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: 1.6.15
102
+ type: :runtime
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 1.6.15
110
+ description: A command line tool that can update and manage todo list on twitter.
111
+ email:
112
+ - finnmann13@gmail.com
113
+ executables:
114
+ - twido
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - .gitignore
119
+ - .yardoc/checksums
120
+ - .yardoc/object_types
121
+ - .yardoc/objects/root.dat
122
+ - .yardoc/proxy_types
123
+ - COPYING
124
+ - Gemfile
125
+ - Gemfile.lock
126
+ - README.md
127
+ - Rakefile
128
+ - bin/twido
129
+ - doc/Twido.html
130
+ - doc/Twido/Authentication.html
131
+ - doc/_index.html
132
+ - doc/class_list.html
133
+ - doc/css/common.css
134
+ - doc/css/full_list.css
135
+ - doc/css/style.css
136
+ - doc/file.README.html
137
+ - doc/file_list.html
138
+ - doc/frames.html
139
+ - doc/index.html
140
+ - doc/js/app.js
141
+ - doc/js/full_list.js
142
+ - doc/js/jquery.js
143
+ - doc/method_list.html
144
+ - doc/top-level-namespace.html
145
+ - features/support/env.rb
146
+ - lib/twido.rb
147
+ - lib/twido/authentication.rb
148
+ - lib/twido/version.rb
149
+ - twido.gemspec
150
+ homepage: ''
151
+ licenses: []
152
+ post_install_message:
153
+ rdoc_options: []
154
+ require_paths:
155
+ - lib
156
+ required_ruby_version: !ruby/object:Gem::Requirement
157
+ none: false
158
+ requirements:
159
+ - - ! '>='
160
+ - !ruby/object:Gem::Version
161
+ version: '0'
162
+ required_rubygems_version: !ruby/object:Gem::Requirement
163
+ none: false
164
+ requirements:
165
+ - - ! '>'
166
+ - !ruby/object:Gem::Version
167
+ version: 1.3.1
168
+ requirements: []
169
+ rubyforge_project:
170
+ rubygems_version: 1.8.23
171
+ signing_key:
172
+ specification_version: 3
173
+ summary: Twitter backed CLI to do list.
174
+ test_files:
175
+ - features/support/env.rb