fino-rails 1.4.0 → 1.5.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
  SHA256:
3
- metadata.gz: a3bbff266262c38b716a1912181b6a299266be3ee146de116e112e1fabf6e924
4
- data.tar.gz: b76dcfa5d50fd1d559a62cdae4b10d3c82da688e345f68468551b9127d7daeb4
3
+ metadata.gz: 44247d542938f2d6d30fcd1cce04f9536a29db60f737b8ab53ec65f322c7ae64
4
+ data.tar.gz: 19d1dcbf0364a5637c14db14937f1533a996cb1a72f951f526a2d16fd75c380d
5
5
  SHA512:
6
- metadata.gz: 5f9951c6e629bde2029426053984b992fa9902a37ddee6b22763f0892b535e4aceb0e852e897f5cd1ffe5b8d76b3a4e607efeb187cf49029a498a3e356c4807f
7
- data.tar.gz: 18820cb8d22e465b16bc4edb3b6d5742c5455d6f7f0eb9e98ab30dd85024582e20d388fadbfd743b513295dea71c11d47cd2e8135b648bf62c61f74df4a55991
6
+ metadata.gz: 2068d0fa5051c0e358c690a9aafc838a61cea5d4b62b5cc0096fec08d805172dfb1c66b4cadfd6bcdc9385f046d6f6e7cb1067922814f7e38c18c6fbfc0a3a4e
7
+ data.tar.gz: 02a17fc345a7e4e6e776ac6f357ccb7633637e4fc2662f0ec5944aa944a4d27f6b83b1d829838f91b1eb5eb5812b25404a797b3ad06b0bec8bf79a08108b3711
@@ -23,8 +23,6 @@
23
23
  <h2 class="min-w-0 text-sm/6 font-semibold text-gray-900">
24
24
  <span class="whitespace-nowrap"><%= setting.name %></span>
25
25
  </h2>
26
-
27
- <%= setting_type_label(setting) %>
28
26
  </div>
29
27
 
30
28
  <div>
@@ -43,6 +41,13 @@
43
41
  <div class="truncate text-xl font-semibold text-gray-800">
44
42
  "<%= setting.value %>"
45
43
  </div>
44
+ <% when Fino::Settings::Numeric %>
45
+ <div class="truncate text-xl font-semibold text-gray-800">
46
+ <span><%= setting.value %></span>
47
+ <% if setting.unit.present? %>
48
+ <span class="text-base font-medium text-gray-600"><%= setting.unit.short_name %></span>
49
+ <% end %>
50
+ </div>
46
51
  <% else %>
47
52
  <div class="truncate text-xl font-semibold text-gray-800">
48
53
  <%= setting.value %>
@@ -36,6 +36,13 @@
36
36
  <div class="truncate text-xl font-semibold text-gray-800">
37
37
  "<%= setting.value %>"
38
38
  </div>
39
+ <% when Fino::Settings::Numeric %>
40
+ <div class="truncate text-xl font-semibold text-gray-800">
41
+ <%= setting.value %>
42
+ <% if setting.unit.present? %>
43
+ <span class="text-base font-medium text-gray-600"><%= setting.unit.short_name %></span>
44
+ <% end %>
45
+ </div>
39
46
  <% else %>
40
47
  <div class="truncate text-xl font-semibold text-gray-800">
41
48
  <%= setting.value %>
@@ -1,3 +1,5 @@
1
+ <% setting = local_assigns[:setting] %>
2
+
1
3
  <div class="<%= local_assigns[:wrapper_class] || 'flex items-center rounded-md bg-white pl-3 outline-1 -outline-offset-1 outline-gray-300 focus-within:outline-2 focus-within:-outline-offset-2 focus-within:outline-indigo-600' %>">
2
4
  <%= form.number_field field_name,
3
5
  {
@@ -6,4 +8,10 @@
6
8
  step: 0.1,
7
9
  class: local_assigns[:input_class] || "block min-w-0 grow bg-white py-1.5 pr-3 pl-1 text-base text-gray-900 placeholder:text-gray-400 focus:outline-none sm:text-sm/6"
8
10
  }.merge(field_name_attr ? { name: field_name_attr } : {}) %>
9
- </div>
11
+
12
+ <% if setting.unit.present? %>
13
+ <div class="shrink-0 text-base text-gray-500 select-none sm:text-sm/6 dark:text-gray-400 pr-3">
14
+ <%= setting.unit.short_name %>
15
+ </div>
16
+ <% end %>
17
+ </div>
@@ -1,3 +1,5 @@
1
+ <% setting = local_assigns[:setting] %>
2
+
1
3
  <div class="<%= local_assigns[:wrapper_class] || 'flex items-center rounded-md bg-white pl-3 outline-1 -outline-offset-1 outline-gray-300 focus-within:outline-2 focus-within:-outline-offset-2 focus-within:outline-indigo-600' %>">
2
4
  <%= form.number_field field_name,
3
5
  {
@@ -6,4 +8,10 @@
6
8
  step: 1,
7
9
  class: local_assigns[:input_class] || "block min-w-0 grow bg-white py-1.5 pr-3 pl-1 text-base text-gray-900 placeholder:text-gray-400 focus:outline-none sm:text-sm/6"
8
10
  }.merge(field_name_attr ? { name: field_name_attr } : {}) %>
9
- </div>
11
+
12
+ <% if setting.unit.present? %>
13
+ <div class="shrink-0 text-base text-gray-500 select-none sm:text-sm/6 dark:text-gray-400 pr-3">
14
+ <%= setting.unit.short_name %>
15
+ </div>
16
+ <% end %>
17
+ </div>
@@ -0,0 +1,12 @@
1
+ Description:
2
+ Installs Fino Rails integration by creating an initializer file with default configuration.
3
+ If fino-solid is installed, it will also run the fino:solid:install generator to create the database migration.
4
+
5
+ Example:
6
+ bin/rails generate fino:rails:install
7
+
8
+ This will create:
9
+ config/initializers/fino.rb
10
+
11
+ If fino-solid is installed, it will also create:
12
+ db/migrate/[timestamp]_create_fino_settings.rb
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails/generators"
4
+
5
+ module Fino
6
+ module Rails
7
+ module Generators
8
+ class InstallGenerator < ::Rails::Generators::Base
9
+ source_root File.expand_path("templates", __dir__)
10
+
11
+ def copy_initializer
12
+ template "fino.rb.tt", "config/initializers/fino.rb"
13
+ end
14
+
15
+ def install_solid_adapter
16
+ return unless fino_solid_available?
17
+
18
+ generate "fino:solid:install"
19
+ end
20
+
21
+ private
22
+
23
+ def fino_solid_available?
24
+ require "fino-solid"
25
+ true
26
+ rescue LoadError
27
+ false
28
+ end
29
+
30
+ def fino_redis_available?
31
+ require "fino-redis"
32
+ true
33
+ rescue LoadError
34
+ false
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,105 @@
1
+ # frozen_string_literal: true
2
+
3
+ Rails.application.configure do
4
+ # Configure fino-rails within this block
5
+
6
+ # Whether fino calls should be instrumented. You can implement custom subscribers by subscribing to `fino` namespace
7
+ config.fino.instrument = Rails.env.development?
8
+
9
+ # Fino Rails provides a default log subscriber that logs executed queries and cache hits/misses by subscribing to
10
+ # `fino` instrumentation namespace
11
+ #
12
+ config.fino.log = config.fino.instrument
13
+
14
+ # If setting was read from the adapter within Rails request, it will be cached for the duration of that request to
15
+ # avoid multiple calls to the adapter
16
+ #
17
+ config.fino.cache_within_request = true
18
+
19
+ # Whether fino should preload all registered settings in the beginning of each request by single adapter call.
20
+ # Can be set to:
21
+ #
22
+ # 1. false - do not preload settings
23
+ # 2. true - preload all settings before each request
24
+ # 3. Callable accepting rack request object and returning boolean - preload settings conditionally, e.g:
25
+ #
26
+ # ->(request) {
27
+ # case request.path
28
+ # when "request/using/all/settings"
29
+ # true
30
+ # when "request/not/using/settings"
31
+ # false
32
+ # when "request/using/specific/settings"
33
+ # [
34
+ # :api_rate_limit,
35
+ # openai: [:model, :temperature]
36
+ # ]
37
+ # end
38
+ # }
39
+ #
40
+ config.fino.preload_before_request = false
41
+ end
42
+
43
+ Fino.configure do
44
+ <%- if fino_redis_available? -%>
45
+ adapter do
46
+ Fino::Redis::Adapter.new(
47
+ Redis.new(**Rails.application.config_for(:redis))
48
+ )
49
+ end
50
+ <%- elsif fino_solid_available? -%>
51
+ adapter do
52
+ Fino::Solid::Adapter.new
53
+ end
54
+ <%- else -%>
55
+ adapter do
56
+ raise "No Fino adapter configured. Use `bundle add fino-solid` for a quick start"
57
+ end
58
+ <%- end -%>
59
+
60
+ # Allows to cache settings between requests
61
+ #
62
+ # Memory cache adapter provided out of the box should be used with care as may lead to inconsistencies between
63
+ # running application instances, but might lead to performance improvements by reducing amount of calls to the adapter
64
+ #
65
+ # cache { Fino::Cache::Memory.new(expires_in: 1.minute) }
66
+
67
+ settings do
68
+ # Configure settings within this block
69
+
70
+ # Supported data types:
71
+ # - string
72
+ # - integer
73
+ # - float
74
+ # - boolean
75
+
76
+ # setting :maintenance_mode,
77
+ # :boolean,
78
+ # default: false,
79
+ # description: <<~DESC.strip
80
+ # Enable maintenance mode for the system. Users will see a maintenance page when this is enabled
81
+ # DESC
82
+ #
83
+ # setting :api_rate_limit,
84
+ # :integer,
85
+ # default: 1000,
86
+ # description: "Maximum API requests per minute per user to prevent abuse"
87
+ #
88
+ # section :openai, label: "OpenAI" do
89
+ # setting :model,
90
+ # :string,
91
+ # default: "gpt-5",
92
+ # description: "OpenAI model"
93
+ #
94
+ # setting :temperature,
95
+ # :float,
96
+ # default: 0.7,
97
+ # description: "Model temperature"
98
+ # end
99
+ #
100
+ # section :feature_toggles, label: "Feature Toggles" do
101
+ # setting :new_ui, :boolean, default: true, description: "Enable the new user interface"
102
+ # setting :beta_functionality, :boolean, default: false, description: "Enable beta functionality for testing"
103
+ # end
104
+ end
105
+ end
data/lib/fino/rails.rb CHANGED
@@ -26,3 +26,4 @@ module Fino
26
26
  end
27
27
 
28
28
  require "fino/rails/engine"
29
+ require "fino/rails/generators/install/install_generator"
data/lib/fino/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Fino
4
- VERSION = "1.4.0"
4
+ VERSION = "1.5.0"
5
5
  REQUIRED_RUBY_VERSION = ">= 3.0.0"
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fino-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Egor Iskrenkov
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - "~>"
17
17
  - !ruby/object:Gem::Version
18
- version: 1.4.0
18
+ version: 1.5.0
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - "~>"
24
24
  - !ruby/object:Gem::Version
25
- version: 1.4.0
25
+ version: 1.5.0
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: rails
28
28
  requirement: !ruby/object:Gem::Requirement
@@ -71,6 +71,9 @@ files:
71
71
  - lib/fino/rails/app/views/layouts/fino/rails/application.html.erb
72
72
  - lib/fino/rails/config/routes.rb
73
73
  - lib/fino/rails/engine.rb
74
+ - lib/fino/rails/generators/install/USAGE
75
+ - lib/fino/rails/generators/install/install_generator.rb
76
+ - lib/fino/rails/generators/install/templates/fino.rb.tt
74
77
  - lib/fino/rails/instrumentation/log_subscriber.rb
75
78
  - lib/fino/rails/instrumentation/pipe.rb
76
79
  - lib/fino/rails/preloading/middleware.rb