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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/codic_parser/cli.rb +12 -4
- data/lib/codic_parser/parser/mb_parser.rb +4 -0
- data/lib/codic_parser/parser/parser.rb +23 -0
- data/lib/codic_parser/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5128268128a3bfbdfe9b78c9581d86ccc2ba2445
|
4
|
+
data.tar.gz: 92bbcac3456128940b58fa9f52daffbcca228d5e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 419256275b585ce90c6ed424a7d66cf67040313274f8b1b67c3f6f3134cca4d8c8d471dc0d346a63481da23d76146c28056d6671ab158dbf9332af2e90612c3f
|
7
|
+
data.tar.gz: cf09c6d123178db65dbd7acc6deb6d39b60655d3ca21bd4857358b6951a4a01ddd49e49dc255f3612701809f2b4f4e6653add13a3bd81fa7f79603f4459f6a12
|
data/Gemfile.lock
CHANGED
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
|
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`)
|
data/lib/codic_parser/cli.rb
CHANGED
@@ -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
|
-
|
23
|
+
if options[:wordlist]
|
24
|
+
@parser.word_list(options)
|
25
|
+
end
|
18
26
|
|
19
|
-
|
20
|
-
@parser.
|
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
|
data/lib/codic_parser/version.rb
CHANGED
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
|
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-
|
11
|
+
date: 2014-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|