snippets_for_espanso 0.1.0 → 0.1.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/snippet_generator.rb +57 -51
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 69855241d541438ecb682ccacd4d9833ce592cabe47c5b27c650947af4eb4c83
4
- data.tar.gz: 67fb38893fa424ac49f306ba761f4f570530270cf57bda566e0ebfa46f0d5c28
3
+ metadata.gz: fbacf0b5f9469322538e5f618a97290a647798d7c9fef3a5a930fa60f3a9dfde
4
+ data.tar.gz: 217c1546e0f1eb04d3fb190b77b1c2e5d133452fadf5f104492eb69603d7372a
5
5
  SHA512:
6
- metadata.gz: 5c0ffbf3026cdab2df95cd652f30db1f97fc9e5c74ee5247241816285fc4dbcf5f60bd5b0b405f1688fe7ac417a6372fec6727ad72e7fe24c66e723047340327
7
- data.tar.gz: c64767846463e5ce4f1fb494a3a85c9005c6fb2da3714b5d57466e66a8de3f10a9d18c6c4af89707c710715dece4a9ba9e5ef1df77ce87f4656240e1b9f9ef0e
6
+ metadata.gz: 3d4d72670e41bb86a13d9771311795788eec7597014ddb2d675f1e9d8d740f356c87fefdc569f770294e5a6794bcdea6008b66d23a3f0e37c9366af08bd150a9
7
+ data.tar.gz: 3419f68f18f9406934febfaff7cc6a7290fba479e6fd52372a7633fcc13d59f28fefcf1a498e4af55b3088c1246feda065173108adf8271951105b6f02e5d04e
@@ -1,64 +1,70 @@
1
- require 'yaml'
1
+ # Some Definitions for the sake of readability.
2
+
2
3
  NEW_LINE="\n"
3
- QUOTE = '"'
4
- trigger="whatsup"
5
- replacement="not much, you?"
6
- filename='test.yml'
4
+ QUOTE = '"'
7
5
 
8
6
  #Just writes matches: at the beginning of file so espanso can read the mapping.
9
- def initialize_espanso_yml
10
- file_to_write='test.yml'
11
- File.open(file_to_write,"a") { |file| file.write('matches:'+NEW_LINE) }
12
- end
13
- #Writes a
14
- def single_snippet_export(trigger,replacement)
15
- file_to_write='test.yml'
16
7
 
17
- File.open(file_to_write,"a") { |file| file.write(' - trigger: '+'":'+trigger+QUOTE+NEW_LINE) }
18
- File.open(file_to_write,"a") { |file| file.write(' replace: '+QUOTE+replacement+QUOTE+NEW_LINE) }
19
- end
8
+ def initialize_espanso_yml(file_to_write)
9
+ File.open(file_to_write,"a") { |file| file.write('matches:'+NEW_LINE) }
10
+ end
20
11
 
21
- #Takes a string for trigger. formvalues should be arrays within an array.
22
- #Parses statement
23
- def picklist_snippet_export(file_to_write)
12
+ #Writes a snippet to file when given trigger and replacement strings.
24
13
 
25
- form_trigger = "yo"
26
- form_variable_name='choices:'
27
- form_type = 'choice'
28
- formvalues = ['eenie','meenie','minie','moe']
29
- statement = "I chose {{choices}}"
30
- File.open(file_to_write,"a") { |file| file.write(' - trigger: '+'":'+form_trigger+QUOTE+NEW_LINE) }
31
- File.open(file_to_write,"a") { |file| file.write(' form: '+QUOTE+statement+QUOTE+NEW_LINE) }
32
- File.open(file_to_write,"a") { |file| file.write(' form_fields:'+NEW_LINE) }
33
- File.open(file_to_write,"a") { |file| file.write(' '+form_variable_name+NEW_LINE) }
34
- File.open(file_to_write,"a") { |file| file.write(' type: '+ form_type+NEW_LINE) }
35
- File.open(file_to_write,"a") { |file| file.write(' values:'+NEW_LINE) }
36
- formvalues.each do |value|
37
- File.open(file_to_write,"a") { |file| file.write(' - '+QUOTE+value+QUOTE+NEW_LINE) }
14
+ def single_snippet_export(file_to_write,trigger,replacement)
15
+ File.open(file_to_write,"a") { |file| file.write(' - trigger: '+'":'+trigger+QUOTE+NEW_LINE) }
16
+ File.open(file_to_write,"a") { |file| file.write(' replace: '+QUOTE+replacement+QUOTE+NEW_LINE) }
38
17
  end
39
- end
40
18
 
41
- def input_form_snippet_export(file_to_write)
19
+ # Create a YAML Comment to separate sections of snippet file.
42
20
 
43
- form_trigger = "yo"
44
- statement = "I chose {{name}}"
45
- File.open(file_to_write,"a") { |file| file.write(' - trigger: '+QUOTE+':'+form_trigger+QUOTE+NEW_LINE) }
46
- File.open(file_to_write,"a") { |file| file.write(' form: |'+NEW_LINE)}
47
- File.open(file_to_write,"a") { |file| file.write(' Hi {{name}}'+NEW_LINE)}
48
- end
21
+ def heading_snippet_export(file_to_write)
22
+ name = "THIS IS AN AWESOME SECTION"
23
+ File.open(file_to_write,"a") { |file| file.write("#"+ name) }
24
+ end
49
25
 
50
- def heading_snippet_export(file_to_write)
51
- name = "THIS IS AN AWESOME SECTION"
52
- File.open(file_to_write,"a") { |file| file.write("#"+ name) }
53
- end
26
+ # Any input fields should be entered with double brackets around them when passed in as form_statement
27
+ # For example "AJ likes coding in {{language}} and using {{editor}} to write code."
28
+
29
+ def input_form_snippet_export(form_trigger,form_statement,file_to_write)
30
+ File.open(file_to_write,"a") { |file| file.write(' - trigger: '+QUOTE+':'+form_trigger+QUOTE+NEW_LINE) }
31
+ File.open(file_to_write,"a") { |file| file.write(' form: |'+NEW_LINE)}
32
+ File.open(file_to_write,"a") { |file| file.write(' '+form_statement+NEW_LINE)}
33
+ end
34
+ ## ! TO DO: REFACTOR FORM METHODS INTO ONE METHOD which accounts for all cases. Add comments clarifying
35
+ ## ! DATA STRUCTURE NEEDED.
36
+ #Takes a string for trigger. form_values should be an array.form_fields should also be of type array.
37
+ #Parses statements and creates picklists based on form fields and values for each field provided
38
+
39
+ def picklist_snippet_export(form_trigger,statement,form_fields,formvalues,file_to_write)
40
+ form_fields.each do |value|
41
+ value+':'
42
+ end
43
+ form_type = 'choice'
44
+ File.open(file_to_write,"a") { |file| file.write(' - trigger: '+'":'+form_trigger+QUOTE+NEW_LINE) }
45
+ File.open(file_to_write,"a") { |file| file.write(' form: '+QUOTE+statement+QUOTE+NEW_LINE) }
46
+ form_fields.each do |value|
47
+ File.open(file_to_write,"a") { |file| file.write(' form_fields:'+NEW_LINE) }
48
+ File.open(file_to_write,"a") { |file| file.write(' '+form_fields+NEW_LINE) }
49
+ File.open(file_to_write,"a") { |file| file.write(' type: '+ form_type+NEW_LINE) }
50
+ File.open(file_to_write,"a") { |file| file.write(' values:'+NEW_LINE) }
51
+ formvalues.each do |value|
52
+ File.open(file_to_write,"a") { |file| file.write(' - '+QUOTE+value+QUOTE+NEW_LINE) }
53
+ end
54
+ end
54
55
 
55
- def textarea_snippet_export(file_to_write)
56
- File.open(file_to_write,"a") { |file| file.write(' - trigger: '+'":'+trigger+QUOTE+NEW_LINE) }
57
- File.open(file_to_write,"a") { |file| file.write(' replace: '+QUOTE+replacement+QUOTE+NEW_LINE) }
58
56
  end
59
- initialize_espanso_yml(filename)
60
- single_snippet_export(trigger,replacement)
61
- picklist_snippet_export(filename)
62
- input_form_snippet_export(filename)
63
- heading_snippet_export(filename)
64
57
 
58
+ # Creates a snippet with large text box
59
+
60
+ def textarea_snippet_export(file_to_write)
61
+ File.open(file_to_write,"a") { |file| file.write(' - trigger: '+QUOTE+':'+form_trigger+QUOTE+NEW_LINE) }
62
+ File.open(file_to_write,"a") { |file| file.write(' form: |'+NEW_LINE)}
63
+ File.open(file_to_write,"a") { |file| file.write(' '+form_statement+NEW_LINE)}
64
+ File.open(file_to_write,"a") { |file| file.write(' '+field_names+NEW_LINE) }
65
+ File.open(file_to_write,"a") { |file| file.write(' '+"multiline: true"+NEW_LINE) }
66
+ end
67
+
68
+ ## Form Generator Method. Will make form that has, .
69
+ ## Takes a few arrays as arguments.
70
+ ## Form Fields: Just string in array, but in form context represented as {{Form Field Name}}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snippets_for_espanso
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - AJ Markow
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-18 00:00:00.000000000 Z
11
+ date: 2020-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yaml
@@ -36,7 +36,7 @@ homepage: https://rubygems.org/gems/snippets_for_espanso
36
36
  licenses:
37
37
  - MIT
38
38
  metadata:
39
- source_code_uri: https://github.com/ajmarkow/snippets_gem
39
+ source_code_uri: https://github.com/ajmarkow/snippets_for_espanso
40
40
  post_install_message:
41
41
  rdoc_options: []
42
42
  require_paths: