apion 0.1.7 → 0.1.8

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: f482216b13883859deeed5d20f2e25e5a572815c
4
- data.tar.gz: 04e234d2036e85bdfee7772cad1fd10b033431e5
3
+ metadata.gz: f7c8924c7d6f31b3b7215d09e42dd140a0950a99
4
+ data.tar.gz: cc9bbd740ccaecbc2d2822dd91716b51556e2992
5
5
  SHA512:
6
- metadata.gz: fcf03529b2a1ace0aa6b383c13549a30c761bc3ca2e3b8da6d71bce09b1e32c48e5ea2a1f55df84d57a663fd2f833311232d5ebd62c5e6667d2bec0864da06d5
7
- data.tar.gz: 5d4d2e59fcb5a7ecbb9eb323fee070c97fe41241ffbe54e5d753371804c92e32fe2efa1447859e023e936ed76455cb73b176a01b85a1ed7116210a4858358c16
6
+ metadata.gz: 85355a9f375ad7668f9e6f95c93ee61ed432b726ecca403a6c707564348021c9c4af9bd19e6b9a69f9345370c4c33729f5bf67c5637d27be08316bab053e1c29
7
+ data.tar.gz: fef28e9ff97459da3169718ef53fdea106be757068433b3b43e722e3a4ae20934ec65101679b5ae314071ae7a29d212dbf1f94ffdc42b2f4cad89a49fd528f82
data/apion.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'apion'
3
- s.version = '0.1.7'
3
+ s.version = '0.1.8'
4
4
  s.date = '2013-09-07'
5
5
  s.summary = "Apion"
6
6
  s.description = "Easy-to-use Fr/Api translator"
data/lib/apion.rb CHANGED
@@ -1,45 +1,2 @@
1
- #!/usr/bin/env ruby
2
-
3
- class Apion
4
-
5
- require "json"
6
- require "timeout"
7
-
8
- ROOT = File.expand_path("../..", __FILE__)
9
- eval(File.read("#{ROOT}/lib/special_chars.rb"))
10
- attr_accessor :timeout
11
-
12
- def initialize
13
- @timeout = 0.2
14
- end
15
-
16
- def parseCSV(path)
17
- Hash[File.open("#{ROOT}/data/#{path}.csv").read.split("\n").map {|ligne| ligne.split("#")}]
18
- end
19
-
20
- def exceptions
21
- @exceptions ||= JSON.parse(File.read("#{ROOT}/data/dict.json"))
22
- end
23
-
24
- def conversion
25
- @conversion ||= parseCSV "conversion"
26
- end
27
-
28
- def apion(texte)
29
- texte = texte.downcase
30
- texte.gsub(SPE, "").split.map do |mot|
31
- exceptions[mot] || "".tap do |result|
32
- Timeout::timeout(timeout) do
33
- conversion.select { |regle| mot =~ /#{regle}/ }.first.tap do |regle, api|
34
- mot.sub! /#{regle}/, ""
35
- result << api.to_s
36
- end until mot.empty?
37
- end
38
- end
39
- end
40
- rescue Timeout::Error
41
- return []
42
- end
43
-
44
- end
45
-
1
+ root = File.expand_path("../..", __FILE__)
2
+ require "#{root}/lib/string.rb"
data/lib/ipa.rb ADDED
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ class IPA
4
+
5
+ require "json"
6
+ require "timeout"
7
+
8
+ ROOT = File.expand_path("../..", __FILE__)
9
+ eval(File.read("#{ROOT}/lib/special_chars.rb"))
10
+ attr_accessor :timeout
11
+
12
+ def initialize
13
+ @timeout = 0.2
14
+ end
15
+
16
+ def parseCSV(path)
17
+ Hash[File.open("#{ROOT}/data/#{path}.csv").read.split("\n").map {|ligne| ligne.split("#")}]
18
+ end
19
+
20
+ def exceptions
21
+ @exceptions ||= JSON.parse(File.read("#{ROOT}/data/dict.json"))
22
+ end
23
+
24
+ def conversion
25
+ @conversion ||= parseCSV "conversion"
26
+ end
27
+
28
+ def convert_to_ipa(texte)
29
+ texte = texte.downcase
30
+ texte.gsub(SPE, "").split.map do |mot|
31
+ exceptions[mot] || "".tap do |result|
32
+ Timeout::timeout(timeout) do
33
+ conversion.select { |regle| mot =~ /#{regle}/ }.first.tap do |regle, api|
34
+ mot.sub! /#{regle}/, ""
35
+ result << api.to_s
36
+ end until mot.empty?
37
+ end
38
+ end
39
+ end
40
+ rescue Timeout::Error
41
+ return []
42
+ end
43
+
44
+ end
45
+
data/lib/string.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  root = File.expand_path("../..", __FILE__)
4
- require "#{root}/lib/apion.rb"
4
+ require "#{root}/lib/ipa.rb"
5
5
 
6
6
  class String
7
7
  def to_api
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apion
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Galaad Gauthier
@@ -34,6 +34,7 @@ files:
34
34
  - Gemfile
35
35
  - apion.gemspec
36
36
  - lib/special_chars.rb
37
+ - lib/ipa.rb
37
38
  - lib/string.rb
38
39
  - lib/apion.rb
39
40
  - data/dict.json