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.
- checksums.yaml +4 -4
- data/lib/snippet_generator.rb +57 -51
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fbacf0b5f9469322538e5f618a97290a647798d7c9fef3a5a930fa60f3a9dfde
|
4
|
+
data.tar.gz: 217c1546e0f1eb04d3fb190b77b1c2e5d133452fadf5f104492eb69603d7372a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d4d72670e41bb86a13d9771311795788eec7597014ddb2d675f1e9d8d740f356c87fefdc569f770294e5a6794bcdea6008b66d23a3f0e37c9366af08bd150a9
|
7
|
+
data.tar.gz: 3419f68f18f9406934febfaff7cc6a7290fba479e6fd52372a7633fcc13d59f28fefcf1a498e4af55b3088c1246feda065173108adf8271951105b6f02e5d04e
|
data/lib/snippet_generator.rb
CHANGED
@@ -1,64 +1,70 @@
|
|
1
|
-
|
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
|
-
|
18
|
-
|
19
|
-
|
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
|
-
|
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
|
-
|
26
|
-
|
27
|
-
|
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
|
-
|
19
|
+
# Create a YAML Comment to separate sections of snippet file.
|
42
20
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
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
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
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.
|
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-
|
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/
|
39
|
+
source_code_uri: https://github.com/ajmarkow/snippets_for_espanso
|
40
40
|
post_install_message:
|
41
41
|
rdoc_options: []
|
42
42
|
require_paths:
|