flex_cocoa 0.0.2 → 0.0.3

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
2
  SHA1:
3
- metadata.gz: 49361337f2e55af56e8e2bf3589e7c7694886a2d
4
- data.tar.gz: 4fa671494091df03b1f922e285ab488a488cd976
3
+ metadata.gz: 2e3d91b9f6aed1fffe47bc44a5933d0a1c1271e7
4
+ data.tar.gz: f0341d6ca60d723fd4398137b7cacc97dc90b24b
5
5
  SHA512:
6
- metadata.gz: ad6c45e0cd779a89da8ab89da65187d7a7a3d66c97dea9de38144207b8059a5267a9011c86f4b9c2c9324a4e8ec5968662d51d9a9e5db1c7df236e2115ef9505
7
- data.tar.gz: bad592da1269a378038902b4e53cd8fb1dff88245034c6dec742645cc01197df17004ce7474c1b6fcdc6a47909e5039d8dfbb41ac91cc6999ab5a82407cf0a0f
6
+ metadata.gz: 5da2faaa6a7278cb5e868ce0364deb5d44bed5168f10d1dc78b93bbf679f804ec46628954b74753d947d2c3bedfcded68872d03db103da0006b9eb1d9f8ae584
7
+ data.tar.gz: feab526f19bae9adf032c76c9bc1e017ed0ea9b3b7a51393ad7e10676e11a42c687fa3957bfd67954194c4b5ba3bff481988418f18b5aa44f903d74b4a0af07b
@@ -0,0 +1,14 @@
1
+ require_relative '../../lib/flex_cocoa'
2
+
3
+ class FlexCocoa
4
+
5
+ end
6
+
7
+ class CcBubble < FlexCocoa
8
+ def initialize (title, message)
9
+ super()
10
+ @exec << " bubble --title \"#{title}\" --text \"#{message}\""
11
+ post_initialize
12
+ sleep(3)
13
+ end
14
+ end
@@ -0,0 +1,33 @@
1
+ require_relative '../../lib/flex_cocoa'
2
+
3
+ class CcFileSelect < FlexCocoa
4
+
5
+ def initialize (title, message, args = {})
6
+ super()
7
+ args = args
8
+
9
+ if args[:flags].nil?
10
+ args[:flags] = [:packages_as_dir]
11
+ end
12
+
13
+ @exec << " fileselect --title \"#{title}\" --text\"#{message}\""
14
+ @exec << " --select-directories" if args[:flags].include?(:select_dir)
15
+ @exec << " --select-only-directories" if args[:flags].include?(:only_dir)
16
+ @exec << " --packages-as-directories" if args[:flags].include?(:packages_as_dir)
17
+ @exec << "-select-multiple" if args[:flags].include?(:select_multiple)
18
+
19
+ unless args[:extensions].nil?
20
+ @exec << " --with-extensions"
21
+ args[:extensions].each { |ext|
22
+ @exec << " #{ext}"
23
+ }
24
+ end
25
+ @exec << " --with-directory #{args[:dir]}" unless args[:dir].nil?
26
+ @exec << " --with-file #{args[:file]}" unless args[:dir].nil?
27
+
28
+ post_initialize
29
+ response = @stdout.read.strip
30
+ @output = response
31
+ end
32
+
33
+ end
@@ -0,0 +1,15 @@
1
+ require_relative '../../lib/flex_cocoa'
2
+
3
+ class CcInputBox < FlexCocoa
4
+
5
+ def initialize (title, question, prompt = '', r_button = 'Ok', m_button = nil, l_button = nil)
6
+ super()
7
+
8
+ buttons_template('inputbox', title, prompt, question, r_button, m_button, l_button)
9
+ post_initialize
10
+ response = @stdout.read.strip.split("\n")
11
+ @output = {button: response[0], response: response[1]}
12
+ end
13
+
14
+ end
15
+
@@ -0,0 +1,21 @@
1
+ require_relative '../../lib/flex_cocoa'
2
+
3
+ class CcMessageBox < FlexCocoa
4
+
5
+ def initialize (title, subtitle, message, r_button, m_button = nil, l_button = nil)
6
+ super()
7
+ @exec << " msgbox"
8
+ @exec << " --title \"#{title}\" --text \"#{subtitle}\""
9
+ @exec << " --informative-text \"#{message}\""
10
+ @exec << " --button1 \"#{r_button}\""
11
+ @exec << " --button2 \"#{m_button}\"" unless m_button.nil?
12
+ @exec << " --button3 \"#{l_button}\"" unless l_button.nil?
13
+
14
+ post_initialize
15
+ response = @stdout.read.strip
16
+ @output = response.to_i - 1
17
+ end
18
+
19
+ end
20
+
21
+
@@ -0,0 +1,29 @@
1
+ require_relative '../../lib/flex_cocoa'
2
+
3
+ class CcProgress < FlexCocoa
4
+ attr_reader :total, :progress
5
+ def initialize (title, message, total)
6
+ super()
7
+ @base_message = message
8
+ @progress = 0
9
+ @total = total
10
+ @exec << " progressbar --tile \"#{title}\" --text \"#{message}\""
11
+ post_initialize
12
+ end
13
+
14
+ def advance (message = nil, counter = true)
15
+ @progress += 1
16
+ output = "#{@progress / @total.to_f * 100}"
17
+
18
+ if message.nil?
19
+ output << " #{@base_message}"
20
+ else
21
+ output << " #{message}"
22
+ end
23
+
24
+ output << " (#{@progress}/#{@total})" if counter
25
+
26
+ @stdin.puts output
27
+ end
28
+
29
+ end
@@ -0,0 +1,20 @@
1
+ require_relative '../../lib/flex_cocoa'
2
+
3
+ class CcSecureInput < FlexCocoa
4
+
5
+ def initialize (title, question, prompt = '', cancel = false)
6
+ super()
7
+
8
+ if cancel
9
+ buttons_template('inputbox', title, prompt, question, 'Cancel', 'Ok', nil)
10
+ else
11
+ buttons_template('inputbox', title, prompt, question, 'Ok', nil, nil)
12
+ end
13
+
14
+ @exec << " --no-show"
15
+ post_initialize
16
+ response = @stdout.read.strip.split("\n")
17
+ @output = {button: response[0], response: response[1]}
18
+ end
19
+
20
+ end
@@ -0,0 +1,16 @@
1
+ require_relative 'cc_message_box'
2
+
3
+ class OkMessageBox
4
+ attr_reader :output
5
+
6
+ def initialize (title, subtitle, message, cancel = false)
7
+
8
+ if cancel
9
+ @output = CcMessageBox.new(title, subtitle, message, 'Cancel', 'Ok').output
10
+ else
11
+ @output = CcMessageBox.new(title, subtitle, message, 'Ok').output
12
+ end
13
+
14
+ end
15
+
16
+ end
@@ -0,0 +1,13 @@
1
+ require_relative 'cc_message_box'
2
+
3
+ class YesNoBox
4
+ attr_reader :output
5
+
6
+ def initialize (title, subtitle, message, cancel = false)
7
+
8
+ l_button = cancel ? 'Cancel' : nil
9
+
10
+ @output = CcMessageBox.new(title, subtitle, message, 'No', 'Yes', l_button).output
11
+ end
12
+
13
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flex_cocoa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eugene Lai
@@ -31,6 +31,14 @@ extensions: []
31
31
  extra_rdoc_files: []
32
32
  files:
33
33
  - lib/flex_cocoa.rb
34
+ - lib/flex_cocoa/cc_bubble.rb
35
+ - lib/flex_cocoa/cc_file_select.rb
36
+ - lib/flex_cocoa/cc_input_box.rb
37
+ - lib/flex_cocoa/cc_message_box.rb
38
+ - lib/flex_cocoa/cc_progress.rb
39
+ - lib/flex_cocoa/cc_secure_input.rb
40
+ - lib/flex_cocoa/ok_message_box.rb
41
+ - lib/flex_cocoa/yes_no_message_box.rb
34
42
  homepage:
35
43
  licenses: []
36
44
  metadata: {}