phlex 2.0.0.beta1 → 2.0.0.rc1

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: fd808f50305105b7fb8cde4624804427da99fa7a3e59a20f6442e1db35e0983d
4
- data.tar.gz: f3e7f7b703a27e3a00bbea42749e4682ac0255a3c3c12abca5c94f90de1be23c
3
+ metadata.gz: 4a6338c8f3742ef6e6bc493e259ba3681d9a651e79c067e030e4aaba8b889396
4
+ data.tar.gz: b0f21d0994c3ec89bb16f4037997e1327e068e7dce4b9b9bad2355df95f40de8
5
5
  SHA512:
6
- metadata.gz: d66595c47ec3704a3b06c619e2fe8697252a8e9f5566be7c0c8082c06c69a46361686135411f04268854a1a087a78b24e072e7ca4fa98fd23b64dfaa147f6f07
7
- data.tar.gz: e93c80673a2ca16d9585d76b8c348ec0a7ddf04013720d083dc064b432aaf7f1642bbe5a6b8622fea6c18eb453f663de0d36929bd903f3b40a7f243987a46dee
6
+ metadata.gz: ff0f545fe87d54db6170264df314eaf9190a1ac5718fc66e905b295c66771b61bcf76a302c94df85d1242ba804790707bb387867e25685c112e402516fb2a58e
7
+ data.tar.gz: 9b4b4615a772814e0b2bb9774802832bd007dd61a08ef5145e750fd43a5984327664050462e6f2cb82f57c9dc46d0d3858d29aa09404c62c9aa1d381c9b32b94
data/README.md CHANGED
@@ -2,21 +2,18 @@
2
2
 
3
3
  Phlex lets you compose web views in pure Ruby.
4
4
 
5
- - [1.0 Stable Docs](https://www.phlex.fun)
6
- - [2.0 Beta Docs](https://beta.phlex.fun)
5
+ - [v1 Stable Docs](https://www.phlex.fun)
6
+ - [v2 Beta Docs](https://beta.phlex.fun)
7
7
 
8
- ## Maintenance schedule
8
+ ## Versioning and Maintenance
9
9
 
10
- ### Bug fixes
10
+ Phlex does not follow semantic versioning (SemVer). Instead, we follow [BreakVer](https://www.taoensso.com/break-versioning).
11
11
 
12
- - Only the latest minor version of each major version will receive bug fixes
13
- - We may choose to fix bugs by releasing a new minor version rather than patching the existing minor version
14
- - Major versions will stop receiving bug fixes one year after the next major version is released
12
+ When a security issue is brought to our attention, we aim to release patches as soon as possible. We aim to patch with a new `non-breaking` version:
15
13
 
16
- ### Security patches
17
-
18
- - When a security issue is brought to our attention, we aim to release patches for any minor version that was released in the last year.
19
- - Additionally, the latest minor version of the latest major version will receive security patches, even if that version is over a year old.
14
+ - every `minor` version that was released in the last year;
15
+ - the latest `minor` version of the latest two `major` versions, even if over a year old; and
16
+ - the `main` branch in GitHub.
20
17
 
21
18
  ## Prior Art 🎨
22
19
 
data/lib/phlex/context.rb CHANGED
@@ -2,18 +2,19 @@
2
2
 
3
3
  # @api private
4
4
  class Phlex::Context
5
- def initialize(user_context = {})
5
+ def initialize(user_context: {}, view_context: nil)
6
6
  @buffer = +""
7
7
  @capturing = false
8
8
  @user_context = user_context
9
9
  @fragments = nil
10
10
  @in_target_fragment = false
11
11
  @halt_signal = nil
12
+ @view_context = view_context
12
13
  end
13
14
 
14
15
  attr_accessor :buffer, :capturing, :user_context, :in_target_fragment
15
16
 
16
- attr_reader :fragments
17
+ attr_reader :fragments, :view_context
17
18
 
18
19
  def target_fragments(fragments)
19
20
  @fragments = fragments.to_h { |it| [it, true] }
data/lib/phlex/csv.rb CHANGED
@@ -9,13 +9,12 @@ class Phlex::CSV
9
9
  @_headers = []
10
10
  @_current_row = []
11
11
  @_current_column_index = 0
12
- @_view_context = nil
13
12
  @_first = true
14
13
  end
15
14
 
16
15
  attr_reader :collection
17
16
 
18
- def call(buffer = +"", view_context: nil)
17
+ def call(buffer = +"", context: nil)
19
18
  unless escape_csv_injection? == true || escape_csv_injection? == false
20
19
  raise <<~MESSAGE
21
20
  You need to define escape_csv_injection? in #{self.class.name}, returning either `true` or `false`.
@@ -40,8 +39,6 @@ class Phlex::CSV
40
39
  MESSAGE
41
40
  end
42
41
 
43
- @_view_context = view_context
44
-
45
42
  each_item do |record|
46
43
  yielder(record) do |*args, **kwargs|
47
44
  view_template(*args, **kwargs)
@@ -73,12 +70,12 @@ class Phlex::CSV
73
70
 
74
71
  def column(header = nil, value)
75
72
  if @_first
76
- @_headers << escape(header)
73
+ @_headers << __escape__(header)
77
74
  elsif header != @_headers[@_current_column_index]
78
75
  raise "Inconsistent header."
79
76
  end
80
77
 
81
- @_current_row << escape(value)
78
+ @_current_row << __escape__(value)
82
79
  @_current_column_index += 1
83
80
  end
84
81
 
@@ -105,11 +102,7 @@ class Phlex::CSV
105
102
  nil
106
103
  end
107
104
 
108
- def helpers
109
- @_view_context
110
- end
111
-
112
- def escape(value)
105
+ def __escape__(value)
113
106
  value = trim_whitespace? ? value.to_s.strip : value.to_s
114
107
  first_char = value[0]
115
108
  last_char = value[-1]
data/lib/phlex/error.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # @api private
3
4
  module Phlex::Error
4
5
  end
data/lib/phlex/fifo.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # @api private
3
4
  class Phlex::FIFO
4
5
  def initialize(max_bytesize: 2_000, max_value_bytesize: 2_000)
5
6
  @store = {}
data/lib/phlex/helpers.rb CHANGED
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # @api private
3
4
  module Phlex::Helpers
4
5
  private
5
6
 
6
- # @return [Hash]
7
7
  def mix(*args)
8
8
  args.each_with_object({}) do |object, result|
9
9
  result.merge!(object) do |_key, old, new|
@@ -26,6 +26,8 @@ module Phlex::Helpers
26
26
  [old] + new.to_a
27
27
  in [String, String]
28
28
  "#{old} #{new}"
29
+ in [_, nil]
30
+ old
29
31
  else
30
32
  new
31
33
  end