flayyer 1.1.0 → 1.2.0

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: c9dbded84120524d80d4557e283de7a9b604b8ac71ffe5eb1b6ea9b1bfe941e2
4
- data.tar.gz: 788f7261bee24d9bcafd14ec8e428781ab33881b985d4ccf8fee1e64ef2a5c1d
3
+ metadata.gz: 9f3cd5589505248711256b44531dfe472c9fb2678e58bc74f8737de32d8bc0b7
4
+ data.tar.gz: 96d4cfbdf0fe2ebfcfea5bed7e5ebc6f7a4f66aaf1ded19620bea0df0a273b04
5
5
  SHA512:
6
- metadata.gz: 75f6618085b5293e593a471deca9701eb56cffd7bb7fe5df7e24eca383f4d9c6cd1a5cf850f46e7e2453771f387e7c477028a3d801f51d86a73f5565960b8452
7
- data.tar.gz: '08cca67e8244fb0b5198b5447aa204f612da10f151d23a0eecfa5f8cec66b5b456f0409180694d054c9a26992d8d86b0b8b3766192fddec6fc76a84f3b668cb6'
6
+ metadata.gz: e5152bc7884de73a23808fea60f29daa2aa2f25d639b3ceb0d46ac6857d3d0522dbcb9e195a58159d15fcf98860490a34c577f94041f6e0745e55d3a3b943461
7
+ data.tar.gz: 47f36829fe4ead59e35d1581b42e9444768dd834463a06e37fb9dc754303e501e73c3003b9f21a70e0975792f8ab5146b597ec0833374728c0e058c116427dc9
@@ -16,17 +16,20 @@ on:
16
16
  jobs:
17
17
  test:
18
18
 
19
- runs-on: ubuntu-latest
19
+ strategy:
20
+ fail-fast: false
21
+ matrix:
22
+ os: [ubuntu-18.04, macos-latest]
23
+ ruby: [2.5, 2.6, 2.7]
24
+ runs-on: ${{ matrix.os }}
20
25
 
21
26
  steps:
22
27
  - uses: actions/checkout@v2
23
28
  - name: Set up Ruby
24
- # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
25
- # change this to (see https://github.com/ruby/setup-ruby#versioning):
26
- # uses: ruby/setup-ruby@v1
27
- uses: ruby/setup-ruby@ec106b438a1ff6ff109590de34ddc62c540232e0
29
+ uses: ruby/setup-ruby@v1
28
30
  with:
29
- ruby-version: 2.6
31
+ ruby-version: ${{ matrix.ruby }}
32
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
30
33
  - name: Install dependencies
31
34
  run: bundle install
32
35
  - name: Run tests
@@ -1,26 +1,26 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- flayyer (1.1.0)
4
+ flayyer (1.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
9
  diff-lcs (1.4.4)
10
10
  rake (12.3.3)
11
- rspec (3.9.0)
12
- rspec-core (~> 3.9.0)
13
- rspec-expectations (~> 3.9.0)
14
- rspec-mocks (~> 3.9.0)
15
- rspec-core (3.9.2)
16
- rspec-support (~> 3.9.3)
17
- rspec-expectations (3.9.2)
11
+ rspec (3.10.0)
12
+ rspec-core (~> 3.10.0)
13
+ rspec-expectations (~> 3.10.0)
14
+ rspec-mocks (~> 3.10.0)
15
+ rspec-core (3.10.0)
16
+ rspec-support (~> 3.10.0)
17
+ rspec-expectations (3.10.0)
18
18
  diff-lcs (>= 1.2.0, < 2.0)
19
- rspec-support (~> 3.9.0)
20
- rspec-mocks (3.9.1)
19
+ rspec-support (~> 3.10.0)
20
+ rspec-mocks (3.10.0)
21
21
  diff-lcs (>= 1.2.0, < 2.0)
22
- rspec-support (~> 3.9.0)
23
- rspec-support (3.9.3)
22
+ rspec-support (~> 3.10.0)
23
+ rspec-support (3.10.0)
24
24
 
25
25
  PLATFORMS
26
26
  ruby
data/README.md CHANGED
@@ -45,7 +45,7 @@ url = flayyer.href
45
45
  # > https://flayyer.io/v2/tenant/deck/template.jpeg?__v=1596906866&title=Hello+world%21
46
46
  ```
47
47
 
48
- Variables can be complex arrays and hashes.
48
+ Variables can be complex arrays and hashes.
49
49
 
50
50
  ```ruby
51
51
  flayyer = Flayyer::FlayyerURL.create do |f|
@@ -56,6 +56,9 @@ flayyer = Flayyer::FlayyerURL.create do |f|
56
56
  { text: 'Apples', count: 14 },
57
57
  ],
58
58
  }
59
+ f.meta = {
60
+ id: 'slug-or-id', # To identify the resource in our analytics report
61
+ }
59
62
  end
60
63
  ```
61
64
 
@@ -5,25 +5,40 @@ module Flayyer
5
5
  class Error < StandardError; end
6
6
 
7
7
  class FlayyerURL
8
- attr_accessor :version, :tenant, :deck, :template, :extension, :variables
8
+ attr_accessor :version, :tenant, :deck, :template, :extension, :variables, :meta
9
9
 
10
10
  def self.create(&block)
11
11
  self.new(&block)
12
12
  end
13
13
 
14
- def initialize(tenant = nil, deck = nil, template = nil, version = nil, extension = 'jpeg', variables = {})
14
+ def initialize(tenant = nil, deck = nil, template = nil, version = nil, extension = 'jpeg', variables = {}, meta = {})
15
15
  @tenant = tenant
16
16
  @deck = deck
17
17
  @template = template
18
18
  @version = version
19
19
  @extension = extension
20
20
  @variables = variables
21
+ @meta = meta
21
22
  yield(self) if block_given?
22
23
  end
23
24
 
24
25
  def querystring
26
+ # Allow accesing the keys of @meta with symbols and strings
27
+ # https://stackoverflow.com/a/10786575
28
+ @meta.default_proc = proc do |h, k|
29
+ case k
30
+ when String then sym = k.to_sym; h[sym] if h.key?(sym)
31
+ when Symbol then str = k.to_s; h[str] if h.key?(str)
32
+ end
33
+ end
34
+
25
35
  defaults = {
26
- __v: Time.now.to_i, # This forces crawlers to refresh the image
36
+ __v: @meta[:v] || Time.now.to_i, # This forces crawlers to refresh the image
37
+ __id: @meta[:id] || nil,
38
+ _w: @meta[:width] || nil,
39
+ _h: @meta[:height] || nil,
40
+ _res: @meta[:resolution] || nil,
41
+ _ua: @meta[:agent] || nil,
27
42
  }
28
43
  result = FlayyerHash.new(@variables.nil? ? defaults : defaults.merge(@variables))
29
44
  result.to_query
@@ -57,6 +72,8 @@ module Flayyer
57
72
  v = Hash[v.each_with_index.to_a.map(&:reverse)] if v.is_a?(Array)
58
73
  if v.is_a?(Hash)
59
74
  h.merge!(FlayyerHash.new(v).to_query_hash(new_key))
75
+ elsif v.nil?
76
+ # skip null values
60
77
  else
61
78
  h[new_key] = v
62
79
  end
@@ -1,3 +1,3 @@
1
1
  module Flayyer
2
- VERSION = '1.1.0'
2
+ VERSION = '1.2.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flayyer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patricio López Juri
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-11-16 00:00:00.000000000 Z
11
+ date: 2020-12-19 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: FLAYYER.com helper classes and methods
14
14
  email: