recycle 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +14 -0
  3. data/exe/recycle +28 -10
  4. data/lib/recycle/version.rb +1 -1
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3d9587c8db1ec655e81a0d3c0bdf4b00dba037a4
4
- data.tar.gz: a8dcc5b82c39d78f5db0ab7bd53c535b1308d648
3
+ metadata.gz: 3e7d964be5b85855d08762c76e209cfab0873b1d
4
+ data.tar.gz: 1fa32cfea649c2c875f8be015723aa450a940392
5
5
  SHA512:
6
- metadata.gz: 54b4efe1b678dcc04400cb3454ba5c0cff9a80aa7a9c703b4bb5542b148bdd27320f2a49894b4faa5371496f2b3b101f3d6adef862224242c90a4aa6c806080e
7
- data.tar.gz: 9fff30d15a8c249f4b97387cc61792a057cfd75565e4f75f255bf4c148b8d5abd43dcf8bacc524d6878e240267bd1f195eb93955cf90a91dedf9a36063361095
6
+ metadata.gz: e34b8f0616cca12dc2fd4d93595c506de847f15a901b3a5374f6e4cca736c66549dcea2b3b80240ac8301071d158177a42747699d4d95282c7d6b5b908c51524
7
+ data.tar.gz: d571def5acf8bf554e2a3ec8c14b7948f6633b8799f346a80867c81b8ed3e5cc1b0d16f983480f8c425a68a5d878cb7c9c2481b0748c5f87668fceba0f96c649
data/README.md CHANGED
@@ -14,6 +14,20 @@ some of the frustration by adding an easy way of adding directory shortcuts
14
14
  eval "$(recycle exec)"
15
15
  ```
16
16
 
17
+ or
18
+
19
+ If you'd prefer to not run a ruby executable every startup you can use
20
+ `recycle cache` in conjunction with sourcing the following.
21
+
22
+ ```sh
23
+ source $HOME/.recycle/cache
24
+ ```
25
+
26
+
27
+
28
+
29
+
30
+
17
31
  Listing configuration:
18
32
 
19
33
  ```sh
@@ -14,6 +14,7 @@ default_command :help
14
14
 
15
15
  RECYCLE_HOME = File.join(ENV['RECYCLE_ROOT'] || Dir.home, '.recycle')
16
16
  DATA_FILE = File.join(RECYCLE_HOME, 'data.yml')
17
+ CACHE_FILE = File.join(RECYCLE_HOME, 'cache')
17
18
  RECYCLE_CONFIG = File.exists?(DATA_FILE) ? YAML.load_file(DATA_FILE) : {}
18
19
 
19
20
  RECYCLE_CONFIG['commands'] ||= {}
@@ -113,20 +114,37 @@ command :remove do |cmd|
113
114
  end
114
115
  end
115
116
 
117
+ def output_config(io)
118
+ RECYCLE_CONFIG.fetch('directories', {}).each do |key, value|
119
+ io.puts %|alias #{key}="cd #{value}"|
120
+ end
121
+
122
+ RECYCLE_CONFIG.fetch('commands', {}).each do |key, value|
123
+ io.puts <<~DOC
124
+ function #{key}() {
125
+ #{value}
126
+ }
127
+ DOC
128
+ end
129
+ end
130
+
116
131
  command :exec do |cmd|
117
132
  cmd.syntax = 'recycle exec'
118
133
  cmd.description = 'Outputs all configuration in a shell consumable manner'
119
134
  cmd.action do
120
- RECYCLE_CONFIG.fetch('directories', {}).each do |key, value|
121
- puts %|alias #{key}="cd #{value}"|
122
- end
135
+ output_config($stdout)
136
+ end
137
+ end
123
138
 
124
- RECYCLE_CONFIG.fetch('commands', {}).each do |key, value|
125
- puts <<~DOC
126
- function #{key}() {
127
- #{value}
128
- }
129
- DOC
130
- end
139
+ command :cache do |cmd|
140
+ cmd.syntax = 'recycle cache'
141
+ cmd.description = "Stores all configuration in a shell consumable manner to #{CACHE_FILE}"
142
+ cmd.action do
143
+ File.open(CACHE_FILE, 'w') { |file| output_config(file) }
144
+ puts <<~DOC
145
+ You can now source #{CACHE_FILE} instead of using eval.
146
+
147
+ Note: You'll have to rerun 'recycle cache' after you add configuration.
148
+ DOC
131
149
  end
132
150
  end
@@ -1,3 +1,3 @@
1
1
  module Recycle
2
- VERSION = '0.1.6'.freeze
2
+ VERSION = '0.1.7'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: recycle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy W. Rowe
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-07-10 00:00:00.000000000 Z
11
+ date: 2017-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commander