ugigi 0.0.1 → 0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ ## 0.1
2
+ * Ugigi#total_countを追加。ヒット数を返します。
3
+
4
+ ## 0.0.1
5
+ * 最初のリリース!
data/README.md CHANGED
@@ -24,6 +24,9 @@ Ugigi Wrapper for Ruby 1.9.x
24
24
  novels.each do |novel|
25
25
  puts novel.title
26
26
  end
27
+
28
+ # "にとり"が文章中に含まれているSSの数を持ってくる
29
+ puts Ugigi.total_count(:free => "にとり")
27
30
 
28
31
  ## Contributing
29
32
 
@@ -11,9 +11,10 @@ require "ugigi/parser"
11
11
 
12
12
  module Ugigi
13
13
  BASE_URL = "http://ugigi.dvrdns.org/api/search/list.json"
14
+ BASE_URL_NOAPI = "http://ugigi.dvrdns.org/search"
15
+
16
+ protected
14
17
 
15
- # @param [Hash] parameter
16
- # @return [String] URL Serialized parameters
17
18
  def self.serialize_parameter parameter
18
19
  return "" unless parameter.class == Hash
19
20
  ant = Hash.new
@@ -24,8 +25,15 @@ module Ugigi
24
25
  return param ? param : ""
25
26
  end
26
27
 
28
+ public
29
+
27
30
  def self.search(args={})
28
31
  parser = Parser.new
29
32
  parser.fetch(args)
30
33
  end
34
+
35
+ def self.total_count(args)
36
+ parser = Parser.new
37
+ parser.total_count(args)
38
+ end
31
39
  end
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  module Ugigi
2
4
  class Parser
3
5
  def initialize
@@ -16,5 +18,11 @@ module Ugigi
16
18
  end
17
19
  return indexes
18
20
  end
21
+
22
+ def total_count(args)
23
+ params = Ugigi.serialize_parameter(args)
24
+ page = @agent.get(URI.join(BASE_URL_NOAPI, params))
25
+ return page.search(%{div[@class="info"]}).children[0].text.strip.split("/")[1].to_i
26
+ end
19
27
  end
20
28
  end
@@ -1,3 +1,3 @@
1
1
  module Ugigi
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ugigi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: '0.1'
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: 2012-07-10 00:00:00.000000000Z
12
+ date: 2012-07-11 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mechanize
16
- requirement: &70314480816760 !ruby/object:Gem::Requirement
16
+ requirement: &70279330494180 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70314480816760
24
+ version_requirements: *70279330494180
25
25
  description: Ugigi Wrapper for Ruby
26
26
  email:
27
27
  - oame@oameya.com
@@ -30,6 +30,7 @@ extensions: []
30
30
  extra_rdoc_files: []
31
31
  files:
32
32
  - .gitignore
33
+ - CHANGELOG.md
33
34
  - Gemfile
34
35
  - LICENSE
35
36
  - README.md