librails 1.1.4 → 1.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: e3fedeb1a64918d6d9087c0ead82625292037df190077f762516c55057db2dbf
4
- data.tar.gz: 347848a3cb5a74f3c621144abdd54294bfbaabc09e60e19d46d7a2f5123511a1
3
+ metadata.gz: e5442bfe19fdd87e12645f35d9df1d139176e38347d893c17b19605ed869bbee
4
+ data.tar.gz: a529c638d5c250cab764f7f73f0eb4ca3c9189c88b5c032ec2ea91245400a602
5
5
  SHA512:
6
- metadata.gz: 23caa55515ec0ecd3144b4fbf1ce387e297a071f6e3d34ee6525c75a1a880d99e21df904581f6fa4775fc770b757550a05ea8e78ba3869da3c9c72360b8597d2
7
- data.tar.gz: 3e3f60e7b83ba806c55be02793430f1404857ecb30e89dca6929917ae1fb67b382e8a2dfe37fc0f143c7acce2d76b747411dd2c916f1b32a0a9aeba851345535
6
+ metadata.gz: df850494eb04c384afaa9b50ed054a4d36b5b251ba998c8000c8be3d19ff251e92af3107d10355b9126caabdcdbfe098af772dc3a8a898550a288469c1b9714b
7
+ data.tar.gz: 1adc870ce27733211ad69ae3e10a8e816efc0f02505950ae5433f33e4b551903d27dffca5750c343b89b92a0ec5ef1029478c226201475e20dc41288fa46df1a
@@ -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
@@ -37,6 +37,22 @@ module Librails
37
37
  result
38
38
  end
39
39
 
40
+ def self.get_array(key)
41
+ value = get_value(key)
42
+ return nil unless value
43
+ values = nil
44
+ if value =~ /^---/
45
+ # Rails Settings Cachedは配列をYAML形式で保存している
46
+ # "---\n- bootstrap\n- chatgpt\n- git\n- github\n- javascript\n
47
+ value = value.sub(/^---\n/, '')
48
+ values = value.split(/\n/).collect {|v| v.sub(/^- /, '').strip}
49
+ else
50
+ # 新方式は単なるtsvとする
51
+ values = value.split(/\t/)
52
+ end
53
+ values
54
+ end
55
+
40
56
  def self.normalize_value(value)
41
57
  value.sub(/^--- /, '').strip
42
58
  end
@@ -56,12 +72,18 @@ module Librails
56
72
  end
57
73
 
58
74
  def self.set_value(key, value)
59
- settings = get(key)
75
+ settings = get_record(key)
60
76
  unless settings
61
77
  settings = Settings.new
62
78
  settings.key = key
63
79
  end
64
- settings.value = value.to_s
80
+ str = nil
81
+ if value.kind_of?(Array)
82
+ str = value.join("\t") # タブ区切りで保存
83
+ else
84
+ str = value.to_s
85
+ end
86
+ settings.value = str
65
87
  settings.save!
66
88
  end
67
89
 
@@ -1,3 +1,3 @@
1
1
  module Librails
2
- VERSION = "1.1.4"
2
+ VERSION = "1.2.0"
3
3
  end
data/lib/librails.rb CHANGED
@@ -1,9 +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"
6
- require "librails/settings"
2
+ # require "librails/version"
3
+ # require "librails/misc_utils"
4
+ # require "librails/model_utils"
5
+ # require "librails/view_helper"
6
+ # require "librails/settings"
7
7
 
8
8
  module Librails
9
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.1.4
4
+ version: 1.2.0
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
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 7.0.8
27
+ - !ruby/object:Gem::Dependency
28
+ name: mysql2
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.5'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.5'
27
41
  description: My Rails Plugin
28
42
  email:
29
43
  - src@srcw.net
@@ -37,14 +51,15 @@ files:
37
51
  - app/assets/config/librails_manifest.js
38
52
  - app/assets/stylesheets/librails/application.css
39
53
  - app/controllers/librails/application_controller.rb
40
- - app/helpers/librails/application_helper.rb
41
54
  - app/jobs/librails/application_job.rb
42
55
  - app/mailers/librails/application_mailer.rb
43
56
  - app/models/librails/application_record.rb
44
57
  - app/views/layouts/librails/application.html.erb
45
58
  - config/routes.rb
46
59
  - lib/librails.rb
60
+ - lib/librails/application_helper.rb
47
61
  - lib/librails/engine.rb
62
+ - lib/librails/form_param.rb
48
63
  - lib/librails/misc_utils.rb
49
64
  - lib/librails/model_utils.rb
50
65
  - lib/librails/settings.rb