meta_information 1.0.2 → 1.0.3
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 +4 -4
- data/.rspec +1 -0
- data/lib/meta_information.rb +4 -1
- data/lib/meta_information/version.rb +2 -2
- data/meta_information.gemspec +3 -3
- data/spec/config.rb +4 -0
- data/spec/lib/meta_information_spec.rb +8 -0
- data/spec/shared_stuff.rb +88 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b5bf1a3b6fb3556b421442c3c44c31254346237
|
4
|
+
data.tar.gz: 70c4c218d1e0392fa3a91f24bc645fc86dc81fbf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e3df2df309dc7ce8f22ef7cb628d7eee89019ad77a767c146abd769cea662deccf53ab7ce2d333f0bc1a035516bc8bf29c249e881ef79bb773218b8d3478f94
|
7
|
+
data.tar.gz: 9074069607699feb799ec04861ea08a7d857a2490d973162a78ca6f804bc506d084bd9b1d4e2c127ab926aab72caeb5e00fe7cc876191763d444cd8b58cc40f3
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/lib/meta_information.rb
CHANGED
@@ -28,7 +28,8 @@ module MetaInformation
|
|
28
28
|
type: node_type(node),
|
29
29
|
name: node['name'],
|
30
30
|
property: node['property'],
|
31
|
-
content: node['content']
|
31
|
+
content: node['content'],
|
32
|
+
itemprop: node['itemprop']
|
32
33
|
)
|
33
34
|
end
|
34
35
|
array
|
@@ -39,6 +40,8 @@ module MetaInformation
|
|
39
40
|
'name'
|
40
41
|
elsif !node['property'].nil?
|
41
42
|
'property'
|
43
|
+
elsif !node['itemprop'].nil?
|
44
|
+
'itemprop'
|
42
45
|
else
|
43
46
|
''
|
44
47
|
end
|
@@ -1,3 +1,3 @@
|
|
1
1
|
module MetaInformation
|
2
|
-
VERSION = '1.0.
|
3
|
-
end
|
2
|
+
VERSION = '1.0.3'
|
3
|
+
end
|
data/meta_information.gemspec
CHANGED
@@ -4,9 +4,9 @@ require "meta_information/version"
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = 'meta_information'
|
6
6
|
s.version = MetaInformation::VERSION
|
7
|
-
s.date = '2017-
|
7
|
+
s.date = '2017-07-31'
|
8
8
|
s.summary = 'MetaInformation - Simple gem for parsing meta information'
|
9
|
-
s.description = 'Simple gem for parsing meta information from websites. It scan all meta-tags by name or property attributes.'
|
9
|
+
s.description = 'Simple gem for parsing meta information from websites. It scan all meta-tags by name, itemprop or property attributes.'
|
10
10
|
s.author = 'Vladislav Kopylov'
|
11
11
|
s.email = 'kopylov.vlad@gmail.com'
|
12
12
|
s.files = `git ls-files`.split("\n")
|
@@ -14,4 +14,4 @@ Gem::Specification.new do |s|
|
|
14
14
|
s.license = 'MIT'
|
15
15
|
|
16
16
|
s.add_dependency('nokogiri', '~> 1.7', '>= 1.7.0')
|
17
|
-
end
|
17
|
+
end
|
data/spec/config.rb
ADDED
@@ -147,6 +147,14 @@ RSpec.describe 'MetaInformation' do
|
|
147
147
|
expect(MetaInformation.send(:node_type, node)).to eq('property')
|
148
148
|
end
|
149
149
|
|
150
|
+
it 'must return property' do
|
151
|
+
document = Nokogiri::HTML(
|
152
|
+
'<meta itemprop="description" content="description" />'
|
153
|
+
)
|
154
|
+
node = document.css('meta').first
|
155
|
+
expect(MetaInformation.send(:node_type, node)).to eq('itemprop')
|
156
|
+
end
|
157
|
+
|
150
158
|
it 'must return empty string' do
|
151
159
|
document = Nokogiri::HTML('<meta content="og_title" />')
|
152
160
|
node = document.css('meta').first
|
@@ -0,0 +1,88 @@
|
|
1
|
+
RSpec.shared_context 'shared stuff', shared_context: :metadata do
|
2
|
+
let(:default_html) do
|
3
|
+
'
|
4
|
+
<html>
|
5
|
+
<meta name="description" content="" />
|
6
|
+
<meta name="title" content="some title" />
|
7
|
+
<meta property="author" content="Bob" />
|
8
|
+
<meta property="og:title" content="og_title" />
|
9
|
+
<meta property="twitter:image" content="http://some_host.com/some_path" />
|
10
|
+
<meta property="og:locale" content="ru_RU" />
|
11
|
+
<meta property="al:ios:app_store_id" content="12345678900" />
|
12
|
+
<meta itemprop="name" content="site name"/>
|
13
|
+
<meta itemprop="description" content="site description"/>
|
14
|
+
<body>
|
15
|
+
<h1>Mr. Belvedere Fan Club</h1>
|
16
|
+
</body>
|
17
|
+
</html>
|
18
|
+
'
|
19
|
+
end
|
20
|
+
|
21
|
+
let(:default_html_meta_array) do
|
22
|
+
[
|
23
|
+
{
|
24
|
+
type: 'name',
|
25
|
+
name: 'description',
|
26
|
+
property: nil,
|
27
|
+
itemprop: nil,
|
28
|
+
content: ''
|
29
|
+
},
|
30
|
+
{
|
31
|
+
type: 'name',
|
32
|
+
name: 'title',
|
33
|
+
property: nil,
|
34
|
+
itemprop: nil,
|
35
|
+
content: 'some title'
|
36
|
+
},
|
37
|
+
{
|
38
|
+
type: 'property',
|
39
|
+
name: nil,
|
40
|
+
property: 'author',
|
41
|
+
itemprop: nil,
|
42
|
+
content: 'Bob'
|
43
|
+
},
|
44
|
+
{
|
45
|
+
type: 'property',
|
46
|
+
name: nil,
|
47
|
+
property: 'og:title',
|
48
|
+
itemprop: nil,
|
49
|
+
content: 'og_title'
|
50
|
+
},
|
51
|
+
{
|
52
|
+
type: 'property',
|
53
|
+
name: nil,
|
54
|
+
property: 'twitter:image',
|
55
|
+
itemprop: nil,
|
56
|
+
content: 'http://some_host.com/some_path'
|
57
|
+
},
|
58
|
+
{
|
59
|
+
type: 'property',
|
60
|
+
name: nil,
|
61
|
+
property: 'og:locale',
|
62
|
+
itemprop: nil,
|
63
|
+
content: 'ru_RU'
|
64
|
+
},
|
65
|
+
{
|
66
|
+
type: 'property',
|
67
|
+
name: nil,
|
68
|
+
property: 'al:ios:app_store_id',
|
69
|
+
itemprop: nil,
|
70
|
+
content: '12345678900'
|
71
|
+
},
|
72
|
+
{
|
73
|
+
type: 'itemprop',
|
74
|
+
name: nil,
|
75
|
+
property: nil,
|
76
|
+
itemprop: 'name',
|
77
|
+
content: 'site name'
|
78
|
+
},
|
79
|
+
{
|
80
|
+
type: 'itemprop',
|
81
|
+
name: nil,
|
82
|
+
property: nil,
|
83
|
+
itemprop: 'description',
|
84
|
+
content: 'site description'
|
85
|
+
}
|
86
|
+
]
|
87
|
+
end
|
88
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: meta_information
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladislav Kopylov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -31,13 +31,14 @@ dependencies:
|
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 1.7.0
|
33
33
|
description: Simple gem for parsing meta information from websites. It scan all meta-tags
|
34
|
-
by name or property attributes.
|
34
|
+
by name, itemprop or property attributes.
|
35
35
|
email: kopylov.vlad@gmail.com
|
36
36
|
executables: []
|
37
37
|
extensions: []
|
38
38
|
extra_rdoc_files: []
|
39
39
|
files:
|
40
40
|
- ".gitignore"
|
41
|
+
- ".rspec"
|
41
42
|
- ".ruby-version"
|
42
43
|
- Gemfile
|
43
44
|
- LICENSE.txt
|
@@ -45,7 +46,9 @@ files:
|
|
45
46
|
- lib/meta_information.rb
|
46
47
|
- lib/meta_information/version.rb
|
47
48
|
- meta_information.gemspec
|
49
|
+
- spec/config.rb
|
48
50
|
- spec/lib/meta_information_spec.rb
|
51
|
+
- spec/shared_stuff.rb
|
49
52
|
homepage: https://github.com/kopylovvlad/meta_information
|
50
53
|
licenses:
|
51
54
|
- MIT
|