duit 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/bin/duit +30 -0
  2. metadata +46 -0
data/bin/duit ADDED
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'net/http'
4
+ require 'json'
5
+
6
+ def post token, summary
7
+ uri = URI("http://localhost:3000/items.json?auth_token=#{token}")
8
+ Net::HTTP.start(uri.host, uri.port) do |http|
9
+ request = Net::HTTP::Post.new(uri.request_uri, initheader={'Content-Type' =>'application/json'})
10
+ request.body = {"summary" => summary}.to_json
11
+
12
+ response = http.request request
13
+
14
+ puts response.code, response.message, response.body
15
+ end
16
+ end
17
+
18
+ def get_token
19
+ # read authentication token as string in first line of ~/.duitrc
20
+ file = File.open(File.expand_path('~/.duitrc'))
21
+ file.lines.first.chomp
22
+ end
23
+
24
+ if ARGV.length > 0
25
+ token = get_token
26
+ summary = ARGV.join(' ')
27
+ post token, summary
28
+ else
29
+ puts "you need to du something"
30
+ end
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: duit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Ryan Yeske
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-04-23 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Add items to Duluth's GTD inbox from the command line
15
+ email: rcyeske@gmail.com
16
+ executables:
17
+ - duit
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - bin/duit
22
+ homepage: http://ryanyeske.com
23
+ licenses: []
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ none: false
36
+ requirements:
37
+ - - ! '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ requirements: []
41
+ rubyforge_project:
42
+ rubygems_version: 1.8.21
43
+ signing_key:
44
+ specification_version: 3
45
+ summary: Command line interface to duluth
46
+ test_files: []