stbaldricks 5.0.3 → 5.1.0.alpha.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 23976dc281df1111a3e7d98405d1b405f4802d95a7b23e07e33d66a0c9a2570c
4
- data.tar.gz: 56b3e56ed91b0433bec7d17ede2a5dd493d5bdb618b382755aca682ab85ce0e3
3
+ metadata.gz: ed6e53fa5a27b5c313045729b05b5d600eac2ef8aab6bb53f07ebab429124861
4
+ data.tar.gz: 3ba8c2e6aaa698129cdabb4cae7eb80438e1417d3bdc6180c836c2e441a98c2c
5
5
  SHA512:
6
- metadata.gz: 09e84c3c3c386df7796c02f05b9e257d24d29084902fc800b69b3bcfa150e34ff7c68dc388055208433588a22d14c50337669837d1456bcc1a78ae642d74c9f9
7
- data.tar.gz: 9a2567682683edfe8c7869866f74f61d7f07bfc6aae3a477e8393ede28c03e950785225eb33333304bd870433037c46e0834849bbb47174ec7973c1993ecf793
6
+ metadata.gz: 90adb75ae3e1201de0154fd0bf0e1d92c75a98f98f79101aa83cf990cb64b65b55a183fda57013742ea04ecc2f52c6566fa334119e62a98e6392f1fee0c75e9f
7
+ data.tar.gz: 58efc424916e7e77adf2cf9530797334884dede156aad4ecb1d00131454b6fb0905c024a6d3582c7407bc4f69e659ed5ec85fc677935549b156cf6418eebffb8
@@ -89,11 +89,8 @@ module SBF
89
89
  data.merge!(attribute_symbol => attribute.dirty_data(true))
90
90
  end
91
91
  elsif attribute.is_a?(Array)
92
- entities = attribute.all? { |e| e.is_a?(BaseEntity) } ? attribute : false
93
- next unless entities
94
- dirty_data_hashes = entities.map { |e| e.dirty_data(true) }.reject(&:empty?)
95
- next if dirty_data_hashes.empty?
96
- data.merge!(attribute_symbol => dirty_data_hashes)
92
+ next unless attribute.all? { |e| e.is_a?(BaseEntity) } && attribute.any? { |e| !e.dirty_data(true).empty? }
93
+ data.merge!(attribute_symbol => attribute)
97
94
  end
98
95
  end
99
96
 
@@ -44,6 +44,39 @@ module SBF
44
44
  def draft_content
45
45
  content.select { |x| x.is_draft == true }
46
46
  end
47
+
48
+ def editor_content
49
+ published_content.map do |published|
50
+ draft_content.find { |d| published.id == d.id } || published
51
+ end
52
+ end
53
+
54
+ def lock_expired?(ttl = 300)
55
+ locked_at.nil? || Time.now >= Time.parse(locked_at) + ttl
56
+ end
57
+
58
+ def add_draft_sections(sections)
59
+ sections.each do |cid, data|
60
+ #convert symbol to integer
61
+ cid = cid.to_s.to_i
62
+
63
+ content = published_content.find { |c| c.id == cid }
64
+ update_draft_content_section(content, data, cid) unless content.nil?
65
+ end
66
+ end
67
+
68
+ private
69
+
70
+ def update_draft_content_section(content, data, cid)
71
+ # update or create draft version of content
72
+ draft = draft_content.find { |d| d.id == cid }
73
+ if draft.nil?
74
+ self.content << SBF::Client::Page::Content.new(content.to_hash.merge(is_draft: true, title: data[:title], text: data[:text]))
75
+ else
76
+ draft.title = data[:title]
77
+ draft.text = data[:text]
78
+ end
79
+ end
47
80
  end
48
81
  end
49
82
  end
@@ -1,5 +1,5 @@
1
1
  module SBF
2
2
  module Client
3
- VERSION = '5.0.3'
3
+ VERSION = '5.1.0.alpha.1'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stbaldricks
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.3
4
+ version: 5.1.0.alpha.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Firespring
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-15 00:00:00.000000000 Z
11
+ date: 2018-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -227,9 +227,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
227
227
  version: '0'
228
228
  required_rubygems_version: !ruby/object:Gem::Requirement
229
229
  requirements:
230
- - - ">="
230
+ - - ">"
231
231
  - !ruby/object:Gem::Version
232
- version: '0'
232
+ version: 1.3.1
233
233
  requirements: []
234
234
  rubyforge_project:
235
235
  rubygems_version: 2.7.6