officepod 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6de93154e36e994448ce973761527fa299bbda34
4
- data.tar.gz: f67266cba6a495996a8042d414f8acf41fd5bd23
3
+ metadata.gz: 7dc250293cdb6eb462abcf93ffce5471abad7200
4
+ data.tar.gz: e47f0c29771c73d0f5c4593524bae54fdd1713ed
5
5
  SHA512:
6
- metadata.gz: b797312b7d74d07d2c6851120a5a8ea7850eeff186551febc5f1aaa4053fe83cb49b5d4e97dd37e1c197bf02d05fd2287dd7af32f76f57f156ec61a6ae3b2649
7
- data.tar.gz: b9d44f53c85adf70a44f57a5981afd4c7f6f11fa244e8386d1df30261133d93b03ef69adbf667f483aeb050804008188e9d50dc35be70dd6731070890faa6c93
6
+ metadata.gz: 465f6f230bf90bb6a582116f3b0cf506c5e36d2e50c90bd580a22cf1fa0ada6ef593eb0937fc043fa58bc625bca2c3ba3f2a9520f8049561690aff5a52003913
7
+ data.tar.gz: 7baadc282cc5119fa66abed0e2803028071c61ffb0c3a8c9860d167992c68f3bf6d38eb095d5c9da2a334194d186722fd2a4995525f678ff8e84059d3b91ed88
@@ -1,13 +1,13 @@
1
1
  module Officepod
2
2
  module Authentication
3
3
  def self.included(base)
4
- base.extend ClassMethods
4
+ base.send :include, InstanceMethods
5
5
  end
6
6
 
7
- module ClassMethods
7
+ module InstanceMethods
8
8
  def login
9
9
  validates_body
10
- response = self.post(@END_POINT, @options)
10
+ response = self.class.post(@END_POINT, @options)
11
11
  result = JSON.parse(response.parsed_response)
12
12
  cookie = get_cookie(response.headers["set-cookie"])
13
13
  result["SID"] = cookie
@@ -17,7 +17,7 @@ module Officepod
17
17
  end
18
18
 
19
19
  def logout
20
- response = self.delete(@END_POINT, @options)
20
+ response = self.class.delete(@END_POINT, @options)
21
21
  response.parsed_response
22
22
  end
23
23
 
@@ -1,10 +1,10 @@
1
1
  module Officepod
2
2
  module Bookmark
3
3
  def self.included(base)
4
- base.extend ClassMethods
4
+ base.send :include, InstanceMethods
5
5
  end
6
6
 
7
- module ClassMethods
7
+ module InstanceMethods
8
8
  end
9
9
 
10
10
  end
@@ -1,10 +1,10 @@
1
1
  module Officepod
2
2
  module File
3
3
  def self.included(base)
4
- base.extend ClassMethods
4
+ base.send :include, InstanceMethods
5
5
  end
6
6
 
7
- module ClassMethods
7
+ module InstanceMethods
8
8
  end
9
9
 
10
10
  end
@@ -1,10 +1,10 @@
1
1
  module Officepod
2
2
  module Room
3
3
  def self.included(base)
4
- base.extend ClassMethods
4
+ base.send :include, InstanceMethods
5
5
  end
6
6
 
7
- module ClassMethods
7
+ module InstanceMethods
8
8
  end
9
9
 
10
10
  end
@@ -1,10 +1,10 @@
1
1
  module Officepod
2
2
  module Storage
3
3
  def self.included(base)
4
- base.extend ClassMethods
4
+ base.send :include, InstanceMethods
5
5
  end
6
6
 
7
- module ClassMethods
7
+ module InstanceMethods
8
8
  def storage_auth_list(lang: nil, cookie: nil)
9
9
  command = __method__.to_s
10
10
  @options[:command] = command
@@ -14,7 +14,7 @@ module Officepod
14
14
  }
15
15
  @options[:headers]["Cookie"] = "SID=#{cookie}"
16
16
  ipv4_pattern = /(?:[0-9]{1,3}\.){3}[0-9]{1,3}/
17
- response = self.post("/server/request.php", @options)
17
+ response = self.class.post("/server/request.php", @options)
18
18
  result = JSON.parse(response.parsed_response)
19
19
  result["storagelist"].each do |e|
20
20
  e["type"] = "FTP" if e["title"].include? "FTP"
@@ -1,3 +1,3 @@
1
1
  module Officepod
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
data/lib/officepod.rb CHANGED
@@ -1,35 +1,39 @@
1
1
  module Officepod
2
2
  def self.included(base)
3
- base.extend ClassMethods
4
- base.class_eval do
3
+ base.send :include, InstanceMethods
4
+
5
+ base.instance_eval do
5
6
  include HTTParty
6
7
  include Authentication
7
8
  include Storage
8
9
  include Bookmark
9
10
  include File
10
11
  include Room
12
+ include Helper
11
13
 
12
14
  base_uri "http://g4m.lalaworks.com"
13
- @END_POINT = "/server/request.php"
14
-
15
- @options = {
16
- command: "",
17
- headers: {
18
- "User-Agent" => "Gate4Mobile",
19
- "Content-Type" => "application/x-www-form-urlencoded",
20
- "Accept" => "application/json",
21
- "Cookie" => ""
22
- },
23
- body: {}
24
- }
25
15
  end
26
16
 
27
- base.instance_eval do
28
- extend Helper
17
+ base.class_eval do
18
+ def initialize
19
+ @END_POINT = "/server/request.php"
20
+
21
+ @options = {
22
+ command: "",
23
+ headers: {
24
+ "User-Agent" => "Gate4Mobile",
25
+ "Content-Type" => "application/x-www-form-urlencoded",
26
+ "Accept" => "application/json",
27
+ "Cookie" => ""
28
+ },
29
+ body: {}
30
+ }
31
+ end
29
32
  end
33
+
30
34
  end
31
35
 
32
- module ClassMethods
36
+ module InstanceMethods
33
37
  def officepod(options={command: "", body: "", cookie: ""})
34
38
  @options[:command] = options[:command]
35
39
  @options[:body] = options[:body]
@@ -3,21 +3,36 @@ require 'spec_helper'
3
3
  describe Officepod do
4
4
  before(:each) do
5
5
  @klass = Class.new
6
- @klass.instance_eval { include Officepod }
6
+ @klass.class_eval { include Officepod }
7
+ @instance = @klass.new
7
8
  end
8
9
 
9
- it "has base_uri from HTTParty" do
10
- expect(@klass.respond_to?(:base_uri)).to eq true
11
- end
10
+ context "Officepod class" do
11
+ it "has base_uri as a class method" do
12
+ expect(@klass.respond_to?(:base_uri)).to eq true
13
+ end
12
14
 
13
- it "has officepod method" do
14
- expect(@klass.respond_to?(:offciepod)).not_to be nil
15
+ it "has officepod as an instance method" do
16
+ expect(@klass.instance_methods.include?(:officepod)).to eq true
17
+ end
18
+
19
+ it "has login as an instance method" do
20
+ expect(@klass.instance_methods.include?(:login)).to eq true
21
+ end
22
+
23
+ it "has @options instance variable" do
24
+ expect(@instance.instance_variable_defined?(:@options)).to eq true
25
+ end
26
+
27
+ it "has @END_POINT instance variable" do
28
+ expect(@instance.instance_variable_defined?(:@END_POINT)).to eq true
29
+ end
15
30
  end
16
31
 
17
32
  context "when login" do
18
33
  response = nil
19
34
 
20
- it "should be success" do
35
+ it "should return hash resonse" do
21
36
  options = {
22
37
  command: "login",
23
38
  headers: {
@@ -36,12 +51,12 @@ describe Officepod do
36
51
  cookie: ""
37
52
  }
38
53
 
39
- response = @klass.officepod(options)
54
+ response = @instance.officepod(options)
40
55
 
41
56
  expect(response.class).to eq Hash
42
57
  end
43
58
 
44
- it "should have storage list" do
59
+ it "should have storage list as array" do
45
60
  expect(response["storage_list"].class).to eq Array
46
61
  end
47
62
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: officepod
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yoochan Seo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-19 00:00:00.000000000 Z
11
+ date: 2016-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json