ruby_native 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b95fa93f1758ce5b7425891875f07a5c8ec5f97f04cb7dc8714f945181aee1e4
4
+ data.tar.gz: 2d7648eed1498803d7e7b7a49f77e8e2613c3a54b583091ab236575acfd45d22
5
+ SHA512:
6
+ metadata.gz: 7458f250f336e7fb332bf1dda557a82117eb9bbc67d1eb581cc5656a677aa97ff2ab60a1c987c5a7aa6feae287345497d56dcbdf9c3733d33004ce413a491f11
7
+ data.tar.gz: 4db4b2a5bf35a5d41ded39ce96946db3c94609bcc26a15463f8adac606dad45fa732517905fa681272207e8fc6cadf30cca362b69d3ad581ae5497ba66b9326b
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Joe Masilotti
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,62 @@
1
+ # ruby_native gem
2
+
3
+ A Rails engine that provides native detection, configuration, push device registration, and view helpers for Ruby Native iOS and Android apps.
4
+
5
+ ## Installation
6
+
7
+ ```ruby
8
+ gem "ruby_native", path: "../../gem" # local development
9
+ ```
10
+
11
+ Then mount the engine in `config/routes.rb`:
12
+
13
+ ```ruby
14
+ Rails.application.routes.draw do
15
+ mount RubyNative::Engine => "/native"
16
+ end
17
+ ```
18
+
19
+ ## Configuration
20
+
21
+ Create `config/ruby_native.yml`:
22
+
23
+ ```yaml
24
+ app:
25
+ name: My App
26
+ appearance:
27
+ tint_color: "#4F46E5"
28
+ background_color: "#FFFFFF"
29
+ status_bar: dark
30
+ status_bar_color: "#FFFFFF"
31
+ tabs:
32
+ - title: Home
33
+ path: /
34
+ icon: house
35
+ - title: Profile
36
+ path: /profile
37
+ icon: person
38
+ ```
39
+
40
+ ## Endpoints
41
+
42
+ - `GET /native/config` - returns the YAML config as JSON
43
+ - `POST /native/push/devices` - registers a push notification token (requires `current_user` from host app)
44
+
45
+ ## View helpers
46
+
47
+ - `native_app?` - true when the request comes from a Ruby Native app (checks user agent)
48
+ - `native_tabs_tag` - renders a hidden signal element for tab bar detection
49
+ - `native_form_tag` - renders a hidden signal element marking the page as a form
50
+ - `native_push_tag` - renders a hidden signal element requesting push permission
51
+
52
+ Signal elements are hidden `<div>` tags with data attributes (e.g., `<div data-native-tabs hidden>`). Place them in the `<body>`, not the `<head>`.
53
+
54
+ ## Stylesheet
55
+
56
+ The gem includes `ruby_native.css` which controls back button visibility:
57
+
58
+ ```erb
59
+ <%= stylesheet_link_tag :ruby_native %>
60
+ ```
61
+
62
+ This shows `.native-back-button` elements only when `body.can-go-back` is set by the native app.
@@ -0,0 +1,7 @@
1
+ .native-back-button {
2
+ display: none;
3
+ }
4
+
5
+ body.can-go-back .native-back-button {
6
+ display: inline;
7
+ }
@@ -0,0 +1,7 @@
1
+ module RubyNative
2
+ class ConfigController < ::ActionController::Base
3
+ def show
4
+ render json: RubyNative.config
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,13 @@
1
+ module RubyNative
2
+ module Push
3
+ class DevicesController < ::ApplicationController
4
+ skip_forgery_protection
5
+
6
+ def create
7
+ device = current_user.push_devices.find_or_initialize_by(token: params[:token])
8
+ device.update!(platform: params[:platform], name: params[:name])
9
+ head :ok
10
+ end
11
+ end
12
+ end
13
+ end
data/config/routes.rb ADDED
@@ -0,0 +1,6 @@
1
+ RubyNative::Engine.routes.draw do
2
+ resource :config, only: :show, controller: "config"
3
+ namespace :push do
4
+ resources :devices, only: :create
5
+ end
6
+ end
@@ -0,0 +1,28 @@
1
+ module RubyNative
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace RubyNative
4
+
5
+ initializer "ruby_native.helpers" do
6
+ ActiveSupport.on_load(:action_controller_base) do
7
+ include RubyNative::NativeDetection
8
+ helper RubyNative::Helper
9
+ end
10
+ end
11
+
12
+ initializer "ruby_native.assets" do |app|
13
+ app.config.assets.paths << root.join("app/assets/stylesheets") if app.config.respond_to?(:assets)
14
+ end
15
+
16
+ initializer "ruby_native.config" do
17
+ config.after_initialize do
18
+ RubyNative.load_config
19
+ end
20
+ end
21
+
22
+ initializer "ruby_native.routes" do |app|
23
+ app.routes.prepend do
24
+ mount RubyNative::Engine, at: "/native"
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,19 @@
1
+ module RubyNative
2
+ module Helper
3
+ def native_app?
4
+ request.user_agent.to_s.include?("Ruby Native")
5
+ end
6
+
7
+ def native_tabs_tag
8
+ tag.div(data: { native_tabs: true }, hidden: true)
9
+ end
10
+
11
+ def native_form_tag
12
+ tag.div(data: { native_form: true }, hidden: true)
13
+ end
14
+
15
+ def native_push_tag
16
+ tag.div(data: { native_push: true }, hidden: true)
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,9 @@
1
+ module RubyNative
2
+ module NativeDetection
3
+ extend ActiveSupport::Concern
4
+
5
+ def native_app?
6
+ request.user_agent.to_s.include?("Ruby Native")
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module RubyNative
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,13 @@
1
+ require "ruby_native/version"
2
+ require "ruby_native/helper"
3
+ require "ruby_native/native_detection"
4
+ require "ruby_native/engine"
5
+
6
+ module RubyNative
7
+ mattr_accessor :config
8
+
9
+ def self.load_config
10
+ path = Rails.root.join("config", "ruby_native.yml")
11
+ self.config = YAML.load_file(path).deep_symbolize_keys if path.exist?
12
+ end
13
+ end
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby_native
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Joe Masilotti
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2026-02-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '7.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '7.1'
27
+ description: A Rails engine providing native detection, configuration, push device
28
+ registration, and view helpers for Ruby Native iOS and Android apps.
29
+ email:
30
+ - joe@masilotti.com
31
+ executables: []
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - LICENSE
36
+ - README.md
37
+ - app/assets/stylesheets/ruby_native.css
38
+ - app/controllers/ruby_native/config_controller.rb
39
+ - app/controllers/ruby_native/push/devices_controller.rb
40
+ - config/routes.rb
41
+ - lib/ruby_native.rb
42
+ - lib/ruby_native/engine.rb
43
+ - lib/ruby_native/helper.rb
44
+ - lib/ruby_native/native_detection.rb
45
+ - lib/ruby_native/version.rb
46
+ homepage: https://github.com/Ruby-Native/gem
47
+ licenses:
48
+ - MIT
49
+ metadata: {}
50
+ post_install_message:
51
+ rdoc_options: []
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: '3.2'
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ requirements: []
65
+ rubygems_version: 3.0.3.1
66
+ signing_key:
67
+ specification_version: 4
68
+ summary: Native bridge helpers for Ruby Native apps.
69
+ test_files: []