codic_parser 0.0.2 → 0.1.0

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: f2221b126ff090bd1eea315f3899c82a66af04cc
4
- data.tar.gz: 33b75b3afd9f30f66f7846994f10a41b162a32b8
3
+ metadata.gz: 5128268128a3bfbdfe9b78c9581d86ccc2ba2445
4
+ data.tar.gz: 92bbcac3456128940b58fa9f52daffbcca228d5e
5
5
  SHA512:
6
- metadata.gz: 6774e9aa7e47631071b9ad85c541c7ab156dfddda629ce9f2653194b6f8d8c727ad56cc7b1924281b9dec9473aee50652ac141f94f987818c2eb3f078ddd31d4
7
- data.tar.gz: 8437c4b9a37373353a60d77727966f613bab753a2c70410049ba6c8a46d159c86c3e6b328f83d17f6776552c34d797a50f58b54063d7c3dd275478a11ba5424a
6
+ metadata.gz: 419256275b585ce90c6ed424a7d66cf67040313274f8b1b67c3f6f3134cca4d8c8d471dc0d346a63481da23d76146c28056d6671ab158dbf9332af2e90612c3f
7
+ data.tar.gz: cf09c6d123178db65dbd7acc6deb6d39b60655d3ca21bd4857358b6951a4a01ddd49e49dc255f3612701809f2b4f4e6653add13a3bd81fa7f79603f4459f6a12
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- codic_parser (0.0.1)
4
+ codic_parser (0.1.0)
5
5
  nokogiri (~> 1.5, >= 1.5.10)
6
6
  thor (~> 0)
7
7
 
data/README.md CHANGED
@@ -37,7 +37,7 @@ $ codic_parser browse query_string
37
37
  ```
38
38
  ## Contributing
39
39
 
40
- 1. Fork it ( http://github.com/<my-github-username>/codic_parser/fork )
40
+ 1. Fork it ( http://github.com/shoyan/codic_parser/fork )
41
41
  2. Create your feature branch (`git checkout -b my-new-feature`)
42
42
  3. Commit your changes (`git commit -am 'Add some feature'`)
43
43
  4. Push to the branch (`git push origin my-new-feature`)
@@ -6,18 +6,26 @@ module CodicParser
6
6
  option :all, :type => :boolean, :aliases => :a
7
7
  option :nodesc, :type => :boolean, :aliases => :l
8
8
  option :entryonly, :type => :boolean, :aliases => :e
9
+ option :wordlist, :type => :boolean, :aliases => :w
10
+ option :hidetranslation, :type => :boolean, :aliases => :h
9
11
  def get(word)
10
12
  @parser = CodicParser::ParserFactory.get(word)
11
13
 
14
+ if options[:all]
15
+ @parser.all(options)
16
+ exit
17
+ end
18
+
12
19
  if options[:entryonly]
13
20
  @parser.entry_list
14
- exit
15
21
  end
16
22
 
17
- @parser.word_list(options)
23
+ if options[:wordlist]
24
+ @parser.word_list(options)
25
+ end
18
26
 
19
- if options[:all]
20
- @parser.all(options)
27
+ unless options[:hidetranslation]
28
+ @parser.translation(options)
21
29
  end
22
30
  end
23
31
 
@@ -4,6 +4,10 @@ module CodicParser
4
4
  @doc = Nokogiri::HTML(open("http://codic.jp/search?q=#{URI::encode(word)}&via=is"))
5
5
  end
6
6
 
7
+ def translation(options = {})
8
+ word_list(options) unless options[:wordlist]
9
+ end
10
+
7
11
  def word_list(options = {})
8
12
  @doc.css('.translation .post a').each do |link|
9
13
  puts link.content
@@ -4,6 +4,28 @@ module CodicParser
4
4
  @doc = Nokogiri::HTML(open("http://codic.jp/search?q=#{URI::encode(word)}&via=is"))
5
5
  end
6
6
 
7
+ def translation(options= {} )
8
+ numbers = []
9
+ words = []
10
+ translations = []
11
+
12
+ @doc.css("#translations li .no").each do |link|
13
+ numbers.push(link.content)
14
+ end
15
+
16
+ @doc.css("#translations li .word-class").each do |link|
17
+ words.push(link.content)
18
+ end
19
+
20
+ @doc.css("#translations li .translated").each do |link|
21
+ translations.push(link.content)
22
+ end
23
+
24
+ numbers.each_index do |i|
25
+ puts "#{numbers[i]} #{words[i]} #{translations[i]}"
26
+ end
27
+ end
28
+
7
29
  def word_list(options= {} )
8
30
  text = []
9
31
  desc = []
@@ -34,6 +56,7 @@ module CodicParser
34
56
  end
35
57
 
36
58
  def all(options = {})
59
+ self.translation
37
60
  self.word_list(options)
38
61
  self.entry_list
39
62
  end
@@ -1,3 +1,3 @@
1
1
  module CodicParser
2
- VERSION = "0.0.2"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codic_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shohei Yamasaki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-03 00:00:00.000000000 Z
11
+ date: 2014-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler