expd 0.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 +7 -0
- checksums.yaml.gz.sig +1 -0
- data/bin/expd +38 -0
- data/lib/expd/config.rb +33 -0
- data/lib/expd/expander.rb +30 -0
- data/lib/expd/version.rb +5 -0
- data/lib/expd.rb +3 -0
- data/tests/tests.rb +27 -0
- data.tar.gz.sig +2 -0
- metadata +130 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3ac3eff3c26f1d7c2905e9d65098ded810145a72
|
4
|
+
data.tar.gz: 140b6f6dfc1d51fc56382b246b1bacb299575ebe
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7ea115e8a27f68694e3accffed7f8ee2dab5563ef8d8b5bf4d80727b176f51085ab62faa775071d6da6a02760182d8f789907ae2135f5a6813fb49fa4ba9b925
|
7
|
+
data.tar.gz: cdd41894311b7f65738fff9103e9769023b10952414cf8dc5bf7e3a43239545db503ac719045ce6fb7150800254205c9558fba5d71c9567d2380d4aeebd997e2
|
checksums.yaml.gz.sig
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
�SM�����ggU�������E��+JD-�g�YK�;/K�����=����ߕ���/~o#T�K;�ۻ�u ��ͪ���P�p��hQ_⹆FhZ|_����%@>��p���J���ĸP9�}���bͽ{�����V@�5�{�8��o�s3�]�t�.ї̃|E����!.5���W����k� ��
|
data/bin/expd
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
|
3
|
+
require "expd"
|
4
|
+
require "trollop"
|
5
|
+
|
6
|
+
opts = Trollop.options do
|
7
|
+
version "expd #{Expd.version}"
|
8
|
+
banner <<-EOS
|
9
|
+
Expd is a command-line text snippet expander.
|
10
|
+
|
11
|
+
Usage:
|
12
|
+
expd [options] <snippet shortcut>
|
13
|
+
|
14
|
+
Where [options] are:
|
15
|
+
EOS
|
16
|
+
|
17
|
+
opt :add, "Add a text snippet from STDIN"
|
18
|
+
opt :remove, "Remove a text snippet"
|
19
|
+
opt :copy, "Copy the expanded text in the clipboard", :default => true
|
20
|
+
end
|
21
|
+
|
22
|
+
Trollop.die "Please provide a snippet shortcut" if ARGV.empty?
|
23
|
+
|
24
|
+
conf = Expd::Config.defaults
|
25
|
+
word = ARGV.first
|
26
|
+
|
27
|
+
unless opts[:remove] || opts[:add]
|
28
|
+
exp = Expd::Expander.new conf.snippets
|
29
|
+
s = exp.expand word, :copy => opts[:copy]
|
30
|
+
puts s unless s.empty?
|
31
|
+
else
|
32
|
+
if opts[:remove]
|
33
|
+
conf.delete word
|
34
|
+
elsif opts[:add]
|
35
|
+
conf[:snippets][word] = STDIN.read
|
36
|
+
end
|
37
|
+
conf.save!
|
38
|
+
end
|
data/lib/expd/config.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require "forwardable"
|
2
|
+
require "yaml"
|
3
|
+
|
4
|
+
module Expd
|
5
|
+
class Config
|
6
|
+
extend Forwardable
|
7
|
+
|
8
|
+
def_delegators :@conf, :[], :[]=, :delete, :fetch
|
9
|
+
|
10
|
+
def initialize(filename)
|
11
|
+
@filename = filename
|
12
|
+
@conf = {}
|
13
|
+
load_from_file!
|
14
|
+
end
|
15
|
+
|
16
|
+
def load_from_file!
|
17
|
+
@conf = YAML.load_file @filename if File.exist?(@filename)
|
18
|
+
@conf[:snippets] ||= {}
|
19
|
+
end
|
20
|
+
|
21
|
+
def save!
|
22
|
+
File.open(@filename, "w") { |f| f.write YAML.dump(@conf) }
|
23
|
+
end
|
24
|
+
|
25
|
+
def snippets
|
26
|
+
self[:snippets]
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.defaults
|
30
|
+
new File.expand_path("~/.expd_snippets")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Expd
|
2
|
+
class Expander
|
3
|
+
def initialize(snippets)
|
4
|
+
@snippets = snippets
|
5
|
+
end
|
6
|
+
|
7
|
+
def expand(name, opts = {})
|
8
|
+
exp = @snippets.fetch(name, "").chomp
|
9
|
+
copy_to_clipboard exp if opts[:copy] && !exp.empty?
|
10
|
+
exp
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def copy_to_clipboard(text)
|
16
|
+
IO.popen(clipboard_cmd, "w") { |p| p.write text } unless text.empty?
|
17
|
+
end
|
18
|
+
|
19
|
+
def clipboard_cmd
|
20
|
+
@expand_cmd ||=
|
21
|
+
case RUBY_PLATFORM
|
22
|
+
when /darwin/
|
23
|
+
"pbcopy"
|
24
|
+
# I dunno what to use on Windows
|
25
|
+
else
|
26
|
+
"xclip -i"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/expd/version.rb
ADDED
data/lib/expd.rb
ADDED
data/tests/tests.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
ci = ENV["CI"] || ENV["CONTINUOUS_INTEGRATION"]
|
2
|
+
if ci
|
3
|
+
require "coveralls"
|
4
|
+
Coveralls.wear!
|
5
|
+
end
|
6
|
+
|
7
|
+
require "test/unit"
|
8
|
+
require "simplecov"
|
9
|
+
|
10
|
+
SimpleCov.formatter = Coveralls::SimpleCov::Formatter if ci
|
11
|
+
SimpleCov.start { add_filter "/tests/" }
|
12
|
+
|
13
|
+
require "expd"
|
14
|
+
|
15
|
+
class ExpdTests < Test::Unit::TestCase
|
16
|
+
def test_version
|
17
|
+
assert_match(/^\d+\.\d+\.\d+/, Expd.version)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_expand
|
21
|
+
exp = Expd::Expander.new({"foo" => "foobar"})
|
22
|
+
assert_equal "foobar", exp.expand("foo")
|
23
|
+
assert_equal "", exp.expand("bar")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
exit Test::Unit::AutoRunner.run
|
data.tar.gz.sig
ADDED
metadata
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: expd
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Baptiste Fontaine
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIDaDCCAlCgAwIBAgIBATANBgkqhkiG9w0BAQUFADA9MRAwDgYDVQQDDAdiYXRp
|
14
|
+
Zm9uMRUwEwYKCZImiZPyLGQBGRYFeWFob28xEjAQBgoJkiaJk/IsZAEZFgJmcjAe
|
15
|
+
Fw0xNTEyMjMwMTExMTZaFw0xNjEyMjIwMTExMTZaMD0xEDAOBgNVBAMMB2JhdGlm
|
16
|
+
b24xFTATBgoJkiaJk/IsZAEZFgV5YWhvbzESMBAGCgmSJomT8ixkARkWAmZyMIIB
|
17
|
+
IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0en8u9i10EQtkp3SUnXnXo0W
|
18
|
+
UISZyvp2kS22c2/FXYg566dtfkp3pwBOZi3gvRYAKpmXAwbynOANdm2bfzQiG+Br
|
19
|
+
0966dfY0SIbFuhaueJ8JUm5o/nxxCiKxuvCFs5899SJxyzmD3NNVzjTdrSU6UTgx
|
20
|
+
Q7K/r2MRYxBmPBbi8wdxyP1Ko36o9BJdLNrUiAVec1VXOlqA9Iw8CyrlG3V1snNl
|
21
|
+
efNVzZ+sMCkR73IyxRRwRgPws2jo2/8LfKcL+J3mz4ekBs4PoyOCWCnPlpBjAwkx
|
22
|
+
OzzDCjpxYbn/SYNHC8MxVdgap7jEX75ogkfpGOrAEdiPASnc2nFKqbJNxX7hCQID
|
23
|
+
AQABo3MwcTAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQU2BKQg2pq
|
24
|
+
izVT9CkLdQo+nHNlvpQwGwYDVR0RBBQwEoEQYmF0aWZvbkB5YWhvby5mcjAbBgNV
|
25
|
+
HRIEFDASgRBiYXRpZm9uQHlhaG9vLmZyMA0GCSqGSIb3DQEBBQUAA4IBAQBkPKEW
|
26
|
+
urPeZb+IHuqWMqpzL/42fU4QuVUYDswLq+V0tXwnHo+okAq00Xh0yr0OaDBvm0mW
|
27
|
+
al9ZGC0RzaSQa+9mPd0t39oaWdtY7TOxQX3OC3vxdZ794gqyQgNxOmajFl22NY01
|
28
|
+
vxMAeZOu+IC5s2pQyUG0Gsq2sRbquW1mj8OC8KI3WWcECqGFOIOdXYTsqVqhwcN1
|
29
|
+
OpgZkC/pnOJanbP2ex2OHjlwFlpQ2PPAhoIG3mU1HEYXBZuP7+DUgNNgpopX83A5
|
30
|
+
0df+9hsqme8UngbwGqM1XgU4dUlXNaoHejAm/d9IrRPvqE2oFsS9ytHShth2bC43
|
31
|
+
LPBfw/xSG5R4RjMC
|
32
|
+
-----END CERTIFICATE-----
|
33
|
+
date: 2016-02-07 00:00:00.000000000 Z
|
34
|
+
dependencies:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: trollop
|
37
|
+
requirement: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '2.1'
|
42
|
+
type: :runtime
|
43
|
+
prerelease: false
|
44
|
+
version_requirements: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '2.1'
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: simplecov
|
51
|
+
requirement: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0.11'
|
56
|
+
type: :development
|
57
|
+
prerelease: false
|
58
|
+
version_requirements: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0.11'
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: rake
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '10.5'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '10.5'
|
77
|
+
- !ruby/object:Gem::Dependency
|
78
|
+
name: coveralls
|
79
|
+
requirement: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0.8'
|
84
|
+
type: :development
|
85
|
+
prerelease: false
|
86
|
+
version_requirements: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0.8'
|
91
|
+
description: Expand text snippet from simple shortcuts on the command-line
|
92
|
+
email: batifon@yahoo.fr
|
93
|
+
executables:
|
94
|
+
- expd
|
95
|
+
extensions: []
|
96
|
+
extra_rdoc_files: []
|
97
|
+
files:
|
98
|
+
- bin/expd
|
99
|
+
- lib/expd.rb
|
100
|
+
- lib/expd/config.rb
|
101
|
+
- lib/expd/expander.rb
|
102
|
+
- lib/expd/version.rb
|
103
|
+
- tests/tests.rb
|
104
|
+
homepage: https://github.com/bfontaine/expd
|
105
|
+
licenses:
|
106
|
+
- MIT
|
107
|
+
metadata: {}
|
108
|
+
post_install_message:
|
109
|
+
rdoc_options: []
|
110
|
+
require_paths:
|
111
|
+
- lib
|
112
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
requirements: []
|
123
|
+
rubyforge_project:
|
124
|
+
rubygems_version: 2.4.8
|
125
|
+
signing_key:
|
126
|
+
specification_version: 4
|
127
|
+
summary: Text snippets command-line tool
|
128
|
+
test_files:
|
129
|
+
- tests/tests.rb
|
130
|
+
has_rdoc:
|
metadata.gz.sig
ADDED
Binary file
|