librails 1.1.6 → 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: df872686d80984872a7b0ae1a0dc802cff819f13e760c42f078d02c42406a03f
4
- data.tar.gz: c4cc4a6d4ee405a2679eb25d88ec98642933faf925a8b139f27a6b68a70527e1
3
+ metadata.gz: e5442bfe19fdd87e12645f35d9df1d139176e38347d893c17b19605ed869bbee
4
+ data.tar.gz: a529c638d5c250cab764f7f73f0eb4ca3c9189c88b5c032ec2ea91245400a602
5
5
  SHA512:
6
- metadata.gz: '0291b3db421706474f8dd314d73438d8e31ec90782df3c4229947580c23f0dfbe9f7dad0f9019e0cdcea7fd66edc36901ab0de9cfbb14b6aa4385fe8e541ae25'
7
- data.tar.gz: f3d677ee28e4cce361334b16aabd9bca794dfc8f88bd550f339b405f3a9dad7d0076cc21f59b70da14d1596aef889dc1169f050e8eabbf0386cd3c8eca2a169f
6
+ metadata.gz: df850494eb04c384afaa9b50ed054a4d36b5b251ba998c8000c8be3d19ff251e92af3107d10355b9126caabdcdbfe098af772dc3a8a898550a288469c1b9714b
7
+ data.tar.gz: 1adc870ce27733211ad69ae3e10a8e816efc0f02505950ae5433f33e4b551903d27dffca5750c343b89b92a0ec5ef1029478c226201475e20dc41288fa46df1a
@@ -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.6"
2
+ VERSION = "1.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: librails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.6
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - src256
@@ -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