dotplan 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### 0.0.3
2
+
3
+ * working put/get plans
4
+
1
5
  ### 0.0.2
2
6
 
3
7
  * minor tweaks in auth
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dotplan (0.0.1)
4
+ dotplan (0.0.2)
5
5
  colorize
6
6
  hashie
7
7
  json
data/bin/dotplan CHANGED
@@ -18,7 +18,7 @@ if ARGV.first && commands.keys.include?(ARGV.first.downcase)
18
18
  end
19
19
  else
20
20
  begin
21
- puts "todo".green
21
+ DotPlan::Command::Default.run()
22
22
  rescue => e
23
23
  puts e
24
24
  end
@@ -0,0 +1,50 @@
1
+ module DotPlan
2
+ module Command
3
+ class Default
4
+ def self.run(*args)
5
+ begin
6
+ credentials = JSON.parse(File.read(DotPlan::CREDENTIALS_PATH))
7
+ rescue => e
8
+ raise "There was a problem reading your credentials. Run dotplan auth first.".red
9
+ end
10
+ username = credentials["username"]
11
+ password = credentials["password"]
12
+ date = Date.today.strftime("%m-%d-%Y")
13
+ url = "#{DotPlan::DOTPLAN_URL}/user/#{username}/plan/#{date}"
14
+ resource = RestClient::Resource.new(url, :Password => password)
15
+ begin
16
+ response = resource.get(:Password => password)
17
+ rescue RestClient::ResourceNotFound => e
18
+ begin
19
+ response = resource.put(nil, :Password => password)
20
+ rescue => e
21
+ response = JSON.parse(e.response)
22
+ raise response["error"].red
23
+ end
24
+ rescue => e
25
+ response = JSON.parse(e.response)
26
+ raise response["error"].red
27
+ end
28
+
29
+ plan = JSON.parse(response)
30
+ puts plan
31
+
32
+ File.open(DotPlan::TEMP_PATH, "w") do |f|
33
+ f.write(plan["text"])
34
+ end
35
+
36
+ result = system("$EDITOR #{DotPlan::TEMP_PATH}")
37
+
38
+ if result
39
+ new_text = File.read DotPlan::TEMP_PATH
40
+ begin
41
+ resource = RestClient::Resource.new("#{url}?text=#{new_text}", :Password => password)
42
+ response = resource.put nil, :Password => password
43
+ rescue => e
44
+ puts e.message
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -1,4 +1,5 @@
1
1
  module DotPlan
2
2
  DOTPLAN_URL = ENV['DOTPLAN_URL'] || "http://dotplanstream.herokuapp.com"
3
3
  CREDENTIALS_PATH = File.join(ENV["HOME"], ".dotplan", "credentials.json")
4
+ TEMP_PATH = File.join(ENV["HOME"], ".dotplan", "temp")
4
5
  end
@@ -1,3 +1,3 @@
1
1
  module DotPlan
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dotplan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-03-12 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
16
- requirement: &70232884581560 !ruby/object:Gem::Requirement
16
+ requirement: &70279403426660 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70232884581560
24
+ version_requirements: *70279403426660
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: colorize
27
- requirement: &70232884581140 !ruby/object:Gem::Requirement
27
+ requirement: &70279403426240 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70232884581140
35
+ version_requirements: *70279403426240
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rest-client
38
- requirement: &70232884580720 !ruby/object:Gem::Requirement
38
+ requirement: &70279403425820 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70232884580720
46
+ version_requirements: *70279403425820
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: hashie
49
- requirement: &70232884580300 !ruby/object:Gem::Requirement
49
+ requirement: &70279403425400 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70232884580300
57
+ version_requirements: *70279403425400
58
58
  description: The simplest way to manage your .plans
59
59
  email:
60
60
  - dpaola2@gmail.com