clipboard_manager 2.0.0 → 3.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: c839018d87470f0e0ef14880764ab2ff0d413505
4
- data.tar.gz: 1643003d620045d60cf89ccf7548ee617387365d
2
+ SHA256:
3
+ metadata.gz: b3482809f7953076b0f8c8ce62c6ba14b010b886405b1dc048fb570037510eaf
4
+ data.tar.gz: ebb4dac2ba0f2aad8efa86b1eea59bc13034af259c8311ea22d6d15863942e69
5
5
  SHA512:
6
- metadata.gz: 0144ebd1f91464cec7f7f233b51e1f227d789eb134544488c026d94a0728b4d5012803b3a715e6e73ddfe7ea77726c570608daeb7867a63a18317dfd852d3876
7
- data.tar.gz: d48b9dd77d6d9d7cf3f850d626ac252b85723e27f909df85b748644ee3add1d01c1abc4a1e3e8f2c41f5654c7fde24aaffcab0d3146a52a4e7f12903a82a0973
6
+ metadata.gz: 73fffaa22f58886ab4f6b80185d14884a1094dbe5c3d359ac9014de19fbd0341fad55a7663144341ce6397eef636ae1d9c886dc476971bb68dd3c35f4e992248
7
+ data.tar.gz: 2e36667fadd205feecaa9a3714e24c154b385dc0329dda455870e7ac21d0bff6f364179fb5f5f289148f0275f5bad098c64c491df4711d48c792b97f32ece47a
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 carlosjhr64
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,81 @@
1
+ # clipboard_manager
2
+
3
+ ## DESCRIPTION:
4
+
5
+ Ruby Gtk3App Clipboard Manager.
6
+
7
+ ## FEATURES
8
+
9
+ * history
10
+ * wget youtube-dl mplayer command to play youtube video
11
+ * firefox opens url
12
+ * espeak
13
+ * zbarcam qrcode
14
+
15
+ ## INSTALL:
16
+
17
+ Note that you'll need gtk3app:
18
+
19
+ $ sudo gem install gtk3app
20
+ $ sudo gem install clipboard_manager
21
+
22
+ ## CONFIGURATION:
23
+
24
+ After an initial run, your user configuration will found in:
25
+
26
+ ~/.config/gtk3app/clipboardmanager/config-?.?.yml
27
+
28
+ Towards the bottom of the file you will find the available tasks:
29
+
30
+ :tasks:
31
+ :mplayer:
32
+ - "(https?://www\\.youtube\\.com/watch\\?v=[\\w\\-]+)"
33
+ - :bashit
34
+ - true
35
+ - wget --quiet -O - $(youtube-dl -f 5/36/17/18 -g '$1') | mplayer -really-quiet
36
+ -cache 8192 -cache-min 1 -
37
+ :firefox:
38
+ - "^https?://"
39
+ - :firefox
40
+ - true
41
+ :espeak:
42
+ - ".{80,}"
43
+ - :espeak
44
+ - true
45
+
46
+ It is by this configuration that one can modify and add tasks.
47
+ With the boolean `true` value the clipboard will clear on the matched task.
48
+ If you don't want the clipboard cleared on a matched task,
49
+ set the boolean value to `false`.
50
+
51
+ The _mplayer_ task will run when the clipboard text matches a youtube link.
52
+ It will run the given system command `wget.. youtube_dl... '$1' | mplayer ...`,
53
+ where $1 will be replaced by the captured 1 match.
54
+
55
+ The _firefox_ task will run when the clipboard text matches a http address.
56
+ It will open the address with firefox.
57
+
58
+ The _espeak_ task will run when the clipboard text is at least 80 characters long.
59
+ It will have espeak read the text.
60
+
61
+ Currently, clipboard_manager has three tasks methods: bashit, firefox, and espeak.
62
+
63
+ For firefox and espeak, the pattern is used to recognize the text.
64
+ The whole copied text is used to pass on to firefox as a url, or espeak as text to be read.
65
+
66
+ bashit is more complicated.
67
+ It requires a command string which it will substitute $0, $1, $2... with match data.
68
+ It then passes the string to system.
69
+
70
+ See [clipboard_manager/clipboard_manager.rb](https://github.com/carlosjhr64/clipboard_manager/blob/master/lib/clipboard_manager/clipboard_manager.rb)
71
+ for details.
72
+ Specifically, methods #espeak, #firefox, and #bashit, which are called from #manage.
73
+
74
+ ## HELP:
75
+
76
+ Usage:
77
+ clipboard_manager [:options+]
78
+ Options:
79
+ -h --help
80
+ -v --version
81
+
@@ -1,20 +1,14 @@
1
1
  #!/usr/bin/env ruby
2
- module ClipboardManager
3
- VERSION = '2.0.0'
4
- if _ = ARGV.shift
5
- if ['-v','--version'].include?(_)
6
- puts VERSION
7
- exit 0
8
- end
9
- puts <<-HELP
2
+ require 'help_parser'
3
+ require 'clipboard_manager'
4
+
5
+ OPTIONS = HelpParser[ClipboardManager::VERSION, <<HELP]
10
6
  Usage:
11
7
  clipboard_manager [:options+]
12
8
  Options:
13
- -v --version
14
9
  -h --help
15
- HELP
16
- exit 0
17
- end
18
- end
19
- require 'clipboard_manager'
10
+ -v --version
11
+ HELP
12
+
13
+ ClipboardManager.requires
20
14
  Gtk3App.main ClipboardManager
@@ -1 +1 @@
1
- 2.0.0
1
+ 3.0.0
@@ -1,13 +1,19 @@
1
- # Standard Libraries
2
- require 'timeout'
1
+ module ClipboardManager
2
+ VERSION = '3.0.0'
3
3
 
4
- # Work gems
5
- require 'gtk3app'
6
- require 'helpema/zbar'
4
+ def self.requires
5
+ # Standard Libraries
6
+ require 'timeout'
7
7
 
8
- # This Gem
9
- require_relative 'clipboard_manager/config.rb'
10
- require_relative 'clipboard_manager/clipboard_manager.rb'
8
+ # Work gems
9
+ require 'gtk3app'
10
+ require 'helpema/zbar'
11
+
12
+ # This Gem
13
+ require_relative 'clipboard_manager/config.rb'
14
+ require_relative 'clipboard_manager/clipboard_manager.rb'
15
+ end
16
+ end
11
17
 
12
18
  # Requires:
13
19
  #`ruby`
@@ -5,6 +5,44 @@ module ClipboardManager
5
5
  ClipboardManager.new(program)
6
6
  end
7
7
 
8
+ class NoYes < Such::Dialog
9
+ def initialize(*par)
10
+ super
11
+ add_button '_No', Gtk::ResponseType::CANCEL
12
+ add_button '_Yes', Gtk::ResponseType::OK
13
+ end
14
+
15
+ def label(*par)
16
+ Such::Label.new child, *par
17
+ end
18
+
19
+ def ok?
20
+ show_all
21
+ response = run
22
+ destroy
23
+ response == Gtk::ResponseType::OK
24
+ end
25
+ end
26
+
27
+ class CancelOk < Such::Dialog
28
+ def initialize(*par)
29
+ super
30
+ add_button(Gtk::Stock::CANCEL, Gtk::ResponseType::CANCEL)
31
+ add_button(Gtk::Stock::OK, Gtk::ResponseType::OK)
32
+ end
33
+
34
+ def combo(*par)
35
+ Such::ComboBoxText.new child, *par
36
+ end
37
+
38
+ def runs
39
+ show_all
40
+ response = run
41
+ yield if response == Gtk::ResponseType::OK
42
+ destroy
43
+ end
44
+ end
45
+
8
46
  class ClipboardManager
9
47
  CLIPBOARD = Gtk::Clipboard.get(Gdk::Selection::CLIPBOARD)
10
48
 
@@ -39,10 +77,12 @@ class ClipboardManager
39
77
  Such::Button.new(vbox, :history_button!){do_history!}
40
78
  Such::Button.new(vbox, :qrcode_button!){do_qrcode!}
41
79
 
80
+ program.app_menu.each{|_|_.destroy if _.key==:fs!}
81
+
42
82
  mm = program.mini_menu
43
- mm.append_menu_item(:do_toggle!){do_toggle!}
44
- mm.append_menu_item(:do_history!){do_history!}
45
- mm.append_menu_item(:do_qrcode!){do_qrcode!}
83
+ mm.add_menu_item(:do_toggle!){do_toggle!}
84
+ mm.add_menu_item(:do_history!){do_history!}
85
+ mm.add_menu_item(:do_qrcode!){do_qrcode!}
46
86
 
47
87
  @history, @previous = [], nil
48
88
  text = request_text
@@ -61,7 +101,7 @@ class ClipboardManager
61
101
 
62
102
  # https://github.com/ruby-gnome2/ruby-gnome2/blob/master/gtk3/sample/misc/dialog.rb
63
103
  def do_history!
64
- dialog = Gtk3App::Dialog::CancelOk.new(:history_dialog!)
104
+ dialog = CancelOk.new(:history_dialog!)
65
105
  dialog.transient_for = @window
66
106
  combo = dialog.combo :history_combo!
67
107
  @history.each do |str|
@@ -71,8 +111,8 @@ class ClipboardManager
71
111
  end
72
112
  combo.append_text(str)
73
113
  end
74
- dialog.runs do |response|
75
- if response == Gtk::ResponseType::OK and combo.active_text
114
+ dialog.runs do
115
+ if combo.active_text
76
116
  @previous = nil
77
117
  CLIPBOARD.text = @history[combo.active]
78
118
  end
@@ -92,10 +132,10 @@ class ClipboardManager
92
132
 
93
133
  def question?(name)
94
134
  return true unless @ask.active?
95
- dialog = Gtk3App::Dialog::NoYes.new :question_dialog!
135
+ dialog = NoYes.new :question_dialog!
96
136
  dialog.transient_for = @window
97
137
  dialog.label.text = "Run #{name}?"
98
- dialog.runs
138
+ dialog.ok?
99
139
  end
100
140
 
101
141
  def toggled
@@ -147,10 +187,10 @@ class ClipboardManager
147
187
  add_history text
148
188
  CONFIG[:tasks].each do |name, _|
149
189
  next unless @checks[name].active?
150
- rgx, mth, str = _
190
+ rgx, mth, clr, str = _
151
191
  rgx = Regexp.new(rgx, Regexp::EXTENDED | Regexp::MULTILINE)
152
192
  if md=rgx.match(text) and question?(name)
153
- CLIPBOARD.text=Rafini::Empty::STRING
193
+ CLIPBOARD.clear if clr
154
194
  begin
155
195
  case mth
156
196
  when :espeak
@@ -184,7 +224,7 @@ class ClipboardManager
184
224
 
185
225
  def bashit(md, str)
186
226
  (md.length-1).downto(0) do |i|
187
- str = str.gsub(/\$#{i}/, md[i])
227
+ str = str.gsub(/\$#{i}/, md[i] || '')
188
228
  end
189
229
  $stderr.puts str
190
230
  Process.detach spawn str
@@ -46,7 +46,7 @@ module ClipboardManager
46
46
  about_dialog: {
47
47
  set_program_name: 'Clipboard Manager',
48
48
  set_version: VERSION.semantic(0..1),
49
- set_copyright: '(c) 2015 CarlosJHR64',
49
+ set_copyright: '(c) 2018 CarlosJHR64',
50
50
  set_comments: 'A Ruby Gtk3App Clipboard Manager ',
51
51
  set_website: 'https://github.com/carlosjhr64/clipboard_manager',
52
52
  set_website_label: 'See it at GitHub!',
@@ -113,10 +113,11 @@ module ClipboardManager
113
113
  mplayer: [
114
114
  '(https?://www\.youtube\.com/watch\?v=[\w\-]+)',
115
115
  :bashit,
116
+ true, # clears clipboard
116
117
  "wget --quiet -O - $(youtube-dl -f 5/36/17/18 -g '$1') | mplayer -really-quiet -cache 8192 -cache-min 1 -",
117
118
  ],
118
- firefox: ['^https?://', :firefox],
119
- espeak: ['.{80,}', :espeak],
119
+ firefox: ['^https?://', :firefox, true],
120
+ espeak: ['.{80,}', :espeak, true],
120
121
  }
121
122
  }
122
123
 
metadata CHANGED
@@ -1,35 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clipboard_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - carlosjhr64
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-15 00:00:00.000000000 Z
11
+ date: 2018-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: help_parser
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '6.5'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 6.5.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '6.5'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 6.5.0
13
33
  - !ruby/object:Gem::Dependency
14
34
  name: gtk3app
15
35
  requirement: !ruby/object:Gem::Requirement
16
36
  requirements:
17
37
  - - "~>"
18
38
  - !ruby/object:Gem::Version
19
- version: '2.0'
39
+ version: '3.0'
20
40
  - - ">="
21
41
  - !ruby/object:Gem::Version
22
- version: 2.0.1
42
+ version: 3.0.0
23
43
  type: :runtime
24
44
  prerelease: false
25
45
  version_requirements: !ruby/object:Gem::Requirement
26
46
  requirements:
27
47
  - - "~>"
28
48
  - !ruby/object:Gem::Version
29
- version: '2.0'
49
+ version: '3.0'
30
50
  - - ">="
31
51
  - !ruby/object:Gem::Version
32
- version: 2.0.1
52
+ version: 3.0.0
33
53
  - !ruby/object:Gem::Dependency
34
54
  name: helpema
35
55
  requirement: !ruby/object:Gem::Requirement
@@ -57,10 +77,10 @@ email: carlosjhr64@gmail.com
57
77
  executables:
58
78
  - clipboard_manager
59
79
  extensions: []
60
- extra_rdoc_files:
61
- - README.rdoc
80
+ extra_rdoc_files: []
62
81
  files:
63
- - README.rdoc
82
+ - LICENSE
83
+ - README.md
64
84
  - bin/clipboard_manager
65
85
  - data/VERSION
66
86
  - data/logo.png
@@ -77,9 +97,7 @@ licenses:
77
97
  - MIT
78
98
  metadata: {}
79
99
  post_install_message:
80
- rdoc_options:
81
- - "--main"
82
- - README.rdoc
100
+ rdoc_options: []
83
101
  require_paths:
84
102
  - lib
85
103
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -93,15 +111,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
111
  - !ruby/object:Gem::Version
94
112
  version: '0'
95
113
  requirements:
96
- - 'ruby: ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-linux]'
114
+ - 'ruby: ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-linux]'
97
115
  - 'system: linux/bash'
98
- - 'zbarcam: 0.20'
99
- - 'firefox: Mozilla Firefox 57.0.1'
116
+ - 'zbarcam: 0.20.1'
117
+ - 'firefox: Mozilla Firefox 63.0.3'
100
118
  - 'espeak: eSpeak text-to-speech: 1.48.03 04.Mar.14 Data at: /usr/share/espeak-data'
101
- - 'wget: GNU Wget 1.19.2 built on linux-gnu.'
102
- - 'youtube-dl: 2017.11.15'
119
+ - 'wget: GNU Wget 1.19.5 built on linux-gnu.'
120
+ - 'youtube-dl: 2018.11.07'
103
121
  rubyforge_project:
104
- rubygems_version: 2.6.13
122
+ rubygems_version: 2.7.6
105
123
  signing_key:
106
124
  specification_version: 4
107
125
  summary: Ruby Gtk3App Clipboard Manager.
@@ -1,107 +0,0 @@
1
- = clipboard_manager
2
-
3
- {<img src="https://badge.fury.io/rb/clipboard_manager.svg" alt="Gem Version" />}[http://badge.fury.io/rb/clipboard_manager]
4
-
5
- == DESCRIPTION:
6
-
7
- Ruby Gtk3App Clipboard Manager.
8
-
9
- == SYNOPSIS:
10
-
11
- gtk3app clipboard_manager [options]
12
-
13
- == FEATURES
14
-
15
- * history
16
- * wget youtube-dl mplayer command to play youtube video
17
- * firefox opens amazon webpage
18
- * espeak
19
- * zbarcam qrcode
20
-
21
- == INSTALL:
22
-
23
- Note that you do need gtk3app:
24
-
25
- $ sudo gem install gtk3app
26
- $ sudo gem install clipboard_manager
27
-
28
- == CONFIGURATION:
29
-
30
- After an initial run, your user configuration will found in:
31
-
32
- ~/.config/gtk3app/clipboardmanager/config-?.?.yml
33
-
34
- Towards the bottom of the file you will find the available tasks:
35
-
36
- :tasks:
37
- :mplayer:
38
- - "(https?://www\\.youtube\\.com/watch\\?v=[\\w\\-]+)"
39
- - :bashit
40
- - wget --quiet -O - $(youtube-dl -f 5/36/17/18 -g '$1') | mplayer -really-quiet
41
- -cache 8192 -cache-min 1 -
42
- :firefox:
43
- - "^https?://www.amazon.com/"
44
- - :firefox
45
- :espeak:
46
- - ".{80,}"
47
- - :espeak
48
-
49
-
50
- It is by this configuration that one can modify and add tasks.
51
-
52
- The _mplayer_ task will run when the clipboard text matches a youtube link.
53
- It will run the given system command "wget.. youtube_dl... '$0' | mplayer ...",
54
- where $1 will be replaced by the match.
55
-
56
- The _firefox_ task will run when the clipboard text matches an amazon link.
57
- It will open the link with firefox.
58
-
59
- The _espeak_ task will run when the clipboard text is at least 80 characters long.
60
- It will have espeak read the text.
61
-
62
- Currently, clipboard_manager has three tasks methods: bashit, firefox, and espeak.
63
-
64
- For firefox and espeak, the pattern is used to recognize the text.
65
- The whole copied text is used to pass on to firefox as a url, or espeak as text to be read.
66
-
67
- bashit is more complicated.
68
- It requires a command string which it will substitute $0, $1, $2... with match data.
69
- It then passes the string to system.
70
-
71
- See clipboard_manager/clipboard_manager.rb[https://github.com/carlosjhr64/clipboard_manager/blob/master/lib/clipboard_manager/clipboard_manager.rb]
72
- for details.
73
- Specifically, methods #espeak, #firefox, and #bashit, which are called from #manage.
74
-
75
- == HELP:
76
-
77
- Usage:
78
- clipboard_manager [:options+]
79
- Options:
80
- -v --version
81
- -h --help
82
-
83
-
84
- == LICENSE:
85
-
86
- (The MIT License)
87
-
88
- Copyright (c) 2014 carlosjhr64
89
-
90
- Permission is hereby granted, free of charge, to any person obtaining
91
- a copy of this software and associated documentation files (the
92
- 'Software'), to deal in the Software without restriction, including
93
- without limitation the rights to use, copy, modify, merge, publish,
94
- distribute, sublicense, and/or sell copies of the Software, and to
95
- permit persons to whom the Software is furnished to do so, subject to
96
- the following conditions:
97
-
98
- The above copyright notice and this permission notice shall be
99
- included in all copies or substantial portions of the Software.
100
-
101
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
102
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
103
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
104
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
105
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
106
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
107
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.