snippets_for_espanso 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/snippet_generator.rb +64 -0
  3. metadata +59 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 69855241d541438ecb682ccacd4d9833ce592cabe47c5b27c650947af4eb4c83
4
+ data.tar.gz: 67fb38893fa424ac49f306ba761f4f570530270cf57bda566e0ebfa46f0d5c28
5
+ SHA512:
6
+ metadata.gz: 5c0ffbf3026cdab2df95cd652f30db1f97fc9e5c74ee5247241816285fc4dbcf5f60bd5b0b405f1688fe7ac417a6372fec6727ad72e7fe24c66e723047340327
7
+ data.tar.gz: c64767846463e5ce4f1fb494a3a85c9005c6fb2da3714b5d57466e66a8de3f10a9d18c6c4af89707c710715dece4a9ba9e5ef1df77ce87f4656240e1b9f9ef0e
@@ -0,0 +1,64 @@
1
+ require 'yaml'
2
+ NEW_LINE="\n"
3
+ QUOTE = '"'
4
+ trigger="whatsup"
5
+ replacement="not much, you?"
6
+ filename='test.yml'
7
+
8
+ #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
+
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
20
+
21
+ #Takes a string for trigger. formvalues should be arrays within an array.
22
+ #Parses statement
23
+ def picklist_snippet_export(file_to_write)
24
+
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) }
38
+ end
39
+ end
40
+
41
+ def input_form_snippet_export(file_to_write)
42
+
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
49
+
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
54
+
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
+ 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
+
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: snippets_for_espanso
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - AJ Markow
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-12-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: yaml
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: Gem with methods to create simple snippets, or more complex snippets
28
+ which invoke a form on users computer.
29
+ email: aj@ajm.codes
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - lib/snippet_generator.rb
35
+ homepage: https://rubygems.org/gems/snippets_for_espanso
36
+ licenses:
37
+ - MIT
38
+ metadata:
39
+ source_code_uri: https://github.com/ajmarkow/snippets_gem
40
+ post_install_message:
41
+ rdoc_options: []
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ requirements: []
55
+ rubygems_version: 3.0.3
56
+ signing_key:
57
+ specification_version: 4
58
+ summary: Takes strings & writes YAML to a file in the format for Espanso Text Expander.
59
+ test_files: []