applin-rails 0.0.0 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/README.md +16 -20
- data/lib/applin/rails/version.rb +1 -1
- data/lib/applin/rails.rb +225 -3
- metadata +3 -4
- data/applin-rails.gemspec +0 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71496dc04565f772229aed6620f06fc3811dde1c27e79cbbaf633ab29ae0b68e
|
4
|
+
data.tar.gz: 2ad83dab974f051d2a9f4e2786c2443a16440a3bb755925acb7bdb15a6dd8608
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac763ea0188317507869791364a8fe36db1afe2608fc0518b51f308443e711f58cdc3e28d5965109dee438a83d69dace4cb0a331f639becf6b08c47689079dea
|
7
|
+
data.tar.gz: 502953b3f347a3b5f31d2085c321ecfddfb0263ec7bbe8f279f70448b6095e250189790b164b59635d7a7c488c574f3e90295a424acbb0e42095aea53ef31477
|
data/.rubocop.yml
CHANGED
data/README.md
CHANGED
@@ -5,28 +5,24 @@ https://www.applin.dev/
|
|
5
5
|
|
6
6
|
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/applin/rails`. To experiment with that code, run `bin/console` for an interactive prompt.
|
7
7
|
|
8
|
-
##
|
8
|
+
## Install
|
9
|
+
To add the gem to your Rails application:
|
9
10
|
|
10
|
-
|
11
|
+
$ bundle add applin-rails
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
$ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
|
15
|
-
|
16
|
-
If bundler is not being used to manage dependencies, install the gem by executing:
|
17
|
-
|
18
|
-
$ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
|
19
|
-
|
20
|
-
## Usage
|
21
|
-
|
22
|
-
TODO: Write usage instructions here
|
23
|
-
|
24
|
-
## Development
|
25
|
-
|
26
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
27
|
-
|
28
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
13
|
+
## Use
|
14
|
+
TODO
|
29
15
|
|
30
16
|
## Contributing
|
17
|
+
Bug reports and pull requests are welcome on GitHub at <https://github.com/leonhard-llc/applin-rails>.
|
31
18
|
|
32
|
-
|
19
|
+
## Development
|
20
|
+
* Install dependencies: `bin/setup`
|
21
|
+
* `rake test`
|
22
|
+
* `bin/console`
|
23
|
+
|
24
|
+
To release a new version:
|
25
|
+
1. Install the gem onto your local machine: `bundle exec rake install`
|
26
|
+
2. Test it with <https://github.com/leonhard-llc/applin-rails-example>
|
27
|
+
1. Update the version number in `version.rb`
|
28
|
+
1. Run `bundle exec rake release`. This will create a git tag, make a `.gem` file, and push the file to <https://rubygems.org>.
|
data/lib/applin/rails/version.rb
CHANGED
data/lib/applin/rails.rb
CHANGED
@@ -1,10 +1,232 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
3
2
|
require_relative "rails/version"
|
4
3
|
|
4
|
+
# https://guides.rubyonrails.org/action_controller_overview.html#restful-downloads
|
5
|
+
Mime::Type.register "application/vnd.applin_response", :applin_response
|
6
|
+
|
7
|
+
ActionController::Renderers.add :applin_response do |obj, options|
|
8
|
+
body = { page: obj }.to_json
|
9
|
+
options[:type] = Mime[:applin_response]
|
10
|
+
send_data body, options
|
11
|
+
end
|
12
|
+
|
5
13
|
module Applin
|
6
14
|
module Rails
|
7
|
-
|
8
|
-
|
15
|
+
ALLOW_ALL = "all"
|
16
|
+
ALLOW_ASCII = "ascii"
|
17
|
+
ALLOW_EMAIL = "email"
|
18
|
+
ALLOW_NUMBERS = "numbers"
|
19
|
+
ALLOW_TEL = "tel"
|
20
|
+
AUTO_CAPITALIZE_NAMES = "names"
|
21
|
+
AUTO_CAPITALIZE_SENTENCES = "sentences"
|
22
|
+
DISPOSITION_FIT = "fit"
|
23
|
+
DISPOSITION_STRETCH = "stretch"
|
24
|
+
DISPOSITION_COVER = "cover"
|
25
|
+
|
26
|
+
def send_page(page, options = {})
|
27
|
+
body = { page: page }.to_json
|
28
|
+
options[:type] = Mime[:applin_response]
|
29
|
+
send_data body, options
|
30
|
+
end
|
31
|
+
|
32
|
+
def back_button(actions:)
|
33
|
+
{ typ: :back_button, actions: actions }
|
34
|
+
end
|
35
|
+
|
36
|
+
def button(text:, actions:)
|
37
|
+
{ typ: :button, text: text, actions: actions }
|
38
|
+
end
|
39
|
+
|
40
|
+
def checkbox(text:, var_name:, actions: nil, initial_bool: nil)
|
41
|
+
{
|
42
|
+
typ: :checkbox,
|
43
|
+
actions: actions,
|
44
|
+
initial_bool: initial_bool,
|
45
|
+
text: text,
|
46
|
+
var_name: var_name,
|
47
|
+
}.reject { |_k, v| v.nil? }
|
48
|
+
end
|
49
|
+
|
50
|
+
def column(widgets:, alignment: nil, spacing: nil)
|
51
|
+
{ typ: :column, alignment: alignment, spacing: spacing, widgets: widgets }.reject { |_k, v| v.nil? }
|
52
|
+
end
|
53
|
+
|
54
|
+
def empty
|
55
|
+
{ typ: :empty }
|
56
|
+
end
|
57
|
+
|
58
|
+
def error_text(text)
|
59
|
+
{ typ: :error_text, text: text }
|
60
|
+
end
|
61
|
+
|
62
|
+
def form(widgets:)
|
63
|
+
{ typ: :form, widgets: widgets }
|
64
|
+
end
|
65
|
+
|
66
|
+
def form_button(text:, actions:, alignment: nil)
|
67
|
+
{ typ: :form_button, alignment: alignment, text: text, actions: actions }.reject { |_k, v| v.nil? }
|
68
|
+
end
|
69
|
+
|
70
|
+
def form_section(widgets:, title: nil)
|
71
|
+
{ typ: :form_section, title: title, widgets: widgets }.reject { |_k, v| v.nil? }
|
72
|
+
end
|
73
|
+
|
74
|
+
# `row_groups` is a an array of arrays of widgets.
|
75
|
+
def grouped_row_table(row_groups:, spacing: nil)
|
76
|
+
{ typ: :grouped_row_table, spacing: spacing, row_groups: row_groups }.reject { |_k, v| v.nil? }
|
77
|
+
end
|
78
|
+
|
79
|
+
# Pass one of the DISPOSITION_* values for the `disposition` parameter.
|
80
|
+
def image(aspect_ratio:, url:, disposition: nil)
|
81
|
+
{ typ: :image, disposition: disposition, aspect_ratio: aspect_ratio, url: url }.reject { |_k, v| v.nil? }
|
82
|
+
end
|
83
|
+
|
84
|
+
def last_error_text
|
85
|
+
{ typ: :last_error_text }
|
86
|
+
end
|
87
|
+
|
88
|
+
def modal_button(text:, actions:, is_cancel: nil, is_default: nil, is_destructive: nil)
|
89
|
+
{
|
90
|
+
typ: :modal_button,
|
91
|
+
is_cancel: is_cancel,
|
92
|
+
is_default: is_default,
|
93
|
+
is_destructive: is_destructive,
|
94
|
+
text: text,
|
95
|
+
actions: actions,
|
96
|
+
}.reject { |_k, v| v.nil? }
|
97
|
+
end
|
98
|
+
|
99
|
+
def nav_button(text:, actions:, badge_text: nil, photo_url: nil, sub_text: nil)
|
100
|
+
{
|
101
|
+
typ: :nav_button,
|
102
|
+
badge_text: badge_text,
|
103
|
+
photo_url: photo_url,
|
104
|
+
sub_text: sub_text,
|
105
|
+
text: text,
|
106
|
+
actions: actions,
|
107
|
+
}.reject { |_k, v| v.nil? }
|
108
|
+
end
|
109
|
+
|
110
|
+
def scroll(&widget_block)
|
111
|
+
{ typ: :scroll, widget: widget_block.yield }
|
112
|
+
end
|
113
|
+
|
114
|
+
def text(text)
|
115
|
+
{ typ: :text, text: text }
|
116
|
+
end
|
117
|
+
|
118
|
+
# Pass one of the ALLOW_* values for `allow`.
|
119
|
+
# Pass one of the AUTO_CAPITALIZE_* values for `auto_capitalize`.
|
120
|
+
def textfield(
|
121
|
+
var_name:, allow: nil,
|
122
|
+
auto_capitalize: nil,
|
123
|
+
error: nil,
|
124
|
+
initial_string: nil,
|
125
|
+
label: nil,
|
126
|
+
max_chars: nil,
|
127
|
+
max_lines: nil,
|
128
|
+
min_chars: nil
|
129
|
+
)
|
130
|
+
{
|
131
|
+
typ: :textfield,
|
132
|
+
allow: allow,
|
133
|
+
auto_capitalize: auto_capitalize,
|
134
|
+
error: error,
|
135
|
+
initial_string: initial_string,
|
136
|
+
label: label,
|
137
|
+
max_chars: max_chars,
|
138
|
+
max_lines: max_lines,
|
139
|
+
min_chars: min_chars,
|
140
|
+
var_name: var_name,
|
141
|
+
}.reject { |_k, v| v.nil? }
|
142
|
+
end
|
143
|
+
|
144
|
+
def alert_modal(title:, modal_buttons:, stream: nil, poll_seconds: nil, text: nil)
|
145
|
+
{
|
146
|
+
typ: :alert_modal,
|
147
|
+
stream: stream,
|
148
|
+
poll_seconds: poll_seconds,
|
149
|
+
text: text,
|
150
|
+
title: title,
|
151
|
+
modal_buttons: modal_buttons
|
152
|
+
}.reject { |_k, v| v.nil? }
|
153
|
+
end
|
154
|
+
|
155
|
+
def drawer_modal(title:, modal_buttons:, stream: nil, poll_seconds: nil, text: nil)
|
156
|
+
{
|
157
|
+
typ: :drawer_modal,
|
158
|
+
stream: stream,
|
159
|
+
poll_seconds: poll_seconds,
|
160
|
+
text: text,
|
161
|
+
title: title,
|
162
|
+
modal_buttons: modal_buttons
|
163
|
+
}.reject { |_k, v| v.nil? }
|
164
|
+
end
|
165
|
+
|
166
|
+
def nav_page(title:, start: nil, end_: nil, stream: nil, poll_seconds: nil, &widget_block)
|
167
|
+
{
|
168
|
+
typ: :plain_page,
|
169
|
+
start: start,
|
170
|
+
end: end_,
|
171
|
+
title: title,
|
172
|
+
stream: stream,
|
173
|
+
poll_seconds: poll_seconds,
|
174
|
+
widget: widget_block.yield
|
175
|
+
}.reject { |_k, v| v.nil? }
|
176
|
+
end
|
177
|
+
|
178
|
+
def plain_page(title: nil, stream: nil, poll_seconds: nil, &widget_block)
|
179
|
+
{
|
180
|
+
typ: :plain_page,
|
181
|
+
title: title,
|
182
|
+
stream: stream,
|
183
|
+
poll_seconds: poll_seconds,
|
184
|
+
widget: widget_block.yield
|
185
|
+
}.reject { |_k, v| v.nil? }
|
186
|
+
end
|
187
|
+
|
188
|
+
def choose_photo(upload_url:)
|
189
|
+
"choose_photo:#{upload_url}"
|
190
|
+
end
|
191
|
+
|
192
|
+
def copy_to_clipboard(text)
|
193
|
+
"copy_to_clipboard:#{text}"
|
194
|
+
end
|
195
|
+
|
196
|
+
def launch_url(url)
|
197
|
+
"launch_url:#{url}"
|
198
|
+
end
|
199
|
+
|
200
|
+
def logout
|
201
|
+
"logout"
|
202
|
+
end
|
203
|
+
|
204
|
+
def nothing
|
205
|
+
"nothing"
|
206
|
+
end
|
207
|
+
|
208
|
+
def poll
|
209
|
+
"poll"
|
210
|
+
end
|
211
|
+
|
212
|
+
def pop
|
213
|
+
"pop"
|
214
|
+
end
|
215
|
+
|
216
|
+
def push(page_key)
|
217
|
+
"push:#{page_key}"
|
218
|
+
end
|
219
|
+
|
220
|
+
def replace_all(page_key)
|
221
|
+
"replace_all:#{page_key}"
|
222
|
+
end
|
223
|
+
|
224
|
+
def rpc(url)
|
225
|
+
"rpc:#{url}"
|
226
|
+
end
|
227
|
+
|
228
|
+
def take_photo(upload_url:)
|
229
|
+
"take_photo:#{upload_url}"
|
230
|
+
end
|
9
231
|
end
|
10
232
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: applin-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Leonhard
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Create mobile apps using only backend code. Applin™ is a Server-Driven
|
14
14
|
UI (SDUI) system.
|
@@ -23,7 +23,6 @@ files:
|
|
23
23
|
- LICENSE.md
|
24
24
|
- README.md
|
25
25
|
- Rakefile
|
26
|
-
- applin-rails.gemspec
|
27
26
|
- lib/applin/rails.rb
|
28
27
|
- lib/applin/rails/version.rb
|
29
28
|
- sig/applin/rails.rbs
|
@@ -42,7 +41,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
42
41
|
requirements:
|
43
42
|
- - ">="
|
44
43
|
- !ruby/object:Gem::Version
|
45
|
-
version: 3.2
|
44
|
+
version: '3.2'
|
46
45
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
47
46
|
requirements:
|
48
47
|
- - ">="
|
data/applin-rails.gemspec
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "lib/applin/rails/version"
|
4
|
-
|
5
|
-
Gem::Specification.new do |spec|
|
6
|
-
# https://guides.rubygems.org/publishing/
|
7
|
-
# https://guides.rubygems.org/specification-reference/
|
8
|
-
spec.name = "applin-rails"
|
9
|
-
spec.version = Applin::Rails::VERSION
|
10
|
-
spec.authors = ["Michael Leonhard"]
|
11
|
-
spec.email = ["michael@leonhardllc.com"]
|
12
|
-
spec.summary = "Applin™ server library for Ruby on Rails"
|
13
|
-
spec.description = "Create mobile apps using only backend code. Applin™ is a Server-Driven UI (SDUI) system."
|
14
|
-
spec.homepage = "https://www.applin.dev/"
|
15
|
-
spec.license = "LicenseRef-LICENSE.md"
|
16
|
-
spec.required_ruby_version = ">= 3.2.2"
|
17
|
-
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
-
spec.metadata["source_code_uri"] = "https://github.com/leonhard-llc/applin-rails"
|
19
|
-
spec.metadata["changelog_uri"] = "https://raw.githubusercontent.com/leonhard-llc/applin-rails/main/CHANGELOG.md"
|
20
|
-
|
21
|
-
# Specify which files should be added to the gem when it is released.
|
22
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
-
spec.files = Dir.chdir(__dir__) do
|
24
|
-
`git ls-files -z`.split("\x0").reject do |f|
|
25
|
-
(File.expand_path(f) == __FILE__) ||
|
26
|
-
f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor Gemfile])
|
27
|
-
end
|
28
|
-
end
|
29
|
-
spec.bindir = "exe"
|
30
|
-
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
31
|
-
spec.require_paths = ["lib"]
|
32
|
-
|
33
|
-
# Uncomment to register a new dependency of your gem
|
34
|
-
# spec.add_dependency "example-gem", "~> 1.0"
|
35
|
-
|
36
|
-
# For more information and examples about making a new gem, check out our
|
37
|
-
# guide at: https://bundler.io/guides/creating_gem.html
|
38
|
-
end
|