jist 1.1.0 → 1.1.1.pre.1

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 (2) hide show
  1. data/lib/jist.rb +19 -2
  2. metadata +5 -5
@@ -6,7 +6,7 @@ require 'json'
6
6
  module Jist
7
7
  extend self
8
8
 
9
- VERSION = '1.1.0'
9
+ VERSION = '1.1.1.pre.1'
10
10
 
11
11
  # A list of clipboard commands with copy and paste support.
12
12
  CLIPBOARD_COMMANDS = {
@@ -214,6 +214,23 @@ module Jist
214
214
  `#{clipboard_command(:paste)}`
215
215
  end
216
216
 
217
+ # Find command from PATH environment.
218
+ #
219
+ # @param [String] cmd command name to find
220
+ # @param [String] options PATH environment variable
221
+ # @return [String] the command found
222
+ def which(cmd, path=ENV['PATH'])
223
+ if RUBY_PLATFORM.downcase =~ /mswin(?!ce)|mingw|bccwin|cygwin/
224
+ path.split(File::PATH_SEPARATOR).each {|dir|
225
+ f = File.join(dir, cmd+".exe")
226
+ return f if File.executable?(f) && !File.directory?(f)
227
+ }
228
+ nil
229
+ else
230
+ return system("which #{cmd} > /dev/null 2>&1")
231
+ end
232
+ end
233
+
217
234
  # Get the command to use for the clipboard action.
218
235
  #
219
236
  # @param [Symbol] action either :copy or :paste
@@ -221,7 +238,7 @@ module Jist
221
238
  # @raise [RuntimeError] if no clipboard integration could be found
222
239
  def clipboard_command(action)
223
240
  command = CLIPBOARD_COMMANDS.keys.detect do |cmd|
224
- system("type #{cmd} >/dev/null 2>&1")
241
+ which cmd
225
242
  end
226
243
  raise "Could not find copy command, tried: #{CLIPBOARD_COMMANDS}" unless command
227
244
  action == :copy ? command : CLIPBOARD_COMMANDS[command]
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jist
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
5
- prerelease:
4
+ version: 1.1.1.pre.1
5
+ prerelease: 6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Conrad Irwin
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-18 00:00:00.000000000 Z
12
+ date: 2012-10-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
@@ -94,9 +94,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
94
94
  required_rubygems_version: !ruby/object:Gem::Requirement
95
95
  none: false
96
96
  requirements:
97
- - - ! '>='
97
+ - - ! '>'
98
98
  - !ruby/object:Gem::Version
99
- version: '0'
99
+ version: 1.3.1
100
100
  requirements: []
101
101
  rubyforge_project:
102
102
  rubygems_version: 1.8.24