txbr 2.5.1 → 2.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/txbr/campaigns_api.rb +1 -1
- data/lib/txbr/template.rb +18 -4
- data/lib/txbr/version.rb +1 -1
- data/spec/campaigns_api_spec.rb +3 -3
- data/spec/template_spec.rb +12 -2
- data/txbr.gemspec +1 -1
- metadata +8 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0568f2b13442d1b261faf8bb8b617b43eec292b21bacb209d0d0089dec986856'
|
4
|
+
data.tar.gz: fc0d22c2387afd76d9901ff1d3543ff7781b3eb63486634ef57b606ce24b706f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba0fe6310e773239d610e3ddc7053210108947318f787c2e4b37b97b144844b6b9c1d0edba846a1c763d0125afecf79436911cd93e8ebc20e82c0db0d714a2f0
|
7
|
+
data.tar.gz: c0bcdedf0d9175df3a143a741db768c568c13f78696731d1646a1fa9d3bfefcf5c606e17313803c282d217775ae5b8d1257c9c4b125c344f4e950b634186e96c
|
data/lib/txbr/campaigns_api.rb
CHANGED
@@ -15,7 +15,7 @@ module Txbr
|
|
15
15
|
page = 0
|
16
16
|
|
17
17
|
loop do
|
18
|
-
campaigns = braze_api.get_json(CAMPAIGN_LIST_PATH, page: page)
|
18
|
+
campaigns = braze_api.get_json(CAMPAIGN_LIST_PATH, page: page, include_archived: false)
|
19
19
|
campaigns['campaigns'].each(&block)
|
20
20
|
break if campaigns['campaigns'].size < CAMPAIGN_BATCH_SIZE
|
21
21
|
page += 1
|
data/lib/txbr/template.rb
CHANGED
@@ -69,10 +69,24 @@ module Txbr
|
|
69
69
|
# Otherwise, transform the var into something Liquid-friendly so it
|
70
70
|
# doesn't jam up the parser.
|
71
71
|
def prerender(source, variables)
|
72
|
-
source.gsub(
|
73
|
-
|
74
|
-
|
75
|
-
|
72
|
+
source.gsub(/(?:\{\s*\{\s*)?(?:[\w\-\_\.\[\]]+\.)?\$\{\s*[\w\-\.\[\]]+\s*\}?\s*(?:\}?\s*\})?/) do |orig|
|
73
|
+
plain = orig.sub(/\A\{\{/, '').sub(/\}\}\z/, '')
|
74
|
+
|
75
|
+
result = if val = variables[plain]
|
76
|
+
"\"#{val}\""
|
77
|
+
else
|
78
|
+
normalize_braze_var(orig)
|
79
|
+
end
|
80
|
+
|
81
|
+
if orig.tr(' ', '').start_with?('{{')
|
82
|
+
result = "{{#{result}"
|
83
|
+
end
|
84
|
+
|
85
|
+
if orig.tr(' ', '').end_with?('}}')
|
86
|
+
result << '}}'
|
87
|
+
end
|
88
|
+
|
89
|
+
result
|
76
90
|
end
|
77
91
|
end
|
78
92
|
|
data/lib/txbr/version.rb
CHANGED
data/spec/campaigns_api_spec.rb
CHANGED
@@ -20,13 +20,13 @@ describe Txbr::CampaignsApi do
|
|
20
20
|
|
21
21
|
let(:interactions) do
|
22
22
|
[{
|
23
|
-
request: { verb: 'get', url: described_class::CAMPAIGN_LIST_PATH, params: { page: 0 } },
|
23
|
+
request: { verb: 'get', url: described_class::CAMPAIGN_LIST_PATH, params: { page: 0, include_archived: false } },
|
24
24
|
response: { status: 200, body: { campaigns: [{ id: '123abc' }] }.to_json }
|
25
25
|
}, {
|
26
|
-
request: { verb: 'get', url: described_class::CAMPAIGN_LIST_PATH, params: { page: 1 } },
|
26
|
+
request: { verb: 'get', url: described_class::CAMPAIGN_LIST_PATH, params: { page: 1, include_archived: false } },
|
27
27
|
response: { status: 200, body: { campaigns: [{ id: '456def' }] }.to_json }
|
28
28
|
}, {
|
29
|
-
request: { verb: 'get', url: described_class::CAMPAIGN_LIST_PATH, params: { page: 2 } },
|
29
|
+
request: { verb: 'get', url: described_class::CAMPAIGN_LIST_PATH, params: { page: 2, include_archived: false } },
|
30
30
|
response: { status: 200, body: { campaigns: [] }.to_json }
|
31
31
|
}]
|
32
32
|
end
|
data/spec/template_spec.rb
CHANGED
@@ -9,6 +9,8 @@ describe Txbr::Template do
|
|
9
9
|
<<~SRC
|
10
10
|
<h1>Braze campaign is {{campaign.${api_id}}}</h1>
|
11
11
|
<h2>Hello, {{${first_name}}}</h2>
|
12
|
+
<h3>I speak {{custom_attributes.${preferred_language} | default: 'en'}}</h3>
|
13
|
+
<h3>{{'foo bar ' | append: custom_attributes.${foobar}}}</h3>
|
12
14
|
SRC
|
13
15
|
end
|
14
16
|
|
@@ -16,7 +18,8 @@ describe Txbr::Template do
|
|
16
18
|
let(:prerender_variables) do
|
17
19
|
{
|
18
20
|
'campaign.${api_id}' => 'abc123',
|
19
|
-
'${first_name}' => 'Dwight'
|
21
|
+
'${first_name}' => 'Dwight',
|
22
|
+
'custom_attributes.${foobar}' => 'baz'
|
20
23
|
}
|
21
24
|
end
|
22
25
|
|
@@ -24,13 +27,20 @@ describe Txbr::Template do
|
|
24
27
|
expect(subject.render).to eq(<<~TEXT)
|
25
28
|
<h1>Braze campaign is abc123</h1>
|
26
29
|
<h2>Hello, Dwight</h2>
|
30
|
+
<h3>I speak en</h3>
|
31
|
+
<h3>foo bar baz</h3>
|
27
32
|
TEXT
|
28
33
|
end
|
29
34
|
end
|
30
35
|
|
31
36
|
context 'with no variable replacements' do
|
32
37
|
it 'renders without erroring' do
|
33
|
-
expect
|
38
|
+
expect(subject.render).to eq(<<~TEXT)
|
39
|
+
<h1>Braze campaign is </h1>
|
40
|
+
<h2>Hello, </h2>
|
41
|
+
<h3>I speak en</h3>
|
42
|
+
<h3>foo bar </h3>
|
43
|
+
TEXT
|
34
44
|
end
|
35
45
|
end
|
36
46
|
end
|
data/txbr.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.add_dependency 'liquid', '~> 4.0'
|
20
20
|
s.add_dependency 'sinatra', '~> 1.4'
|
21
21
|
s.add_dependency 'sinatra-contrib', '~> 1.4'
|
22
|
-
s.add_dependency 'txgh', '~>
|
22
|
+
s.add_dependency 'txgh', '~> 7.0'
|
23
23
|
|
24
24
|
s.require_path = 'lib'
|
25
25
|
s.files = Dir['{lib,spec}/**/*', 'README.md', 'txbr.gemspec', 'LICENSE']
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: txbr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cameron Dutro
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: abroad
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
103
|
+
version: '7.0'
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
110
|
+
version: '7.0'
|
111
111
|
description: A library for syncing translation resources between Braze and Transifex.
|
112
112
|
email:
|
113
113
|
- camertron@gmail.com
|
@@ -162,7 +162,7 @@ files:
|
|
162
162
|
homepage: https://github.com/lumoslabs/txbr
|
163
163
|
licenses: []
|
164
164
|
metadata: {}
|
165
|
-
post_install_message:
|
165
|
+
post_install_message:
|
166
166
|
rdoc_options: []
|
167
167
|
require_paths:
|
168
168
|
- lib
|
@@ -177,9 +177,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
177
177
|
- !ruby/object:Gem::Version
|
178
178
|
version: '0'
|
179
179
|
requirements: []
|
180
|
-
|
181
|
-
|
182
|
-
signing_key:
|
180
|
+
rubygems_version: 3.2.7
|
181
|
+
signing_key:
|
183
182
|
specification_version: 4
|
184
183
|
summary: A library for syncing translation resources between Braze and Transifex.
|
185
184
|
test_files: []
|