monolens 0.5.2 → 0.5.3

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
  SHA1:
3
- metadata.gz: 2b96981f78af52f468676e9de0aeb3f79e79ab66
4
- data.tar.gz: fb6445fc49c216be5868b27bef78cdfba79a1264
3
+ metadata.gz: bef48815edf1f5c767fd7e41ad3720046b4d6a7c
4
+ data.tar.gz: 366cfea423fca4d3a7aa7471a67fd19571016b50
5
5
  SHA512:
6
- metadata.gz: 110e2c7da4dcc2195599813adf977af62d1698255339d0ba087bb1b1a7fb886ffd90bd12ded6eeb720547c327294eec758ae462f7e98024fffaecddb8e56c2cd
7
- data.tar.gz: 1621c07cbba992d5a74c0811e420dd8489ff1c064eaf26bd698404b61bc3ab64ca60da65827ac3a061d0dfad28c483d3e2c07f83e50b4ec5eb22ea944b91d134
6
+ metadata.gz: 1e0ae29c6ab1c18b22d3a96c7455983116f5433ba537ddf8a4c6a8c5ef289eb562a3d2d955da6218eb7ccf27a34488405f3fb66798524b03943deb61498093b3
7
+ data.tar.gz: 8513b04a89c60ded94f11a7296b613bf23358515b4f5e035b933afa9259e1f4ad7c0cc282d1d0c96841feefcaf46743aad325ed877c7e4b476663cb079f281f3
data/README.md CHANGED
@@ -79,6 +79,7 @@ result = lens.call(input)
79
79
  core.dig - Extract from the input value (object or array) using a path.
80
80
  core.chain - Applies a chain of lenses to an input value
81
81
  core.mapping - Converts the input value via a key:value mapping
82
+ core.literal - Returns a constant value takens as lens definition
82
83
 
83
84
  str.strip - Remove leading and trailing spaces of an input string
84
85
  str.split - Splits the input string as an array
@@ -0,0 +1,11 @@
1
+ module Monolens
2
+ module Core
3
+ class Literal
4
+ include Lens
5
+
6
+ def call(arg, world = {})
7
+ option(:defn)
8
+ end
9
+ end
10
+ end
11
+ end
data/lib/monolens/core.rb CHANGED
@@ -10,6 +10,11 @@ module Monolens
10
10
  end
11
11
  module_function :dig
12
12
 
13
+ def literal(options)
14
+ Literal.new(options)
15
+ end
16
+ module_function :literal
17
+
13
18
  def mapping(options)
14
19
  Mapping.new(options)
15
20
  end
@@ -21,3 +26,4 @@ end
21
26
  require_relative 'core/chain'
22
27
  require_relative 'core/dig'
23
28
  require_relative 'core/mapping'
29
+ require_relative 'core/literal'
@@ -2,7 +2,7 @@ module Monolens
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 5
5
- TINY = 2
5
+ TINY = 3
6
6
  end
7
7
  VERSION = "#{Version::MAJOR}.#{Version::MINOR}.#{Version::TINY}"
8
8
  end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe Monolens, "core.literal" do
4
+ let(:lens) do
5
+ Monolens.lens('core.literal' => { defn: 'hello' })
6
+ end
7
+
8
+ it 'works' do
9
+ input = {}
10
+ expected = 'hello'
11
+ expect(lens.call(input)).to eql(expected)
12
+ end
13
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: monolens
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bernard Lambeau
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-20 00:00:00.000000000 Z
11
+ date: 2022-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -93,6 +93,7 @@ files:
93
93
  - lib/monolens/core.rb
94
94
  - lib/monolens/core/chain.rb
95
95
  - lib/monolens/core/dig.rb
96
+ - lib/monolens/core/literal.rb
96
97
  - lib/monolens/core/mapping.rb
97
98
  - lib/monolens/error.rb
98
99
  - lib/monolens/error_handler.rb
@@ -132,6 +133,7 @@ files:
132
133
  - spec/monolens/command/names.json
133
134
  - spec/monolens/command/robust-map-upcase.lens.yml
134
135
  - spec/monolens/core/test_dig.rb
136
+ - spec/monolens/core/test_literal.rb
135
137
  - spec/monolens/core/test_mapping.rb
136
138
  - spec/monolens/lens/test_options.rb
137
139
  - spec/monolens/object/test_extend.rb