librails 1.0.0 → 1.1.6

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: c823fc1b474eef6df534b9defe3946ad5b6a4c919dcae7797ab69e7873c4a505
4
- data.tar.gz: 7fc179fa1616ea9e6fa4921e2fe0f70e057534dbff42e2d2fbc21563fc6ee786
3
+ metadata.gz: df872686d80984872a7b0ae1a0dc802cff819f13e760c42f078d02c42406a03f
4
+ data.tar.gz: c4cc4a6d4ee405a2679eb25d88ec98642933faf925a8b139f27a6b68a70527e1
5
5
  SHA512:
6
- metadata.gz: a8e6653767aab0b0906b7cd0c84dc9867d016fa316cd24c6a4870c1971128e0abcb2e9a95ed4a166080242ee701fbb28e8e5135a06d708f379a66b1e643089cb
7
- data.tar.gz: 787b53c553a2c89a5df3d2aff96c9a57f7ca0d02d63e3855c712f3c4c24dda03cb81f211ffdd7fec2438ad78dd53671fe723a87a4a9c800034cd04cd45cf4de7
6
+ metadata.gz: '0291b3db421706474f8dd314d73438d8e31ec90782df3c4229947580c23f0dfbe9f7dad0f9019e0cdcea7fd66edc36901ab0de9cfbb14b6aa4385fe8e541ae25'
7
+ data.tar.gz: f3d677ee28e4cce361334b16aabd9bca794dfc8f88bd550f339b405f3a9dad7d0076cc21f59b70da14d1596aef889dc1169f050e8eabbf0386cd3c8eca2a169f
@@ -3,7 +3,7 @@ module Librails
3
3
  isolate_namespace Librails
4
4
 
5
5
  # Add a load path for this specific Engine
6
- config.autoload_paths << File.expand_path("../../lib", __FILE__)
6
+ config.autoload_paths << File.expand_path("../../", __FILE__)
7
7
 
8
8
  initializer "librails.view_helper" do |app|
9
9
  ActiveSupport.on_load :action_view do
@@ -0,0 +1,14 @@
1
+ module Librails
2
+ class FormParam
3
+ def initialize(id, label = nil, value = nil)
4
+ # 基本はIDとlabel。valueは特別な値を紐付けたい場合にのみ使用する。
5
+ @id = id
6
+ @label = label
7
+ if @label.nil?
8
+ @label = @id
9
+ end
10
+ @value = value
11
+ end
12
+ attr_accessor :id, :label, :value
13
+ end
14
+ end
@@ -0,0 +1,69 @@
1
+ module Librails
2
+
3
+ ## Settingテーブルを読み書きするクラス
4
+ #
5
+ # rails-settings-cachedとの互換性のため値を正規化するメソッドを用意している
6
+ #
7
+ # 以下のテーブルを想定
8
+ #
9
+ # テーブル名: settings
10
+ # id(int): 主キー
11
+ # var(varchar(255)): 値のキー
12
+ # value(text): 値
13
+
14
+
15
+ class Settings < ActiveRecord::Base
16
+ self.table_name = "settings"
17
+
18
+ def self.get_str(key)
19
+ get_value(key)
20
+ end
21
+
22
+ def self.get_int(key)
23
+ value = get_value(key)
24
+ return nil unless value
25
+ value.to_i
26
+ end
27
+
28
+ def self.get_time(key)
29
+ value = get_value(key)
30
+ return nil unless value
31
+ result = nil
32
+ begin
33
+ result = Time.zone.parse(value)
34
+ rescue => e
35
+ puts e.message
36
+ end
37
+ result
38
+ end
39
+
40
+ def self.normalize_value(value)
41
+ value.sub(/^--- /, '').strip
42
+ end
43
+
44
+ def self.get_value(key)
45
+ settings = get_record(key)
46
+ value = nil
47
+ if settings
48
+ # Rails::Settings::Cachedが先頭に"-- "を付けているのでそれを除去する。互換性のための処理
49
+ value = normalize_value(settings.value)
50
+ end
51
+ value
52
+ end
53
+
54
+ def self.get_record(key)
55
+ Settings.find_by(var: key)
56
+ end
57
+
58
+ def self.set_value(key, value)
59
+ settings = get(key)
60
+ unless settings
61
+ settings = Settings.new
62
+ settings.key = key
63
+ end
64
+ settings.value = value.to_s
65
+ settings.save!
66
+ end
67
+
68
+ end
69
+ end
@@ -1,3 +1,3 @@
1
1
  module Librails
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.6"
3
3
  end
data/lib/librails.rb CHANGED
@@ -1,8 +1,9 @@
1
1
  require "librails/engine"
2
- require "librails/version"
3
- require "librails/misc_utils"
4
- require "librails/model_utils"
5
- require "librails/view_helper"
2
+ # require "librails/version"
3
+ # require "librails/misc_utils"
4
+ # require "librails/model_utils"
5
+ # require "librails/view_helper"
6
+ # require "librails/settings"
6
7
 
7
8
  module Librails
8
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: librails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - src256
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-07 00:00:00.000000000 Z
11
+ date: 2023-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -37,16 +37,18 @@ files:
37
37
  - app/assets/config/librails_manifest.js
38
38
  - app/assets/stylesheets/librails/application.css
39
39
  - app/controllers/librails/application_controller.rb
40
- - app/helpers/librails/application_helper.rb
41
40
  - app/jobs/librails/application_job.rb
42
41
  - app/mailers/librails/application_mailer.rb
43
42
  - app/models/librails/application_record.rb
44
43
  - app/views/layouts/librails/application.html.erb
45
44
  - config/routes.rb
46
45
  - lib/librails.rb
46
+ - lib/librails/application_helper.rb
47
47
  - lib/librails/engine.rb
48
+ - lib/librails/form_param.rb
48
49
  - lib/librails/misc_utils.rb
49
50
  - lib/librails/model_utils.rb
51
+ - lib/librails/settings.rb
50
52
  - lib/librails/version.rb
51
53
  - lib/librails/view_helper.rb
52
54
  - lib/tasks/librails_tasks.rake