boxnet 0.0.3 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module Boxnet
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.5"
3
3
  end
data/lib/boxnet.rb CHANGED
@@ -5,6 +5,7 @@ require 'file_node'
5
5
  require 'file_tree'
6
6
  require 'folder'
7
7
  require 'file'
8
+ require 'ticket'
8
9
 
9
10
  module Boxnet
10
11
  class Client
@@ -17,7 +18,8 @@ module Boxnet
17
18
  end
18
19
 
19
20
  def self.get_ticket
20
- get(@@URL + "?api_key=#{@@API_KEY}&action=get_ticket")
21
+ data = get(@@URL + "?api_key=#{@@API_KEY}&action=get_ticket")
22
+ Ticket.new(data)
21
23
  end
22
24
 
23
25
  def self.get_auth_url_for_ticket(ticket)
data/lib/result.rb CHANGED
@@ -4,7 +4,9 @@ module Boxnet
4
4
 
5
5
  def initialize(raw_result)
6
6
  @raw_result = raw_result
7
- @file_tree = Boxnet::FileTree.new(raw_result)
7
+ unless status == "Wrong input"
8
+ @file_tree = Boxnet::FileTree.new(raw_result)
9
+ end
8
10
  end
9
11
 
10
12
  def status
data/lib/ticket.rb ADDED
@@ -0,0 +1,15 @@
1
+ module Boxnet
2
+ class Ticket
3
+ attr :ticket, :status
4
+
5
+ def initialize(data)
6
+ @ticket = data["response"]["ticket"]
7
+ @status = data["response"]["status"]
8
+ end
9
+
10
+ def url
11
+ "https://www.box.net/api/1.0/auth/#{@ticket}"
12
+ end
13
+
14
+ end
15
+ end
data/spec/boxnet_spec.rb CHANGED
@@ -8,7 +8,7 @@ describe Boxnet do
8
8
  describe "get ticket" do
9
9
  context "no API key" do
10
10
  before(:each) do
11
- Boxnet.API_KEY = ""
11
+ Boxnet::Client.API_KEY = ""
12
12
  @result = Boxnet::Client.get_ticket
13
13
  end
14
14
  it { @result.should_not be_nil }
@@ -17,7 +17,7 @@ describe Boxnet do
17
17
 
18
18
  context "invalid API key" do
19
19
  before(:each) do
20
- Boxnet.API_KEY = "bad_api_key"
20
+ Boxnet::Client.API_KEY = "bad_api_key"
21
21
  @result = Boxnet::Client.get_ticket
22
22
  end
23
23
  it { @result.should_not be_nil }
@@ -27,6 +27,8 @@ describe Boxnet do
27
27
  context "valid API key" do
28
28
  before(:each) do
29
29
  @result = Boxnet::Client.get_ticket
30
+ puts "ticket"
31
+ puts @result.inspect
30
32
  end
31
33
  it { @result.should_not be_nil }
32
34
  it { @result["response"]["status"].should == "get_ticket_ok" }
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe "get account tree" do
4
+ context "valid ticket" do
5
+ before(:each) do
6
+ Boxnet::Client.API_KEY = "m4o9591n3z2k41gks0gr69mayvfbg6gz"
7
+ ticket = "1csa8hpmko9z838m7s76qbqrmrv0bk0q"
8
+ @result = Boxnet::Client.get_auth_token(ticket)
9
+ end
10
+ it { @result.should_not be_nil }
11
+ it { @result["response"]["status"].should == "get_auth_token_ok" }
12
+ it { @result["response"]["auth_token"].should_not be_nil }
13
+ it { @result["response"]["user"].should_not be_nil }
14
+ end
15
+ end
@@ -0,0 +1,10 @@
1
+ require 'spec_helper'
2
+
3
+ describe "get account tree" do
4
+ before(:each) do
5
+ Boxnet::Client.API_KEY = "m4o9591n3z2k41gks0gr69mayvfbg6gz"
6
+ @ticket = Boxnet::Client.get_ticket
7
+ end
8
+
9
+ it { @ticket.should_not be_nil }
10
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: boxnet
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.3
5
+ version: 0.0.5
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jonathan Birkholz
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-11-18 00:00:00 Z
13
+ date: 2011-11-21 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
@@ -67,8 +67,11 @@ files:
67
67
  - lib/file_tree.rb
68
68
  - lib/folder.rb
69
69
  - lib/result.rb
70
+ - lib/ticket.rb
70
71
  - spec/boxnet_spec.rb
71
72
  - spec/get_account_file_tree_spec.rb
73
+ - spec/get_auth_token_spec.rb
74
+ - spec/get_ticket_spec.rb
72
75
  - spec/spec_helper.rb
73
76
  homepage: ""
74
77
  licenses: []
@@ -100,4 +103,6 @@ summary: Ruby gem for Box.net REST Api
100
103
  test_files:
101
104
  - spec/boxnet_spec.rb
102
105
  - spec/get_account_file_tree_spec.rb
106
+ - spec/get_auth_token_spec.rb
107
+ - spec/get_ticket_spec.rb
103
108
  - spec/spec_helper.rb