ruby_native 0.10.11 → 0.10.14
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/app/controllers/ruby_native/push/devices_controller.rb +11 -1
- data/lib/ruby_native/cli/preview.rb +2 -1
- data/lib/ruby_native/helper.rb +41 -7
- data/lib/ruby_native/version.rb +1 -1
- data/lib/ruby_native.rb +6 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7b83fa869135734b170e4b23a8ca46984c54ea5b830326af54003f1a9006830a
|
|
4
|
+
data.tar.gz: 84e8db6d56e06beb29933463939dfa970d90bc652f52e68bd0b5ad8f41dc273f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c555bdb8ff38ae5a851b81a733aed0554949b1d15352de103f7c90415a56a2b8ce8a21acd5f1724e8b6ebd648ba1a875a9b03f86b1d150f451b53369c2fb23f5
|
|
7
|
+
data.tar.gz: 7de2e7778924c227c6501201af4a5d233c4b1000a99edc93f5074c824526ce248c7cd8d98fa3f963a9935deae69c92fa8f74cf920c3f1e731415545ff80f329a
|
|
@@ -4,10 +4,20 @@ module RubyNative
|
|
|
4
4
|
skip_forgery_protection
|
|
5
5
|
|
|
6
6
|
def create
|
|
7
|
-
device =
|
|
7
|
+
device = ruby_native_user.push_devices.find_or_initialize_by(token: params[:token])
|
|
8
8
|
device.update!(platform: params[:platform], name: params[:name])
|
|
9
9
|
head :ok
|
|
10
10
|
end
|
|
11
|
+
|
|
12
|
+
private
|
|
13
|
+
|
|
14
|
+
# Resolves the signed-in user via RubyNative.current_user_resolver, which is
|
|
15
|
+
# either a controller method name (Symbol) or a callable run in the
|
|
16
|
+
# controller. Defaults to `current_user`.
|
|
17
|
+
def ruby_native_user
|
|
18
|
+
resolver = RubyNative.current_user_resolver
|
|
19
|
+
resolver.respond_to?(:call) ? instance_exec(&resolver) : send(resolver)
|
|
20
|
+
end
|
|
11
21
|
end
|
|
12
22
|
end
|
|
13
23
|
end
|
|
@@ -187,7 +187,8 @@ module RubyNative
|
|
|
187
187
|
puts ""
|
|
188
188
|
puts url
|
|
189
189
|
puts ""
|
|
190
|
-
puts "Scan the QR code or paste the URL into the Ruby Native
|
|
190
|
+
puts "Scan the QR code or paste the URL into the Ruby Native app."
|
|
191
|
+
puts "Don't have it yet? Download it at https://rubynative.com/try/download"
|
|
191
192
|
if @url
|
|
192
193
|
puts "Keep this running and your Rails server reachable at #{@url}."
|
|
193
194
|
else
|
data/lib/ruby_native/helper.rb
CHANGED
|
@@ -120,12 +120,25 @@ module RubyNative
|
|
|
120
120
|
if block
|
|
121
121
|
menu = NavbarMenuBuilder.new(@context)
|
|
122
122
|
@context.capture(menu, &block)
|
|
123
|
-
@
|
|
123
|
+
add(@context.tag.div(data: data) { menu.to_html })
|
|
124
124
|
else
|
|
125
|
-
@
|
|
125
|
+
add(@context.tag.div(data: data))
|
|
126
126
|
end
|
|
127
127
|
end
|
|
128
128
|
|
|
129
|
+
# Adds a segment to the nav bar. On iOS the segments render as a centered
|
|
130
|
+
# segmented control (the same control the App Store uses for Apps/Games).
|
|
131
|
+
# Mark the current page's segment `selected: true`. Tapping a segment
|
|
132
|
+
# navigates to its `href` (or clicks the `click` selector), replacing
|
|
133
|
+
# history so the back button doesn't walk back through segment switches.
|
|
134
|
+
def segment(title, href: nil, click: nil, selected: false)
|
|
135
|
+
data = { native_segment: "", native_title: title }
|
|
136
|
+
data[:native_href] = href if href
|
|
137
|
+
data[:native_click] = click if click
|
|
138
|
+
data[:native_selected] = "" if selected
|
|
139
|
+
add(@context.tag.div(data: data))
|
|
140
|
+
end
|
|
141
|
+
|
|
129
142
|
# Adds a native share button to the nav bar. Tapping it opens the
|
|
130
143
|
# platform share sheet for `url:` (defaults to the current page on the
|
|
131
144
|
# web side) so it works even where embedded web views don't support
|
|
@@ -139,20 +152,32 @@ module RubyNative
|
|
|
139
152
|
data[:native_icon] = resolved if resolved
|
|
140
153
|
data[:native_position] = position.to_s
|
|
141
154
|
data[:native_share_url] = url if url
|
|
142
|
-
@
|
|
155
|
+
add(@context.tag.div(data: data))
|
|
143
156
|
end
|
|
144
157
|
|
|
145
158
|
def submit_button(title: "Save", click: "[type='submit']")
|
|
146
|
-
@
|
|
159
|
+
add(@context.tag.div(data: {
|
|
147
160
|
native_submit_button: "",
|
|
148
161
|
native_title: title,
|
|
149
162
|
native_click: click
|
|
150
|
-
})
|
|
163
|
+
}))
|
|
151
164
|
end
|
|
152
165
|
|
|
153
166
|
def to_html
|
|
154
167
|
@context.safe_join(@items)
|
|
155
168
|
end
|
|
169
|
+
|
|
170
|
+
private
|
|
171
|
+
|
|
172
|
+
# Collects a signal element and returns a blank, html-safe string. That
|
|
173
|
+
# lets the builder read naturally with `<%=` in ERB (`<%= navbar.button %>`)
|
|
174
|
+
# without emitting anything, since the nav bar renders from the collected
|
|
175
|
+
# items in `to_html`, not from these return values. Silent `<% %>` tags
|
|
176
|
+
# keep working too.
|
|
177
|
+
def add(item)
|
|
178
|
+
@items << item
|
|
179
|
+
ActiveSupport::SafeBuffer.new
|
|
180
|
+
end
|
|
156
181
|
end
|
|
157
182
|
|
|
158
183
|
class NavbarMenuBuilder
|
|
@@ -168,7 +193,7 @@ module RubyNative
|
|
|
168
193
|
data[:native_click] = click if click
|
|
169
194
|
data[:native_icon] = resolved if resolved
|
|
170
195
|
data[:native_selected] = "" if selected
|
|
171
|
-
@
|
|
196
|
+
add(@context.tag.div(data: data))
|
|
172
197
|
end
|
|
173
198
|
|
|
174
199
|
# Adds a share entry to a navbar button's dropdown menu. Selecting it
|
|
@@ -181,12 +206,21 @@ module RubyNative
|
|
|
181
206
|
data[:native_share_url] = url if url
|
|
182
207
|
data[:native_icon] = resolved if resolved
|
|
183
208
|
data[:native_selected] = "" if selected
|
|
184
|
-
@
|
|
209
|
+
add(@context.tag.div(data: data))
|
|
185
210
|
end
|
|
186
211
|
|
|
187
212
|
def to_html
|
|
188
213
|
@context.safe_join(@items)
|
|
189
214
|
end
|
|
215
|
+
|
|
216
|
+
private
|
|
217
|
+
|
|
218
|
+
# See NavbarBuilder#add: collects the item and returns a blank, html-safe
|
|
219
|
+
# string so menu items read naturally with `<%= menu.item %>` in ERB.
|
|
220
|
+
def add(item)
|
|
221
|
+
@items << item
|
|
222
|
+
ActiveSupport::SafeBuffer.new
|
|
223
|
+
end
|
|
190
224
|
end
|
|
191
225
|
end
|
|
192
226
|
end
|
data/lib/ruby_native/version.rb
CHANGED
data/lib/ruby_native.rb
CHANGED
|
@@ -22,6 +22,12 @@ module RubyNative
|
|
|
22
22
|
mattr_accessor :screenshot_key
|
|
23
23
|
mattr_accessor :screenshot_sign_in
|
|
24
24
|
|
|
25
|
+
# How the push endpoint finds the signed-in user to attach a device token to.
|
|
26
|
+
# Accepts a controller method name (Symbol) or a callable evaluated in the
|
|
27
|
+
# controller, e.g. `-> { Current.person }`. Defaults to `current_user`, so
|
|
28
|
+
# Devise apps need no configuration. Set via `RubyNative.configure`.
|
|
29
|
+
mattr_accessor :current_user_resolver, default: :current_user
|
|
30
|
+
|
|
25
31
|
def self.configure
|
|
26
32
|
yield self
|
|
27
33
|
end
|