webconsole 0.1.12 → 0.1.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 555c27b5c21ea562b658de794fa4ec746b9a0925
4
- data.tar.gz: f326923751b001f49193726d6a0c3ec7ba7ba3b2
3
+ metadata.gz: 3fcc746a3b332008cbc7f7767e5c7879b968b639
4
+ data.tar.gz: d2debc54d64a67a3555db9164e012f2e2d59a883
5
5
  SHA512:
6
- metadata.gz: 886011882fdcf7a7b133396e95fa704b5cac1c7d44118bc8d461d09d5a06db54ee2a42c95e752ed05a440266ae046df90c681e9a1340051011bfa7777c679167
7
- data.tar.gz: 9ab339784218399113bfd0fc381b83492c39548225851e1b67d405abc264fb56630a37713455016f50fb68ca93bff9074f70e51f53b1e57c5a36ebc63cdb6c6a
6
+ metadata.gz: 2e195df3b04bdff44650930f4e1e00ea1cb4839dde2e771d1ce1e482b5c6a0f31e9917cfcc9395bcdfdf97148be98310534b21fc8c65fe4ca2ee622106d4b5b6
7
+ data.tar.gz: c18edf9c671929b543e95171fc6b683eea64a19990a7bab4afd74b2b5d61b441d779099bcd003fad7e720c3b8c2e582bfc66acb9a49f2c8fdbc9bb33c3ea6ccb
@@ -1,6 +1,7 @@
1
1
  module WebConsole
2
2
  # Keys
3
3
  PLUGIN_NAME_KEY = 'WC_PLUGIN_NAME'
4
+ SPLIT_ID_KEY = 'WC_SPLIT_ID'
4
5
  WINDOW_ID_KEY = 'WC_WINDOW_ID'
5
6
  SHARED_RESOURCES_PATH_KEY = 'WC_SHARED_RESOURCES_PATH'
6
7
  SHARED_RESOURCES_URL_KEY = 'WC_SHARED_RESOURCES_URL'
@@ -48,6 +48,13 @@ module WebConsole
48
48
  return result
49
49
  end
50
50
 
51
+ CREATE_WINDOW_SCRIPT = File.join(APPLESCRIPT_DIRECTORY, "create_window.scpt")
52
+ def self.create_window
53
+ result = self.run_applescript(CREATE_WINDOW_SCRIPT)
54
+ result.chomp!
55
+ return result
56
+ end
57
+
51
58
  # Shared Resources
52
59
 
53
60
  RESOURCE_PATH_FOR_PLUGIN_SCRIPT = File.join(APPLESCRIPT_DIRECTORY, "resource_path_for_plugin.scpt")
@@ -1,33 +1,32 @@
1
+ require_relative "window"
1
2
  require_relative "view/javascript"
2
3
  require_relative "view/erb"
3
4
  require_relative "view/resources"
4
5
 
5
6
  module WebConsole
6
- class View
7
-
8
- attr_reader :window
9
- def initialize
10
- @window = WebConsole::Window.new
11
- end
12
-
13
- def base_url=(value)
14
- @window.base_url = value
15
- end
16
-
17
- def base_url_path=(value)
18
- @window.base_url_path = value
19
- end
20
-
21
- def load_html(html)
22
- @window.load_html(html)
7
+ class View < Window
8
+
9
+ # Properties
10
+
11
+ def view_id
12
+ if !@view_id
13
+ if ENV.has_key?(SPLIT_ID_KEY)
14
+ @view_id = ENV[SPLIT_ID_KEY]
15
+ else
16
+ @view_id = split_id
17
+ end
18
+ end
19
+ return @view_id
23
20
  end
24
21
 
25
- def do_javascript(javascript)
26
- return @window.do_javascript(javascript)
27
- end
22
+ private
23
+
24
+ # Web
28
25
 
29
- def close
30
- @window.close
26
+ def arguments_with_target(arguments)
27
+ arguments = super(arguments)
28
+ arguments.push(view_id)
29
+ return arguments
31
30
  end
32
31
 
33
32
  end
@@ -1,5 +1,5 @@
1
1
  module WebConsole
2
- class View
2
+ class View < Window
3
3
 
4
4
  require 'erb'
5
5
 
@@ -1,5 +1,5 @@
1
1
  module WebConsole
2
- class View
2
+ class View < Window
3
3
 
4
4
  def do_javascript_function(function, arguments = nil)
5
5
  javascript = self.class.javascript_function(function, arguments)
@@ -1,5 +1,5 @@
1
1
  module WebConsole
2
- class View
2
+ class View < Window
3
3
  require 'open-uri'
4
4
 
5
5
  require_relative "../constants"
@@ -8,9 +8,24 @@ module WebConsole
8
8
  @window_id = window_id
9
9
  end
10
10
 
11
+ # Properties
12
+
11
13
  def base_url_path=(value)
12
14
  @base_url = "file://" + value
13
15
  end
16
+
17
+ def window_id
18
+ if !@window_id
19
+ if ENV.has_key?(WINDOW_ID_KEY)
20
+ @window_id = ENV[WINDOW_ID_KEY]
21
+ else
22
+ @window_id = WebConsole::create_window
23
+ end
24
+ end
25
+ return @window_id
26
+ end
27
+
28
+ # Web
14
29
 
15
30
  LOADHTML_SCRIPT = File.join(APPLESCRIPT_DIRECTORY, "load_html.scpt")
16
31
  LOADHTMLWITHBASEURL_SCRIPT = File.join(APPLESCRIPT_DIRECTORY, "load_html_with_base_url.scpt")
@@ -24,44 +39,51 @@ module WebConsole
24
39
  arguments.push(@base_url)
25
40
  end
26
41
 
27
- if window_id
28
- arguments.push(window_id)
29
- end
30
-
31
- result = WebConsole::run_applescript(script, arguments)
32
- if !window_id
33
- # This allows a window manager created without a window_id and then be assigned the window_id when load_html is called.
34
- @window_id = self.class.window_id_from_result(result)
35
- end
42
+ return run_script(script, arguments)
36
43
  end
37
44
 
38
45
  DOJAVASCRIPT_SCRIPT = File.join(APPLESCRIPT_DIRECTORY, "do_javascript.scpt")
39
46
  def do_javascript(javascript)
40
- WebConsole::run_applescript(DOJAVASCRIPT_SCRIPT, [javascript, window_id])
47
+ return run_script(DOJAVASCRIPT_SCRIPT, [javascript])
41
48
  end
42
49
 
43
50
  READ_FROM_STANDARD_INPUT_SCRIPT = File.join(APPLESCRIPT_DIRECTORY, "read_from_standard_input.scpt")
44
51
  def read_from_standard_input(text)
45
- WebConsole::run_applescript(READ_FROM_STANDARD_INPUT_SCRIPT, [text, window_id])
52
+ run_script(READ_FROM_STANDARD_INPUT_SCRIPT, [text])
46
53
  end
47
54
 
55
+ # Window
56
+
48
57
  CLOSEWINDOW_SCRIPT = File.join(APPLESCRIPT_DIRECTORY, "close_window.scpt")
49
58
  def close
50
59
  WebConsole::run_applescript(CLOSEWINDOW_SCRIPT, [window_id])
51
60
  end
52
-
53
- def window_id
54
- if !@window_id && ENV.has_key?(WINDOW_ID_KEY)
55
- @window_id = ENV[WINDOW_ID_KEY]
61
+
62
+ SPLIT_ID_IN_WINDOW_SCRIPT = File.join(APPLESCRIPT_DIRECTORY, "split_id_in_window.scpt")
63
+ def split_id(pluginName = nil)
64
+ arguments = [window_id]
65
+
66
+ if pluginName
67
+ arguments.push(pluginName)
56
68
  end
57
- return @window_id
69
+
70
+ result = WebConsole::run_applescript(SPLIT_ID_IN_WINDOW_SCRIPT, arguments)
71
+ result.chomp!
72
+ return result
58
73
  end
59
74
 
60
75
  private
61
-
62
- def self.window_id_from_result(result)
63
- return result.split.last.to_i
76
+
77
+ def run_script(script, arguments = [])
78
+ arguments = arguments_with_target(arguments)
79
+ return WebConsole::run_applescript(script, arguments)
64
80
  end
65
81
 
82
+ def arguments_with_target(arguments)
83
+ arguments.push(window_id)
84
+ return arguments
85
+ end
86
+
87
+
66
88
  end
67
89
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webconsole
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.12
4
+ version: 0.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roben Kleene
@@ -17,13 +17,11 @@ extensions: []
17
17
  extra_rdoc_files: []
18
18
  files:
19
19
  - lib/applescript/close_window.scpt
20
+ - lib/applescript/create_window.scpt
20
21
  - lib/applescript/do_javascript.scpt
21
- - lib/applescript/do_javascript_in_split.scpt
22
22
  - lib/applescript/exists.scpt
23
23
  - lib/applescript/load_html.scpt
24
- - lib/applescript/load_html_in_split.scpt
25
24
  - lib/applescript/load_html_with_base_url.scpt
26
- - lib/applescript/load_html_with_base_url_in_split.scpt
27
25
  - lib/applescript/load_plugin.scpt
28
26
  - lib/applescript/plugin_has_windows.scpt
29
27
  - lib/applescript/read_from_standard_input.scpt
@@ -31,7 +29,7 @@ files:
31
29
  - lib/applescript/resource_url_for_plugin.scpt
32
30
  - lib/applescript/run_plugin.scpt
33
31
  - lib/applescript/run_plugin_in_split.scpt
34
- - lib/applescript/split_id_for_plugin_in_window.scpt
32
+ - lib/applescript/split_id_in_window.scpt
35
33
  - lib/applescript/window_id_for_plugin.scpt
36
34
  - lib/webconsole.rb
37
35
  - lib/webconsole/dependencies.rb