glossa 1.0.5 → 1.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4e773d2de3588b814543656a2a5906ea1ea7d786
4
- data.tar.gz: c1e019a4319148fe43220c7014a414d6309c00b3
3
+ metadata.gz: 2b47036eb93fd38c2ab9647f4cc24dece0ec6bfc
4
+ data.tar.gz: f8535e218e76b8adee01c132bad266ed7dbcf879
5
5
  SHA512:
6
- metadata.gz: 8a2c83198b18eb0973a7e66bac8994a4885a65f11eb3b01baf7dfbcfbf26f314f019b1cd993025e0d64e2fc2a925374fd0b38202160d01ca74061cbeedc3ca09
7
- data.tar.gz: 3e133f7cd59dfca1f870334abcc5aa39a2ae86df9cbb7e06b68824fcf8c317ac764c1de153b550f86d65f657537715d1f605c34c45ed82d662ced322010be343
6
+ metadata.gz: faf673d1bbf5f986d170d164b889edb64fedde2401b232da04ddb5866f54b98105677e9efad7f10a503675eb8a3ccd179df486ce33fe854c134191374ccb1043
7
+ data.tar.gz: 95f9e6c0f064c07e06e18d27dbb3431b3c3cfe1d414e19ac7b14607bc076f1403dbd54cbb19d2d9f04b68b59bbab89c308dbdca446fd5ce211df19b22d3a368f
@@ -0,0 +1,33 @@
1
+ require "json"
2
+
3
+ class Glossa::Language
4
+ def self.import(path = nil)
5
+ path = gets "File path:" if path.nil?
6
+
7
+ # Get file from path
8
+ json = '';
9
+ File.open(path).each do |line|
10
+ json << line
11
+ end
12
+
13
+ options = JSON.parse(json)
14
+ self.new(false, options)
15
+ end
16
+
17
+ def export(path = nil)
18
+ if File.exist? path
19
+ raise "That file already exists!"
20
+ return
21
+ elsif path.nil?
22
+ raise "File path required"
23
+ return
24
+ end
25
+
26
+ lang_state = {}
27
+ self.instance_variables.each do |attribute|
28
+ a = attribute[1..attribute.length]
29
+ lang_state[a] = self.instance_variable_get(attribute)
30
+ end
31
+ File.open(path, "w") { |file| file.write(lang_state.to_json) }
32
+ end
33
+ end
@@ -39,22 +39,22 @@ class Glossa::Language
39
39
  "F" => "mn",
40
40
  "L" => "rl"
41
41
  }
42
- @structure = options[:structure] || "CVC"
43
- @exponent = options[:exponent] || 2
44
- @restricts = options[:restricts] || []
45
- @cortho = options[:cortho] || {}
46
- @vortho = options[:vortho] || {}
47
- @noortho = options[:noortho] || true
48
- @nomorph = options[:nomorph] || true
49
- @nowordpool = options[:nowordpool] || true
50
- @minsyll = options[:minsyll] || 1
51
- @maxsyll = options[:maxsyll] || 1
52
- @morphemes = options[:morphemes] || {}
53
- @words = options[:words] || {}
54
- @names = options[:names] || []
55
- @joiner = options[:joiner] || ' '
56
- @maxchar = options[:maxchar] || 12
57
- @minchar = options[:minchar] || 5
42
+ @structure = options['structure'] || "CVC"
43
+ @exponent = options['exponent'] || 2
44
+ @restricts = options['restricts'] || []
45
+ @cortho = options['cortho'] || {}
46
+ @vortho = options['vortho'] || {}
47
+ @noortho = options['noortho'] || true
48
+ @nomorph = options['nomorph'] || true
49
+ @nowordpool = options['nowordpool'] || true
50
+ @minsyll = options['minsyll'] || 1
51
+ @maxsyll = options['maxsyll'] || 1
52
+ @morphemes = options['morphemes'] || {}
53
+ @words = options['words'] || {}
54
+ @names = options['names'] || []
55
+ @joiner = options['joiner'] || ' '
56
+ @maxchar = options['maxchar'] || 12
57
+ @minchar = options['minchar'] || 5
58
58
  end
59
59
 
60
60
  @genitive = get_morpheme('of')
@@ -135,6 +135,7 @@ class Glossa::Language
135
135
  # phonetic word according to the language's orthography.
136
136
  def make_syllable
137
137
  structure = self.structure.chars
138
+
138
139
  while true
139
140
  syll = ''
140
141
  structure.each do |ptype|
@@ -153,7 +154,7 @@ class Glossa::Language
153
154
  # Make sure this syllable doesn't violate a restriction
154
155
  bad = false
155
156
  self.restricts.each do |regex|
156
- if regex =~ syll
157
+ if /#{regex}/ =~ syll
157
158
  bad = true
158
159
  break
159
160
  end
data/lib/glossa.rb CHANGED
@@ -249,13 +249,14 @@ module Glossa
249
249
  },
250
250
  {
251
251
  :name => "Double sounds",
252
- :res => [/(.)\1/]
252
+ :res => ['(.)\1']
253
253
  },
254
254
  {
255
255
  :name => "Doubles and hard clusters",
256
- :res => [/[sʃf][sʃ]/, /(.)\1/, /[rl][rl]/]
256
+ :res => ['[sʃf][sʃ]', '(.)\1', '[rl][rl]']
257
257
  }
258
258
  ]
259
259
  end
260
260
 
261
- require "glossa/language"
261
+ require "glossa/language"
262
+ require "glossa/import_export"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glossa
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jake Franklin
@@ -20,6 +20,7 @@ extensions: []
20
20
  extra_rdoc_files: []
21
21
  files:
22
22
  - lib/glossa.rb
23
+ - lib/glossa/import_export.rb
23
24
  - lib/glossa/language.rb
24
25
  homepage: http://rubygems.org/gems/glossa
25
26
  licenses: