rrline 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.rdoc +42 -0
- data/bin/rr +9 -0
- data/data/keys.yaml +3 -0
- data/lib/rr/application.rb +129 -0
- data/lib/rr/version.rb +3 -0
- data/lib/rr.rb +9 -0
- metadata +51 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d9fc098e54d70e863d9b9ffc14b3e9dfdb4f88dc
|
4
|
+
data.tar.gz: 4809e2b695484a2de42ff313b67f4000928a5b64
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6cbb3b66d537e83f8d6903684183a359c72840d80a205ad2780a48a54879e0867cd00a2605537fbb586c09d40526bd044ea1ce306d9c679d564e36ec06106eec
|
7
|
+
data.tar.gz: 45064fc31f82bd823c5b88046233ad195dcd599b8a4759a9f6d597936e9664f83e93c212d715ec0d03b08d69604cfe90c7dc6cebeeb1eda691af440e9e35b2b9
|
data/README.rdoc
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
= Runrun.it Command Line Tool
|
2
|
+
|
3
|
+
== Description
|
4
|
+
|
5
|
+
This is a very simple tool to make the process of list and hit play on your tasks easier.
|
6
|
+
|
7
|
+
== Installation
|
8
|
+
|
9
|
+
Install as a RubyGem:
|
10
|
+
|
11
|
+
$ gem install rrline
|
12
|
+
|
13
|
+
And install dependencies:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
== Usage
|
18
|
+
|
19
|
+
=== Basics
|
20
|
+
|
21
|
+
To use rr, first, store your API keys: (you can find them on you Profile page)
|
22
|
+
|
23
|
+
rr -k <app-key>,<user-token>
|
24
|
+
|
25
|
+
To list your fist 10 tasks:
|
26
|
+
|
27
|
+
rr -l
|
28
|
+
|
29
|
+
To hit play on your first task just:
|
30
|
+
|
31
|
+
rr -p
|
32
|
+
|
33
|
+
To start working in another task:
|
34
|
+
|
35
|
+
rr -p <task-id>
|
36
|
+
|
37
|
+
|
38
|
+
If rr command is not available across the folders, you can add the executable to the shell's lookup path:
|
39
|
+
|
40
|
+
export PATH=/Users/<your user>/<folder where downloaded code is>/rr/bin:$PATH
|
41
|
+
|
42
|
+
|
data/bin/rr
ADDED
data/data/keys.yaml
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
module RR
|
2
|
+
class Application
|
3
|
+
|
4
|
+
def initialize(argv)
|
5
|
+
@working_dir = File.dirname(__FILE__)
|
6
|
+
@params = parse_options(argv)
|
7
|
+
@filename = "#{@working_dir}/../../data/keys.yaml"
|
8
|
+
@tasks_url = 'https://secure.runrun.it/api/v1.0/tasks'
|
9
|
+
HTTPI.adapter = :curb
|
10
|
+
HTTPI.log = false
|
11
|
+
end
|
12
|
+
|
13
|
+
def run
|
14
|
+
case @params.command
|
15
|
+
when :help
|
16
|
+
puts "\n##### This is a Runrun.it Command Line Tool #####\n\n
|
17
|
+
-k\tStore your keys: -k <app-key>,<user-token>\n
|
18
|
+
-l\tList tasks opened for you\n
|
19
|
+
-p\tStart working on a task. Default the top priority. You can specify task_id for other tasks: rr -p <task_id>"
|
20
|
+
when :keys
|
21
|
+
Dir.mkdir "#{@working_dir}/../../data"
|
22
|
+
File.open(@filename, 'w') { |file| file.write(YAML::dump(@params.keys)) }
|
23
|
+
puts "Storing keys..."
|
24
|
+
when :list
|
25
|
+
headers = get_headers
|
26
|
+
query = {:responsible_id => 'me', :sort => 'queue_position', :sortDir => 'asc', :page => 1, :limit => 10}
|
27
|
+
|
28
|
+
result = make_request(@tasks_url, query, headers, :get)
|
29
|
+
|
30
|
+
result.each do |task|
|
31
|
+
print "#%6s - #{task['title']}" % task['id']
|
32
|
+
if task['is_working_on']
|
33
|
+
print Rainbow(" [Working]").green
|
34
|
+
else
|
35
|
+
print Rainbow(" [Paused!]").red if task['queue_position'] == 1
|
36
|
+
end
|
37
|
+
print "\n"
|
38
|
+
end
|
39
|
+
when :play
|
40
|
+
puts "Playing..."
|
41
|
+
if @params.task
|
42
|
+
task_to_play = @params.task
|
43
|
+
else
|
44
|
+
task_to_play = get_first_task_id
|
45
|
+
end
|
46
|
+
play(task_to_play)
|
47
|
+
end
|
48
|
+
|
49
|
+
puts "\nDone!"
|
50
|
+
end
|
51
|
+
|
52
|
+
def parse_options(argv)
|
53
|
+
options = OpenStruct.new
|
54
|
+
|
55
|
+
OptionParser.new do |opts|
|
56
|
+
|
57
|
+
opts.on('-h','Shows help screen') do
|
58
|
+
options.command = :help
|
59
|
+
end
|
60
|
+
|
61
|
+
opts.on('-k', '--keys App-key, User-token', Array, 'Save keys') do |keys|
|
62
|
+
options.command = :keys
|
63
|
+
options.keys = keys
|
64
|
+
end
|
65
|
+
|
66
|
+
opts.on('-p', '--play [TASK_ID]', Integer, 'Play task') do |task|
|
67
|
+
options.command = :play
|
68
|
+
options.task = task
|
69
|
+
end
|
70
|
+
|
71
|
+
opts.on('-l','List tasks...') do
|
72
|
+
options.command = :list
|
73
|
+
end
|
74
|
+
|
75
|
+
end.parse!
|
76
|
+
|
77
|
+
options
|
78
|
+
end
|
79
|
+
|
80
|
+
def get_stored_keys
|
81
|
+
if File.exist?(@filename)
|
82
|
+
keys = YAML::load(File.open(@filename))
|
83
|
+
return {:app_key => keys[0], :user_token => keys[1]}
|
84
|
+
else
|
85
|
+
puts "ERROR: You need to store your credentials first. Use rr -k <app-key>,<user-token>"
|
86
|
+
exit
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def make_request(url, query_body, headers, type)
|
91
|
+
request = HTTPI::Request.new
|
92
|
+
request.url = url
|
93
|
+
request.query = query_body if type == :get
|
94
|
+
request.body = query_body if type == :post
|
95
|
+
request.headers = headers
|
96
|
+
|
97
|
+
begin
|
98
|
+
buffer = HTTPI.send(type, request)
|
99
|
+
rescue => error
|
100
|
+
puts "ERROR: Trying to connect to Runrun.it API\n"
|
101
|
+
puts error
|
102
|
+
exit
|
103
|
+
end
|
104
|
+
|
105
|
+
return JSON.parse(buffer.body) unless buffer.body.strip.empty?
|
106
|
+
end
|
107
|
+
|
108
|
+
def get_first_task_id
|
109
|
+
headers = get_headers
|
110
|
+
query = {:responsible_id => 'me', :sort => 'queue_position', :sortDir => 'asc', :page => 1, :limit => 1}
|
111
|
+
|
112
|
+
result = get_request(@tasks_url, query, headers)
|
113
|
+
return result.first['id']
|
114
|
+
end
|
115
|
+
|
116
|
+
def play(task_id)
|
117
|
+
headers = get_headers
|
118
|
+
play_url = @tasks_url + "/#{task_id}/play"
|
119
|
+
result = make_request(play_url, nil, headers, :post)
|
120
|
+
end
|
121
|
+
|
122
|
+
def get_headers
|
123
|
+
keys = get_stored_keys
|
124
|
+
headers = {:content_type => :json, :accept => :json, :'app-key' => "#{keys[:app_key]}", :'user-token' => "#{keys[:user_token]}"}
|
125
|
+
headers
|
126
|
+
end
|
127
|
+
|
128
|
+
end
|
129
|
+
end
|
data/lib/rr/version.rb
ADDED
data/lib/rr.rb
ADDED
metadata
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rrline
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Fransky
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-09-09 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: iVery simple application for Runrun.it Command Line Tool
|
14
|
+
email:
|
15
|
+
- franklin@runrun.it
|
16
|
+
executables:
|
17
|
+
- rr
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- bin/rr
|
22
|
+
- lib/rr/application.rb
|
23
|
+
- lib/rr/version.rb
|
24
|
+
- lib/rr.rb
|
25
|
+
- data/keys.yaml
|
26
|
+
- README.rdoc
|
27
|
+
homepage: http://runrun.it
|
28
|
+
licenses: []
|
29
|
+
metadata: {}
|
30
|
+
post_install_message:
|
31
|
+
rdoc_options: []
|
32
|
+
require_paths:
|
33
|
+
- lib
|
34
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: 1.9.2
|
39
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 1.3.6
|
44
|
+
requirements: []
|
45
|
+
rubyforge_project: rrline
|
46
|
+
rubygems_version: 2.1.11
|
47
|
+
signing_key:
|
48
|
+
specification_version: 4
|
49
|
+
summary: Simple application for RR Command Line Tool
|
50
|
+
test_files: []
|
51
|
+
has_rdoc:
|