jekyll-avatar 0.2.1 → 0.2.2

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
  SHA1:
3
- metadata.gz: 2df65b0567ec7f5ace78586ba68a2212e370944d
4
- data.tar.gz: a0ac164bc7bfc19d6c3ddc50f038944a7cf7f6f2
3
+ metadata.gz: 07f6bbf150caf11f730c204ade5d6b2258a2bb1d
4
+ data.tar.gz: c73d73c20983b02c94fa37833ee00b44d18d1429
5
5
  SHA512:
6
- metadata.gz: 60bd8737b13b66b6d80efeb8e572679a99f9f3e913ddad75f5d2c03cf368899141be33e45474d88c8e44d64ae6fc444d0b1e501c719a9c61129fac20eca7d00e
7
- data.tar.gz: fe32c49f9a12b3fbaf4454dbb25a2cca4e5f59ffd4e9fdba58171b48f40cfd34c441c0e7b67ccb7227147234f98a11a19725748a95415a8e4447b00b174fb894
6
+ metadata.gz: 59d0f9536f6a531497f22910ffcd770c87fa970f4770595bb89eb34b4b514c7677853c94c6324fe82affd15953f5f03e9b8c0b7a64f26735bc7814480fd4e37a
7
+ data.tar.gz: 2cf1615323742bedf9e60222444316eed33eb823727cc362351a5741d9dbaf9617c1a04686060c3ca71e364bcbe9615d68529b72e6ad3855a9bce7c63af38cee
data/README.md CHANGED
@@ -43,7 +43,7 @@ That will output:
43
43
 
44
44
  ### Customizing
45
45
 
46
- You can customize the size of the resulting avatar by passing the size arugment:
46
+ You can customize the size of the resulting avatar by passing the size argument:
47
47
 
48
48
  ```
49
49
  {% avatar hubot size=50 %}
@@ -54,3 +54,21 @@ That will output:
54
54
  ```html
55
55
  <img class="avatar" src="https://avatars3.githubusercontent.com/hubot?v=3&amp;s=50" alt="hubot" width="50" height="50" />
56
56
  ```
57
+
58
+ ### Passing the username as variable
59
+
60
+ You can also pass the username as a variable, like this:
61
+
62
+ ```
63
+ {% assign username="hubot" %}
64
+ {% avatar {{ username }} %}
65
+ ```
66
+
67
+ Or, if the variable is someplace a bit more complex, like a loop:
68
+
69
+ ```
70
+ {% assign employees = "alice|bob" | split:"|" %}
71
+ {% for employee in employees %}
72
+ {% avatar user=employee %}
73
+ {% endfor %}
74
+ ```
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
 
20
20
  spec.require_paths = ['lib']
21
21
 
22
- spec.add_dependency 'jekyll', '>= 2.4'
22
+ spec.add_dependency 'jekyll', '~> 3.0'
23
23
  spec.add_development_dependency 'bundler', '~> 1.11'
24
24
  spec.add_development_dependency 'rake', '~> 10.0'
25
25
  spec.add_development_dependency 'rspec', '~> 3.0'
@@ -1,5 +1,3 @@
1
- require 'jekyll-avatar/version'
2
-
3
1
  module Jekyll
4
2
  class Avatar < Liquid::Tag
5
3
  SERVERS = 4
@@ -12,49 +10,51 @@ module Jekyll
12
10
  end
13
11
 
14
12
  def render(context)
15
- @text = Liquid::Template.parse(@text).render(context)
16
-
13
+ @context = context
14
+ @text = Liquid::Template.parse(@text).render(@context)
17
15
  tag = '<img '
18
16
 
19
17
  # See http://primercss.io/avatars/#small-avatars
20
- if size < 48
21
- tag << 'class="avatar avatar-small" '
22
- else
23
- tag << 'class="avatar" '
24
- end
18
+ tag << if size < 48
19
+ 'class="avatar avatar-small" '
20
+ else
21
+ 'class="avatar" '
22
+ end
25
23
 
26
24
  tag << "src=\"#{url}\" alt=\"#{username}\" "
27
25
  tag << "width=\"#{size}\" height=\"#{size}\" />"
28
- tag
29
26
  end
30
27
 
31
28
  private
32
29
 
33
30
  def username
34
- @username ||= @text.split(' ').first.sub('@', '')
31
+ matches = @text.match(/\s+user=(\w+)\s+/)
32
+ if matches
33
+ @context[matches[1]]
34
+ else
35
+ @text.split(' ').first.sub('@', '')
36
+ end
35
37
  end
36
38
 
37
39
  def size
38
- @size ||= begin
39
- matches = @text.match(/\bsize=(\d+)\b/i)
40
- matches ? matches[1].to_i : DEFAULT_SIZE
41
- end
40
+ matches = @text.match(/\bsize=(\d+)\b/i)
41
+ matches ? matches[1].to_i : DEFAULT_SIZE
42
42
  end
43
43
 
44
44
  def path
45
- @path ||= "#{username}?v=#{VERSION}&s=#{size}"
45
+ "#{username}?v=#{VERSION}&s=#{size}"
46
46
  end
47
47
 
48
48
  def server_number
49
- @server_number ||= Zlib.crc32(path) % SERVERS
49
+ Zlib.crc32(path) % SERVERS
50
50
  end
51
51
 
52
52
  def host
53
- @host ||= "avatars#{server_number}.githubusercontent.com"
53
+ "avatars#{server_number}.githubusercontent.com"
54
54
  end
55
55
 
56
56
  def url
57
- @url ||= "https://#{host}/#{path}"
57
+ "https://#{host}/#{path}"
58
58
  end
59
59
  end
60
60
  end
@@ -1,6 +1,6 @@
1
1
  module Liquid; class Tag; end; end
2
2
  module Jekyll
3
3
  class Avatar < Liquid::Tag
4
- VERSION = '0.2.1'
4
+ VERSION = '0.2.2'.freeze
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-avatar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Balter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-13 00:00:00.000000000 Z
11
+ date: 2016-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.4'
19
+ version: '3.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '2.4'
26
+ version: '3.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
121
  version: '0'
122
122
  requirements: []
123
123
  rubyforge_project:
124
- rubygems_version: 2.5.1
124
+ rubygems_version: 2.5.2
125
125
  signing_key:
126
126
  specification_version: 4
127
127
  summary: A Jekyll plugin for rendering GitHub avatars