bowser 0.3.0 → 0.4.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
2
  SHA1:
3
- metadata.gz: 58aa512a6c0f6aedea63aeba23ea9079a88bd6df
4
- data.tar.gz: fcecad93587669f19b31b294510defd29d066672
3
+ metadata.gz: 325dcfff506bbe9728a56a3594f1833338781c05
4
+ data.tar.gz: a9d0d2f9de91b17331b001b497bdad966f43532e
5
5
  SHA512:
6
- metadata.gz: fde2064268b7c1fb96826119ed2205284dab29d78acdf3728fcd8d0d6ff44789c98c57aa713403197650700645535ff93355a5b390a3d26f7d6c1c09a2104355
7
- data.tar.gz: 2cea386c54a5cc5a4296cf53c258dbf21073fab9ab195e408752dd50c3b197faf315a42d28df5bb9bd61103c038fb17e5aac19530af85b3e0ee940bb05a8dfd0
6
+ metadata.gz: 5ddfa2eab7464f87677c5da471706ac80e1c2d14251f7013966dc423dba29997b0c57dfad94f1f6eb65afa1b8a4ff117214cfa73d892f533d794fff8995dcd80
7
+ data.tar.gz: 6faa9b7b6b3d78b3ec798f92f46f1e5aedc6d77ff4fd510d41b92d28de61ced407ec551d006966c39f8f06498698c7057c576e6186dafb671052f89835e173c0
@@ -2,6 +2,7 @@ language: ruby
2
2
  rvm:
3
3
  - 2.2.5
4
4
  - 2.3.1
5
+ - 2.4.1
5
6
  - jruby-9.0.5.0
6
7
  - jruby-9.1.1.0
7
8
  before_install:
@@ -1,3 +1,26 @@
1
+ ## Version 0.3.0
2
+
3
+ - Fix bug with falsy JS values as element properties
4
+ - Yield request object in `HTTP` methods (like `.fetch` and `.upload`)
5
+ - Two `Element` instances holding the same native element are equal (`==`)
6
+ - Fix travis + phantomjs 2
7
+ - Add request upload object
8
+ - Add Geolocation support
9
+
10
+ ## Version 0.2.2
11
+
12
+ - Use event.target instead of event.currentTarget for native events
13
+ - Fix spec failure with a more recent `opal-rspec`
14
+ - Remove opal-rspec version restriction
15
+ - Improve native pass-through in Event
16
+ - Allow WebSockets to be closed
17
+
18
+ ## Version 0.2.1
19
+
20
+ - Allow passing data, headers, and method with HTTP.fetch
21
+ - Allow WebSockets to reconnect automatically with configurable delay
22
+ - Relax Opal version restriction
23
+
1
24
  ## Version 0.2.0
2
25
 
3
26
  - Allow specifying methods for HTTP requests, including file uploads
@@ -1,3 +1,3 @@
1
1
  module Bowser
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -0,0 +1,54 @@
1
+ module Bowser
2
+ module DelegateNative
3
+ # Fall back to native properties.
4
+ def method_missing message, *args, &block
5
+ property_name = property_for_message(message)
6
+ property = `#@native[#{property_name}]`
7
+
8
+ # translate setting a property
9
+ if message.end_with? '='
10
+ return `#@native[#{property_name}] = args[0]`
11
+ end
12
+
13
+ # If the native element doesn't have this property, bubble it up
14
+ super if `#{property} === undefined`
15
+
16
+ if `property === false`
17
+ return false
18
+ else
19
+ property = `property == null ? nil : property`
20
+ end
21
+
22
+ # If it's a method, call it. Otherwise, return it.
23
+ if `typeof(property) === 'function'`
24
+ `property.apply(#@native, args)`
25
+ else
26
+ property
27
+ end
28
+ end
29
+
30
+ def respond_to_missing? message, include_all
31
+ return true if message.end_with? '='
32
+ return true if property_for_message(message)
33
+
34
+ false
35
+ end
36
+
37
+ def property_for_message message
38
+ camel_cased_message = message
39
+ .gsub(/_\w/) { |match| `match[1]`.upcase }
40
+ .sub(/=$/, '')
41
+
42
+ # translate `supported?` to `supported` or `isSupported`
43
+ if message.end_with? '?'
44
+ camel_cased_message = camel_cased_message.chop
45
+ property_type = `typeof(#@native[camel_cased_message])`
46
+ if property_type == 'undefined'
47
+ camel_cased_message = "is#{camel_cased_message[0].upcase}#{camel_cased_message[1..-1]}"
48
+ end
49
+ end
50
+
51
+ camel_cased_message
52
+ end
53
+ end
54
+ end
@@ -1,8 +1,10 @@
1
+ require 'bowser/delegate_native'
1
2
  require 'bowser/event_target'
2
3
  require 'bowser/element'
3
4
 
4
5
  module Bowser
5
6
  module Document
7
+ extend DelegateNative
6
8
  extend EventTarget
7
9
 
8
10
  @native = `document`
@@ -1,9 +1,11 @@
1
1
  require 'bowser/event_target'
2
2
  require 'bowser/file_list'
3
+ require 'bowser/delegate_native'
3
4
 
4
5
  module Bowser
5
6
  class Element
6
7
  include EventTarget
8
+ include DelegateNative
7
9
 
8
10
  def initialize native
9
11
  @native = native
@@ -78,45 +80,6 @@ module Bowser
78
80
  FileList.new(`#@native.files`)
79
81
  end
80
82
 
81
- # Fall back to native properties.
82
- def method_missing message, *args, &block
83
- camel_cased_message = message
84
- .gsub(/_\w/) { |match| match[1].upcase }
85
- .sub(/=$/, '')
86
-
87
- # translate setting a property
88
- if message.end_with? '='
89
- return `#@native[camel_cased_message] = args[0]`
90
- end
91
-
92
- # translate `supported?` to `supported` or `isSupported`
93
- if message.end_with? '?'
94
- camel_cased_message = camel_cased_message.chop
95
- property_type = `typeof(#@native[camel_cased_message])`
96
- if property_type == 'undefined'
97
- camel_cased_message = "is#{camel_cased_message[0].upcase}#{camel_cased_message[1..-1]}"
98
- end
99
- end
100
-
101
- # If the native element doesn't have this property, bubble it up
102
- super if `typeof(#@native[camel_cased_message]) === 'undefined'`
103
-
104
- property = `#@native[camel_cased_message]`
105
-
106
- if `property === false`
107
- return false
108
- else
109
- property = `property == null ? nil : property`
110
- end
111
-
112
- # If it's a method, call it. Otherwise, return it.
113
- if `typeof(property) === 'function'`
114
- `property.apply(#@native, args)`
115
- else
116
- property
117
- end
118
- end
119
-
120
83
  def ==(other)
121
84
  `#@native === #{other.to_n}`
122
85
  end
@@ -1,7 +1,9 @@
1
+ require 'bowser/delegate_native'
1
2
  require 'bowser/event_target'
2
3
 
3
4
  module Bowser
4
5
  module Window
6
+ extend DelegateNative
5
7
  extend EventTarget
6
8
 
7
9
  @native = `window`
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bowser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamie Gaskins
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-12-31 00:00:00.000000000 Z
11
+ date: 2017-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opal
@@ -94,6 +94,7 @@ files:
94
94
  - lib/bowser.rb
95
95
  - lib/bowser/version.rb
96
96
  - opal/bowser.rb
97
+ - opal/bowser/delegate_native.rb
97
98
  - opal/bowser/document.rb
98
99
  - opal/bowser/element.rb
99
100
  - opal/bowser/event.rb
@@ -126,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
127
  version: '0'
127
128
  requirements: []
128
129
  rubyforge_project:
129
- rubygems_version: 2.5.1
130
+ rubygems_version: 2.6.11
130
131
  signing_key:
131
132
  specification_version: 4
132
133
  summary: Minimalist browser support for Opal apps