nautilus_scripts 0.0.4 → 0.0.5
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/nautilus_scripts.rb +90 -6
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4214551bfb73b0c39e81b91154518cfa96c05bfc
|
4
|
+
data.tar.gz: e175cf7afff7ed3e138e793dc139e88ab8e78016
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d4f3dc48e2aaac07381eb6c6da131bbf76123c3a842320669dbde160c14269659092dee21a0194ae65109d299989e70816037dc8a2064b5fc54dd59f8467089
|
7
|
+
data.tar.gz: 9b9a26cf844daee1cd3b65e07cb0e73178c585fc37ca9461b47b9507326dee145410b6c0e9d5fcc65a785b8076c4ecee92dc09ff363f10333318a317ad492a2a
|
data/lib/nautilus_scripts.rb
CHANGED
@@ -3,9 +3,29 @@ module Nautilus
|
|
3
3
|
GEOMETRY_RE=/(?<w>\d+)x(?<h>\d+)\+(?<x>\d+)\+(?<y>\d+)/
|
4
4
|
GEOMETRY_KEYS=[:x, :y, :w, :h]
|
5
5
|
|
6
|
+
# Document the responsibility of the class
|
7
|
+
#
|
8
|
+
# == Nautilus::Scripts class
|
9
|
+
#
|
10
|
+
# Helpers for handling NAUTILUS_SCRIPT environment variables in ruby scripts placed in
|
11
|
+
# ~/.local/share/nautilus/scripts
|
12
|
+
#
|
13
|
+
# == Formatting
|
14
|
+
#
|
15
|
+
# Embody +parameters+ or +options+ in Teletype Text tags. You can also use
|
16
|
+
# *bold* or *italics* but must use HTML tags for <b>multiple words</b>,
|
17
|
+
# <i>like this</i> and <tt>like this</tt>.
|
6
18
|
class Scripts
|
7
19
|
include Enumerable
|
8
20
|
|
21
|
+
##
|
22
|
+
# Constructor for Scripts class
|
23
|
+
#
|
24
|
+
# === Arguments
|
25
|
+
#
|
26
|
+
# * +items+ - optionally set paths to be manipulated, only if NAUTILUS_SCRIPT
|
27
|
+
# environment variables are not set
|
28
|
+
#
|
9
29
|
def initialize(items=nil)
|
10
30
|
@items = []
|
11
31
|
Scripts.selected_uris(items).each { |item|
|
@@ -13,32 +33,78 @@ module Nautilus
|
|
13
33
|
}
|
14
34
|
end
|
15
35
|
|
36
|
+
##
|
16
37
|
# Convert file URI to filesystem path
|
17
|
-
|
38
|
+
#
|
39
|
+
# === Arguments
|
40
|
+
#
|
41
|
+
# * +item+ - file URI to convert to a filesystem path
|
42
|
+
#
|
43
|
+
def self.defile(item)
|
18
44
|
item.sub(/^file:\/\//, "").gsub(/%20/, " ")
|
19
45
|
end
|
20
46
|
|
21
47
|
# Convert filesystem path to file URI
|
22
|
-
def refile(item)
|
48
|
+
def self.refile(item)
|
23
49
|
item.sub(/^/, "file://").gsub(/\s/, "%20")
|
24
50
|
end
|
25
51
|
|
26
|
-
|
52
|
+
##
|
53
|
+
# Returns the URI for the current directory from where the script was run.
|
54
|
+
#
|
55
|
+
# === Arguments
|
56
|
+
#
|
57
|
+
# * +default+ - value to use if Environment variable is not set
|
58
|
+
#
|
59
|
+
# === Environment Variable
|
60
|
+
#
|
61
|
+
# NAUTILUS_SCRIPT_CURRENT_URI=file:///home/tmp/bjs/nexus_5/links/20161202/Internal%20shared%20storage/DCIM/Camera
|
62
|
+
#
|
27
63
|
def self.current_uri(default="")
|
28
64
|
ENV['NAUTILUS_SCRIPT_CURRENT_URI']||default
|
29
65
|
end
|
30
66
|
|
31
|
-
|
67
|
+
##
|
68
|
+
# Returns the list of selected files as filesystem paths
|
69
|
+
#
|
70
|
+
# === Arguments
|
71
|
+
#
|
72
|
+
# * +default+ - value to use if Environment variable is not set
|
73
|
+
#
|
74
|
+
# === Environment Variable
|
75
|
+
#
|
76
|
+
# NAUTILUS_SCRIPT_SELECTED_FILE_PATHS='/home/tmp/bjs/nexus_5/links/20161202/Internal shared storage/DCIM/Camera/IMG_20131122_111539.jpg
|
77
|
+
#
|
32
78
|
def self.selected_file_paths(default="")
|
33
79
|
(ENV['NAUTILUS_SCRIPT_SELECTED_FILE_PATHS']||default).split(/\n/)
|
34
80
|
end
|
35
81
|
|
36
|
-
|
82
|
+
##
|
83
|
+
#
|
84
|
+
# Returns the list of selected files as URIs
|
85
|
+
#
|
86
|
+
# === Arguments
|
87
|
+
#
|
88
|
+
# * +default+ - value to use if Environment variable is not set
|
89
|
+
#
|
90
|
+
# === Environment Variable
|
91
|
+
#
|
92
|
+
# NAUTILUS_SCRIPT_SELECTED_URIS='file:///home/tmp/bjs/nexus_5/links/20161202/Internal%20shared%20storage/DCIM/Camera/IMG_20131122_111539.jpg
|
93
|
+
#
|
37
94
|
def self.selected_uris(default="")
|
38
95
|
(ENV['NAUTILUS_SCRIPT_SELECTED_URIS']||default).split(/\n/)
|
39
96
|
end
|
40
97
|
|
41
|
-
|
98
|
+
##
|
99
|
+
# Returns the window geometry extracted from the environment variable as a hash
|
100
|
+
#
|
101
|
+
# === Arguments
|
102
|
+
#
|
103
|
+
# * +default+ - value to use if Environment variable is not set
|
104
|
+
#
|
105
|
+
# === Environment Variable
|
106
|
+
#
|
107
|
+
# NAUTILUS_SCRIPT_WINDOW_GEOMETRY=1540x808+26+23
|
42
108
|
def self.window_geometry(default="")
|
43
109
|
geo=ENV['NAUTILUS_SCRIPT_WINDOW_GEOMETRY']||default
|
44
110
|
m=geo.match(GEOMETRY_RE)
|
@@ -47,6 +113,24 @@ module Nautilus
|
|
47
113
|
return h
|
48
114
|
end
|
49
115
|
|
116
|
+
##
|
117
|
+
# Iterator
|
118
|
+
#
|
119
|
+
# === Arguments
|
120
|
+
#
|
121
|
+
# * +block+ - block from caller
|
122
|
+
#
|
123
|
+
# === Example
|
124
|
+
#
|
125
|
+
# s = Nautilus::Scripts.new
|
126
|
+
# s.each { |path|
|
127
|
+
# puts path
|
128
|
+
# }
|
129
|
+
#
|
130
|
+
# === Yields
|
131
|
+
#
|
132
|
+
# * +item+ - each selected filesystem path
|
133
|
+
#
|
50
134
|
def each(&block)
|
51
135
|
@items.each { |item|
|
52
136
|
block.call(item)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nautilus_scripts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steeve McCauley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-07 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: manipulate files selected in the filemanager in the scripts directory
|
14
14
|
(~/.local/share/nautilus/scripts)
|
@@ -38,7 +38,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
38
38
|
version: '0'
|
39
39
|
requirements: []
|
40
40
|
rubyforge_project:
|
41
|
-
rubygems_version: 2.5.
|
41
|
+
rubygems_version: 2.5.2
|
42
42
|
signing_key:
|
43
43
|
specification_version: 4
|
44
44
|
summary: gnome nautilus scripts
|