beeminder 0.1.3 → 0.1.4
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.
- data/beeminder.gemspec +2 -0
- data/bin/beemind +31 -17
- data/lib/beeminder/user.rb +3 -2
- data/lib/beeminder/version.rb +1 -1
- metadata +35 -3
data/beeminder.gemspec
CHANGED
data/bin/beemind
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# coding: utf-8
|
3
3
|
|
4
|
+
require 'highline/import'
|
5
|
+
require 'trollop'
|
4
6
|
require 'yaml'
|
5
7
|
|
6
8
|
# load library
|
@@ -14,30 +16,42 @@ else
|
|
14
16
|
require 'beeminder'
|
15
17
|
end
|
16
18
|
|
17
|
-
|
18
|
-
|
19
|
+
usage = "usage: beemind goal value [comment]"
|
20
|
+
opts = Trollop::options do
|
21
|
+
banner usage
|
22
|
+
|
23
|
+
opt :config, "Path to config.", :type => :string, :default => "~/.beeminderrc"
|
24
|
+
opt :list, "List all available goals."
|
25
|
+
end
|
26
|
+
|
27
|
+
Trollop::die usage if not (2..3).include?(ARGV.size) and not opts[:list]
|
28
|
+
goal, value, comment = ARGV unless opts[:list]
|
29
|
+
|
30
|
+
opts[:config] = File.expand_path opts[:config]
|
31
|
+
|
32
|
+
if not File.exists? opts[:config]
|
19
33
|
# create config
|
20
|
-
|
21
|
-
yaml = {
|
34
|
+
auth = {
|
22
35
|
"account" => ask("Beeminder account:"),
|
23
36
|
"token" => ask("Auth token:")
|
24
37
|
}
|
25
|
-
File.open(config, "w+") {|f| YAML.dump yaml, f}
|
26
|
-
File.chmod 0600, config
|
27
|
-
puts "Written config to '#{config}.'"
|
38
|
+
File.open(opts[:config], "w+") {|f| YAML.dump yaml, f}
|
39
|
+
File.chmod 0600, opts[:config]
|
40
|
+
puts "Written config to '#{opts[:config]}.'"
|
28
41
|
end
|
29
42
|
|
30
43
|
# load config
|
31
|
-
|
44
|
+
auth = YAML.load File.open(opts[:config])
|
32
45
|
|
33
46
|
# login
|
34
|
-
bee = Beeminder::User.new
|
35
|
-
|
36
|
-
if
|
37
|
-
|
38
|
-
|
47
|
+
bee = Beeminder::User.new auth["account"], auth["token"]
|
48
|
+
|
49
|
+
if opts[:list]
|
50
|
+
# list all available goals
|
51
|
+
puts "available goals:"
|
52
|
+
goals = bee.goals.sort_by{|g| g.slug}.each do |goal|
|
53
|
+
puts " #{goal.slug} (#{goal.title})"
|
54
|
+
end
|
55
|
+
else
|
56
|
+
bee.send goal, value, comment || ""
|
39
57
|
end
|
40
|
-
|
41
|
-
goal, value, comment = ARGV
|
42
|
-
|
43
|
-
bee.send goal, value, comment || ""
|
data/lib/beeminder/user.rb
CHANGED
@@ -54,7 +54,7 @@ module Beeminder
|
|
54
54
|
# @param comment [String] Optional comment.
|
55
55
|
def send name, value, comment=""
|
56
56
|
goal = self.goal name
|
57
|
-
dp = Beeminder::Datapoint.new value
|
57
|
+
dp = Beeminder::Datapoint.new :value => value, :comment => comment
|
58
58
|
goal.add dp
|
59
59
|
end
|
60
60
|
|
@@ -108,7 +108,8 @@ module Beeminder
|
|
108
108
|
http = Net::HTTP.new(url.host, url.port)
|
109
109
|
http.read_timeout = 8640
|
110
110
|
http.use_ssl = true
|
111
|
-
|
111
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE # FIXME: actually verify
|
112
|
+
|
112
113
|
json = ""
|
113
114
|
http.start do |http|
|
114
115
|
req = case type
|
data/lib/beeminder/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beeminder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,6 +11,22 @@ bindir: bin
|
|
11
11
|
cert_chain: []
|
12
12
|
date: 2012-09-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: json
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
14
30
|
- !ruby/object:Gem::Dependency
|
15
31
|
name: highline
|
16
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -27,6 +43,22 @@ dependencies:
|
|
27
43
|
- - ~>
|
28
44
|
- !ruby/object:Gem::Version
|
29
45
|
version: '1.6'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: trollop
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '2'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2'
|
30
62
|
description: Convenient access to Beeminder's API.
|
31
63
|
email:
|
32
64
|
- mail@muflax.com
|
@@ -61,7 +93,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
61
93
|
version: '0'
|
62
94
|
segments:
|
63
95
|
- 0
|
64
|
-
hash:
|
96
|
+
hash: 867077506270084543
|
65
97
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
98
|
none: false
|
67
99
|
requirements:
|
@@ -70,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
70
102
|
version: '0'
|
71
103
|
segments:
|
72
104
|
- 0
|
73
|
-
hash:
|
105
|
+
hash: 867077506270084543
|
74
106
|
requirements: []
|
75
107
|
rubyforge_project:
|
76
108
|
rubygems_version: 1.8.23
|