instapi 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/examples/bookmark.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require 'instapi'
2
2
 
3
3
  # i = Instapi.new('username', 'password')
4
- i = Instapi.new(*ARGV).login!
4
+ i = Instapi.new(*ARGV)
5
5
  i.add('https://github.com/jugyo')
@@ -1,7 +1,7 @@
1
1
  require 'instapi'
2
2
 
3
3
  # i = Instapi.new('username', 'password')
4
- i = Instapi.new(*ARGV).login!
4
+ i = Instapi.new(*ARGV)
5
5
  i.unread.each do |bookmark|
6
6
  p bookmark
7
7
  end
@@ -1,3 +1,3 @@
1
1
  class Instapi
2
- VERSION = "1.2.0"
2
+ VERSION = "1.3.0"
3
3
  end
data/lib/instapi.rb CHANGED
@@ -8,20 +8,15 @@ class Instapi
8
8
 
9
9
  def initialize(username, password)
10
10
  @username, @password = username, password
11
- self
12
11
  end
13
12
 
14
13
  def client
15
14
  return @client if @client
16
15
  @client = HTTPClient.new
16
+ @client.post("#{BASE_URL}/user/login", :username => username, :password => password)
17
17
  @client
18
18
  end
19
19
 
20
- def login!
21
- client.post("#{BASE_URL}/user/login", :username => username, :password => password)
22
- self
23
- end
24
-
25
20
  def add(url, options = {})
26
21
  get('/api/add', {:url => url, :username => username, :password => password}.merge(options))
27
22
  end
@@ -42,15 +37,15 @@ class Instapi
42
37
  get("/delete/#{id}")
43
38
  end
44
39
 
45
- def text(url)
40
+ def get(path, params = {})
41
+ client.get_content(BASE_URL + path, params)
42
+ end
43
+
44
+ def self.text(url)
46
45
  doc = Nokogiri::HTML(get("/text?u=#{url}"))
47
46
  {
48
47
  :title => doc.css('title').first.text,
49
48
  :text => doc.css('#story').first.inner_html
50
49
  }
51
50
  end
52
-
53
- def get(path, params = {})
54
- client.get_content(BASE_URL + path, params)
55
- end
56
51
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: instapi
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.2.0
5
+ version: 1.3.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - jugyo