applin-rails 0.0.0 → 0.2.0

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
  SHA256:
3
- metadata.gz: 77b40b177f8a47a6f93c307dc0560b309568139b63623464378576c45aacee89
4
- data.tar.gz: 59b2863cc28d76054a40dabbe79546fe4e011c6718ee921dcaabcdf53ebc530a
3
+ metadata.gz: 1f4baaac83d2c5def4823290b5ef402575bb7eb1ee52bc80bb7c8f1ffaea4b4e
4
+ data.tar.gz: 16620a1a0ace304554362ac721b083c1487eab83cb6bde26b7ff68b382804376
5
5
  SHA512:
6
- metadata.gz: 4cd4ccd6ff7a418832c5776edc9d8012e359173f1f24ba25b2735b3656b0b22d713078d39cbf796d0460acc05e453eff0f7f80947ad9d1b7960d8c02ac5b0ba6
7
- data.tar.gz: 960814c8a0d3740732e4fef1362388a679155711865d0b0f81f429d32dc0c003017ab042ff6fb1677c8ab3d0a8c4c49d86840f85abc217f3074558351e6ce380
6
+ metadata.gz: 741179d035939f3936c966302d2902c54d402afd09664daad8c2de9298bb875c7d20bb2d3d455766c4e75480f5a4d432b7f9df117a1c7f038f2468f8bed30284
7
+ data.tar.gz: f9c61d68b0e09010f4c82ae6100bc321f8cac684c695b56c460c08444b13b1e3ac976c86d050b35191e4d90bd2d5589c0f3552e4103862ad62f236452e402039
data/.rubocop.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.6
2
+ TargetRubyVersion: 3.2
3
3
 
4
4
  Style/StringLiterals:
5
5
  Enabled: true
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
- ## Installation
8
+ ## Install
9
+ To add the gem to your Rails application:
9
10
 
10
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
11
+ $ bundle add applin-rails
11
12
 
12
- Install the gem and add to the application's Gemfile by executing:
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
- Bug reports and pull requests are welcome on GitHub at https://github.com/leonhard-llc/applin-rails.
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>.
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Applin
4
4
  module Rails
5
- VERSION = "0.0.0"
5
+ VERSION = "0.2.0"
6
6
  end
7
7
  end
data/lib/applin/rails.rb CHANGED
@@ -1,10 +1,244 @@
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
- class Error < StandardError; end
8
- # Your code goes here...
15
+ ALIGN_CENTER = "center"
16
+ ALIGN_END = "end"
17
+ ALIGN_START = "start"
18
+ ALLOW_ALL = "all"
19
+ ALLOW_ASCII = "ascii"
20
+ ALLOW_EMAIL = "email"
21
+ ALLOW_NUMBERS = "numbers"
22
+ ALLOW_TEL = "tel"
23
+ AUTO_CAPITALIZE_NAMES = "names"
24
+ AUTO_CAPITALIZE_SENTENCES = "sentences"
25
+ DISPOSITION_FIT = "fit"
26
+ DISPOSITION_STRETCH = "stretch"
27
+ DISPOSITION_COVER = "cover"
28
+
29
+ def send_page(page, options = {})
30
+ body = { page: page }.to_json
31
+ options[:type] = Mime[:applin_response]
32
+ send_data body, options
33
+ end
34
+
35
+ def back_button(actions:)
36
+ { typ: :back_button, actions: actions }
37
+ end
38
+
39
+ def button(text:, actions:)
40
+ { typ: :button, text: text, actions: actions }
41
+ end
42
+
43
+ def checkbox(text:, var_name:, actions: nil, initial_bool: nil, rpc: nil)
44
+ {
45
+ typ: :checkbox,
46
+ actions: actions,
47
+ initial_bool: initial_bool,
48
+ rpc: rpc,
49
+ text: text,
50
+ var_name: var_name,
51
+ }.reject { |_k, v| v.nil? }
52
+ end
53
+
54
+ def column(widgets:, align: nil, spacing: nil)
55
+ { typ: :column, align: align, spacing: spacing, widgets: widgets }.reject { |_k, v| v.nil? }
56
+ end
57
+
58
+ def empty
59
+ { typ: :empty }
60
+ end
61
+
62
+ def error_text(text)
63
+ { typ: :error_text, text: text }
64
+ end
65
+
66
+ def form(widgets:)
67
+ { typ: :form, widgets: widgets }
68
+ end
69
+
70
+ def form_button(text:, actions:, align: nil)
71
+ { typ: :form_button, align: align, text: text, actions: actions }.reject { |_k, v| v.nil? }
72
+ end
73
+
74
+ def form_section(widgets:, title: nil)
75
+ { typ: :form_section, title: title, widgets: widgets }.reject { |_k, v| v.nil? }
76
+ end
77
+
78
+ # `row_groups` is a an array of arrays of widgets.
79
+ def grouped_row_table(row_groups:, spacing: nil)
80
+ { typ: :grouped_row_table, spacing: spacing, row_groups: row_groups }.reject { |_k, v| v.nil? }
81
+ end
82
+
83
+ # Pass one of the DISPOSITION_* values for the `disposition` parameter.
84
+ def image(aspect_ratio:, url:, disposition: nil)
85
+ { typ: :image, disposition: disposition, aspect_ratio: aspect_ratio, url: url }.reject { |_k, v| v.nil? }
86
+ end
87
+
88
+ def last_error_text
89
+ { typ: :last_error_text }
90
+ end
91
+
92
+ def modal_button(text:, actions:, is_cancel: nil, is_default: nil, is_destructive: nil)
93
+ {
94
+ typ: :modal_button,
95
+ is_cancel: is_cancel,
96
+ is_default: is_default,
97
+ is_destructive: is_destructive,
98
+ text: text,
99
+ actions: actions,
100
+ }.reject { |_k, v| v.nil? }
101
+ end
102
+
103
+ def ok_modal_button(is_default: true)
104
+ modal_button(text: "OK", is_default: is_default, actions: [pop])
105
+ end
106
+
107
+ def cancel_modal_button(is_default: false)
108
+ modal_button(text: "Cancel", is_default: is_default, actions: [pop])
109
+ end
110
+
111
+ def nav_button(text:, actions:, badge_text: nil, photo_url: nil, sub_text: nil)
112
+ {
113
+ typ: :nav_button,
114
+ badge_text: badge_text,
115
+ photo_url: photo_url,
116
+ sub_text: sub_text,
117
+ text: text,
118
+ actions: actions,
119
+ }.reject { |_k, v| v.nil? }
120
+ end
121
+
122
+ def scroll(&widget_block)
123
+ { typ: :scroll, widget: widget_block.yield }
124
+ end
125
+
126
+ def text(text)
127
+ { typ: :text, text: text }
128
+ end
129
+
130
+ # Pass one of the ALLOW_* values for `allow`.
131
+ # Pass one of the AUTO_CAPITALIZE_* values for `auto_capitalize`.
132
+ def textfield(
133
+ var_name:, allow: nil,
134
+ auto_capitalize: nil,
135
+ error: nil,
136
+ initial_string: nil,
137
+ label: nil,
138
+ max_chars: nil,
139
+ max_lines: nil,
140
+ min_chars: nil
141
+ )
142
+ {
143
+ typ: :textfield,
144
+ allow: allow,
145
+ auto_capitalize: auto_capitalize,
146
+ error: error,
147
+ initial_string: initial_string,
148
+ label: label,
149
+ max_chars: max_chars,
150
+ max_lines: max_lines,
151
+ min_chars: min_chars,
152
+ var_name: var_name,
153
+ }.reject { |_k, v| v.nil? }
154
+ end
155
+
156
+ def alert_modal(title:, modal_buttons:, stream: nil, poll_seconds: nil, text: nil)
157
+ {
158
+ typ: :alert_modal,
159
+ stream: stream,
160
+ poll_seconds: poll_seconds,
161
+ text: text,
162
+ title: title,
163
+ widgets: modal_buttons
164
+ }.reject { |_k, v| v.nil? }
165
+ end
166
+
167
+ def drawer_modal(title:, modal_buttons:, stream: nil, poll_seconds: nil, text: nil)
168
+ {
169
+ typ: :drawer_modal,
170
+ stream: stream,
171
+ poll_seconds: poll_seconds,
172
+ text: text,
173
+ title: title,
174
+ widgets: modal_buttons
175
+ }.reject { |_k, v| v.nil? }
176
+ end
177
+
178
+ def nav_page(title:, start: nil, end_: nil, stream: nil, poll_seconds: nil, &widget_block)
179
+ {
180
+ typ: :nav_page,
181
+ start: start,
182
+ end: end_,
183
+ title: title,
184
+ stream: stream,
185
+ poll_seconds: poll_seconds,
186
+ widget: widget_block.yield
187
+ }.reject { |_k, v| v.nil? }
188
+ end
189
+
190
+ def plain_page(title: nil, stream: nil, poll_seconds: nil, &widget_block)
191
+ {
192
+ typ: :plain_page,
193
+ title: title,
194
+ stream: stream,
195
+ poll_seconds: poll_seconds,
196
+ widget: widget_block.yield
197
+ }.reject { |_k, v| v.nil? }
198
+ end
199
+
200
+ def choose_photo(upload_url:)
201
+ "choose_photo:#{upload_url}"
202
+ end
203
+
204
+ def copy_to_clipboard(text)
205
+ "copy_to_clipboard:#{text}"
206
+ end
207
+
208
+ def launch_url(url)
209
+ "launch_url:#{url}"
210
+ end
211
+
212
+ def logout
213
+ "logout"
214
+ end
215
+
216
+ def nothing
217
+ "nothing"
218
+ end
219
+
220
+ def poll
221
+ "poll"
222
+ end
223
+
224
+ def pop
225
+ "pop"
226
+ end
227
+
228
+ def push(page_key)
229
+ "push:#{page_key}"
230
+ end
231
+
232
+ def replace_all(page_key)
233
+ "replace_all:#{page_key}"
234
+ end
235
+
236
+ def rpc(url)
237
+ "rpc:#{url}"
238
+ end
239
+
240
+ def take_photo(upload_url:)
241
+ "take_photo:#{upload_url}"
242
+ end
9
243
  end
10
244
  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.0.0
4
+ version: 0.2.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-08-28 00:00:00.000000000 Z
11
+ date: 2023-09-04 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.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