wikinotizie 1.0.0

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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/wikinotizie.rb +42 -0
  3. metadata +57 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a89dda423c4dfd94357145b6c81b207491e7384ebacad5d47ac723fad31721d2
4
+ data.tar.gz: ce14ef299a8f1ac85ca7de12cf6b6f51cdd78c0674677be3f37c7e72e1fc58f2
5
+ SHA512:
6
+ metadata.gz: 16f4170ec9da38bdb179df434a480c52c197ca0afad2bd471cb6dd9b3c89962e9aefa7a676f4d4293acc5453712cfe259979b46b8307d27de1f8054c2f60e6c7
7
+ data.tar.gz: bda2abe687fd10abb8bc545222afae874f4f0ceff672a63501daef71f0d55e7e3b07642c53d149cae01eac26befea7baa00f6440ff84ae145a5a327a39405853
@@ -0,0 +1,42 @@
1
+ require 'date'
2
+ class Wikinotizie
3
+ def self.parse(content)
4
+ if content.match?(/{{data\|(\d{1,2} \w+ \d{4})\|(lunedì|martedì|mercoledì|giovedì|venerdì|sabato|domenica)}}/i)
5
+ match = content.match(/{{data\|(\d{1,2} \w+ \d{4})\|(lunedì|martedì|mercoledì|giovedì|venerdì|sabato|domenica)}}/i)
6
+ data = match[1]
7
+ giorno = match[2]
8
+ with_luogo = false
9
+ elsif content.match?(/{{luogodata\|luogo=([a-zA-ZÀ-ÖØ-öø-ÿ]+)\|1=(lunedì|martedì|mercoledì|giovedì|venerdì|sabato|domenica)\|data=(\d{1,2} \w+ \d{4})}}/i)
10
+ match = content.match(/{{luogodata\|luogo=([a-zA-ZÀ-ÖØ-öø-ÿ]+)\|1=(lunedì|martedì|mercoledì|giovedì|venerdì|sabato|domenica)\|data=(\d{1,2} \w+ \d{4})}}/i)
11
+ luogo = match[1]
12
+ giorno = match[2]
13
+ data = match[3]
14
+ with_luogo = true
15
+ elsif content.match?(/{{luogodata\|(lunedì|martedì|mercoledì|giovedì|venerdì|sabato|domenica)\|luogo=([a-zA-ZÀ-ÖØ-öø-ÿ]+)\|data=(\d{1,2} \w+ \d{4})}}/i)
16
+ match = content.match(/{{luogodata\|(lunedì|martedì|mercoledì|giovedì|venerdì|sabato|domenica)\|luogo=([a-zA-ZÀ-ÖØ-öø-ÿ]+)\|data=(\d{1,2} \w+ \d{4})}}/i)
17
+ luogo = match[2]
18
+ giorno = match[1]
19
+ data = match[3]
20
+ with_luogo = true
21
+ elsif content.match?(/{{data\|1=(\d{1,2} \w+ \d{4})\|2=(lunedì|martedì|mercoledì|giovedì|venerdì|sabato|domenica)}}/i)
22
+ match = content.match(/{{data\|1=(\d{1,2} \w+ \d{4})\|2=(lunedì|martedì|mercoledì|giovedì|venerdì|sabato|domenica)}}/i)
23
+ data = match[1]
24
+ giorno = match[2]
25
+ with_luogo = false
26
+ else
27
+ @funzionante = false
28
+ end
29
+ months = [["gennaio", "Jan"], ["febbraio", "Feb"], ["marzo", "Mar"], ["aprile", "Apr"], ["maggio", "May"], ["giugno", "Jun"], ["luglio", "Jul"], ["agosto", "Aug"], ["settembre", "Sep"], ["ottobre", "Oct"], ["novembre", "Nov"], ["dicembre", "Dec"]]
30
+ months.each do |italian_month, english_month|
31
+ if data.match? italian_month
32
+ @rubydate = DateTime.parse(data.gsub(/#{italian_month}/, english_month))
33
+ end
34
+ end
35
+ unless @funzionante == false
36
+ return [content, match, data, giorno, @rubydate, with_luogo] if with_luogo == false
37
+ return [content, match, data, giorno, @rubydate, with_luogo, luogo] if with_luogo == true
38
+ else
39
+ return false
40
+ end
41
+ end
42
+ end
metadata ADDED
@@ -0,0 +1,57 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wikinotizie
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Ferdinando Traversa
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-11-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: date
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description:
28
+ email:
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - lib/wikinotizie.rb
34
+ homepage: https://github.com/ferdi2005/wikinotizie
35
+ licenses:
36
+ - MIT
37
+ metadata: {}
38
+ post_install_message:
39
+ rdoc_options: []
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ requirements: []
53
+ rubygems_version: 3.0.8
54
+ signing_key:
55
+ specification_version: 4
56
+ summary: Parser di date per il template data di Wikinotizie
57
+ test_files: []