brwiki 0.1.1 → 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cec30c75c621d162dbce60e6aa5d16bf40559c4166e540fc2b54e6b8278ebde8
4
- data.tar.gz: f1fb8636893d3a59ec6259b13c9726dc69f935672fb9322a5e772f5a5b597869
3
+ metadata.gz: bbda2f0124b6a0d7edb4dde0c04c8ea5c9b5b0cd8d74d0dc24a4e8ed4a2c03e2
4
+ data.tar.gz: de4d70362042930a449c8a4470acb7b738bde228cae9a47023ef88fbcb6b082d
5
5
  SHA512:
6
- metadata.gz: e420426e2df7f0bb8ce3d1f10305f8dbc6cd2ac8568a7ad255db7b6eb5284cf2e2d1541b50016d4891f3eb1602891068e211bc7afa002cb20e5234f87f2f5ce8
7
- data.tar.gz: 573105a1fed790e6303001535de06ccb813e5bda8b477039adf7e5a5d8c55bf4951f240423c05fc077eee09f714424918a851fa7fd0471e5782daba57268ef78
6
+ metadata.gz: b5af26b24aea235c5bc49dfff1080b83c59fe60e310b3fd3dc6ae7623eb3ae7ae3d30d0a02391e145d86ed9e9b3b11619e2af4c8481cf677c187eec46e20046b
7
+ data.tar.gz: 87742555089a7ceb05b97a7845f4f7fc186cc55f3f54f8ecb7d68eca71b374388c4299b1b992139da6bd051977442b67d1a6d297fcefe1e54f3967bcccf88950
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2022-10-20
4
+
5
+ - Initial release
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in brwiki.gemspec
6
+ #gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+ gem "nokogiri"
10
+ #gem "HTTParty"
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 TODO: Write your name
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # Brwiki
2
+
3
+ A library to scrap articles from wikipedia
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'brwiki'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install brwiki
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+
25
+ include Brwiki
26
+ puts Brwiki::search("en","juice")
27
+ ```
28
+ ## Contributing
29
+
30
+ Bug reports and pull requests are welcome on GitHub at https://github.com/luizin5/brwiki.
31
+
32
+ ## License
33
+
34
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ task default: %i[]
Binary file
data/example/ex.rb ADDED
@@ -0,0 +1,4 @@
1
+ require "brwiki"
2
+
3
+ include Brwiki
4
+ puts Brwiki::search("pt","galo")
@@ -0,0 +1,3 @@
1
+ module Brwiki
2
+ VERSION = 0.2
3
+ end
data/lib/brwiki.rb CHANGED
@@ -1,69 +1,18 @@
1
- require 'httparty'
2
- require 'nokogiri'
1
+ require "nokogiri"
2
+ require "open-uri"
3
3
 
4
- class Brwiki
4
+ module Brwiki
5
5
 
6
- extend HTTParty
7
- extend Nokogiri
8
-
9
- attr_reader :fonte
10
- attr_reader :site
11
- attr_reader :sitehtml
12
- attr_reader :lang
13
-
14
-
15
- def setpage(artigo)
16
-
17
- @lol = "https://#{@lang}.wikipedia.org"
18
-
19
- @fonte = "https://#{@lang}.m.wikipedia.org/wiki/#{artigo}"
20
-
21
- @site = HTTParty.get(@fonte)
22
-
23
- @sitehtml = Nokogiri::HTML(@site.response.body)
24
-
25
- end
26
-
27
-
28
-
29
- def setlang(idioma)
30
- @lang = idioma
31
-
32
- return "idioma selecionado #{idioma}"
33
- end
34
-
35
-
36
-
37
- def gettitle
38
- return @sitehtml.search("title").text
6
+ def search lang, pesquisa
7
+ page = Nokogiri::HTML URI::open("https://#{lang}.m.wikipedia.org/wiki/#{pesquisa}")
8
+ [page.css("h1")[0].text,
9
+ fisrt_paragraph(page.css("p").to_a)[0].text]
39
10
  end
40
11
 
41
-
42
-
43
- def getdescription(paragrafo)
44
- if paragrafo.eql?("all")
45
- return @sitehtml.search("p").text
46
- else
47
- p = @sitehtml.search("p")[paragrafo]
48
- return p.text
49
- end
12
+ private
13
+ def fisrt_paragraph x
14
+ x.reject { |y| y.attr("class") == "mw-empty-elt" }
50
15
  end
51
16
 
52
-
53
-
54
- def geturl
55
- fonte = @fonte
56
- return fonte
57
- end
58
-
59
-
60
-
61
- def getlinks(links)
62
- if links == "all"
63
- links = @sitehtml.search("a")
64
- else
65
- links = @sitehtml.search("a")[links]
66
- end
67
- return @lol + links.attr("href")
68
- end
69
17
  end
18
+
data/sig/brwiki.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module Brwiki
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata CHANGED
@@ -1,79 +1,47 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brwiki
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: '0.2'
5
5
  platform: ruby
6
6
  authors:
7
- - Luiz
7
+ - luizin5
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-13 00:00:00.000000000 Z
11
+ date: 2022-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 1.13.9
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: httparty
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: nokogiri
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: httparty
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- description: obtenha paginas do wikipedia direto em seu terminal
70
- email: luizfelip079@outlook.com
26
+ version: 1.13.9
27
+ description: a library to access articles from wikipedia
28
+ email:
29
+ - '='
71
30
  executables: []
72
31
  extensions: []
73
32
  extra_rdoc_files: []
74
33
  files:
34
+ - CHANGELOG.md
35
+ - Gemfile
36
+ - LICENSE.txt
37
+ - README.md
38
+ - Rakefile
39
+ - builds/brwiki-0.2.gem
40
+ - example/ex.rb
75
41
  - lib/brwiki.rb
76
- homepage: https://rubygems.org/gems/brwiki
42
+ - lib/brwiki/version.rb
43
+ - sig/brwiki.rbs
44
+ homepage:
77
45
  licenses:
78
46
  - MIT
79
47
  metadata:
@@ -86,15 +54,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
86
54
  requirements:
87
55
  - - ">="
88
56
  - !ruby/object:Gem::Version
89
- version: '0'
57
+ version: 2.6.0
90
58
  required_rubygems_version: !ruby/object:Gem::Requirement
91
59
  requirements:
92
60
  - - ">="
93
61
  - !ruby/object:Gem::Version
94
62
  version: '0'
95
63
  requirements: []
96
- rubygems_version: 3.3.3
64
+ rubygems_version: 3.3.7
97
65
  signing_key:
98
66
  specification_version: 4
99
- summary: wikipedia
67
+ summary: a library to access articles from wikipedia
100
68
  test_files: []