ex_ua 0.0.1 → 0.0.2

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/README.md ADDED
@@ -0,0 +1,20 @@
1
+ Description
2
+ ===========
3
+
4
+ ex_ua library gives you some API to access http://ex.ua/
5
+
6
+ Install
7
+ =======
8
+
9
+ `gem install ex_ua`
10
+
11
+ Example usage
12
+ =============
13
+
14
+
15
+ require 'ex_ua'
16
+ client = ExUA::Client.new
17
+ base_categories = client.base_categories('ru') # Gives you array of all base categories for a given language
18
+ category = base_categories.first # Select first category (usually video)
19
+ sub_categories = category.categories
20
+
@@ -1,7 +1,7 @@
1
1
  module ExUA
2
2
  # Represents a category
3
3
  class Category
4
- attr_reader :id,:parent
4
+ attr_reader :id,:parent, :url
5
5
 
6
6
  # @params[ExUA::Client] ex_ua client
7
7
  # @params[Fixnum] id Category id
@@ -31,6 +31,16 @@ module ExUA
31
31
  @name ||= page_content.root.xpath("//meta[@name='title']/@content").first.value
32
32
  end
33
33
 
34
+ # Category description
35
+ def description
36
+ @description ||= page_content.root.xpath("//meta[@name='description']/@content").first.value
37
+ end
38
+
39
+ # Category picture
40
+ def picture
41
+ @picture ||= page_content.root.xpath("//link[@rel='image_src']/@href").first.value.split("?").first
42
+ end
43
+
34
44
  # List of subcategories
35
45
  def categories
36
46
  page_content.search('table.include_0 a b').map do |link|
@@ -75,12 +85,11 @@ module ExUA
75
85
  links.each { |link|
76
86
  case link.attributes["href"].value
77
87
  when %r{^/get/}
78
- item.download_url = link.attributes["href"].value
79
88
  item.title = link.attributes["title"].value
80
- item.id = item.download_url.match(%r{^/get/(\d+)})[1].to_i
89
+ item.id = link.attributes["href"].value.match(%r{^/get/(\d+)})[1].to_i
81
90
  when %r{^/load}
82
91
  item.additional_servers||=[]
83
- item.additional_servers << link.attributes["title"].value
92
+ item.additional_servers << link.attributes["title"].value.match(%r{fs(\d+)})[1].to_i
84
93
  end
85
94
  }
86
95
  end
@@ -105,4 +114,4 @@ module ExUA
105
114
  @prev_url||=page_content.root.xpath("//link[@rel='prev']/@href").first.tap{|a| a.value if a}
106
115
  end
107
116
  end
108
- end
117
+ end
data/lib/ex_ua/item.rb CHANGED
@@ -1,5 +1,14 @@
1
1
  module ExUA
2
2
  # Download item
3
- class Item < Struct.new(:id, :title, :download_url, :additional_servers)
3
+ class Item < Struct.new(:id, :title, :additional_servers)
4
+ # Actual download url.
5
+ # You can add ?fs_id=server_id param to download form #additional_servers
6
+ def download_url
7
+ "#{ExUA::BASE_URL}#{url}"
8
+ end
9
+
10
+ def url
11
+ @url ||= "/load/#{self.id}"
12
+ end
4
13
  end
5
- end
14
+ end
data/lib/ex_ua/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module ExUa
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ex_ua
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-29 00:00:00.000000000 Z
12
+ date: 2011-12-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &2151875460 !ruby/object:Gem::Requirement
16
+ requirement: &2151873700 !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: :development
23
23
  prerelease: false
24
- version_requirements: *2151875460
24
+ version_requirements: *2151873700
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: mechanize
27
- requirement: &2151874060 !ruby/object:Gem::Requirement
27
+ requirement: &2151870560 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2151874060
35
+ version_requirements: *2151870560
36
36
  description: Ruby API for ex.ua
37
37
  email:
38
38
  - refresh.xss@gmail.com
@@ -42,6 +42,7 @@ extra_rdoc_files: []
42
42
  files:
43
43
  - .gitignore
44
44
  - Gemfile
45
+ - README.md
45
46
  - Rakefile
46
47
  - ex_ua.gemspec
47
48
  - lib/ex_ua.rb