avatar_store 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5aaa97c17fba0924e124c335128aa8a22da0de21
4
+ data.tar.gz: eb8c2a08fb85e9f7228e179b754b59b7b13d6155
5
+ SHA512:
6
+ metadata.gz: 901e1596dc0f05d2d3ef62b4c060aa93eac91038738cc9a8b56ecc299bd4ec00ab1dfd3c8b4c4f596cb0521988aec890de12125d43523e35d32c52a971a442d2
7
+ data.tar.gz: ec6c38512c13b347bd96d64d02f6d8f7912a22219c49ace32b9cc900dd643f4641e74e0a55c5b5a196446f63cf57093366d67f68eb0628cd80fe5faf4c8dad23
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.5
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in avatar_store.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 bin
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,49 @@
1
+ # AvatarStore
2
+
3
+ helper methods for avatarstore.org
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'avatar_store'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install avatar_store
20
+
21
+ ## Usage
22
+
23
+ There only one method `img_src`, the first parameter `email` is required, and `size`(64, 128 or 256 is accepted, others will be ignored. The default is 256) is optional.
24
+
25
+ ```
26
+ irb(main):001:0> require 'avatar_store'
27
+ => true
28
+
29
+ irb(main):002:0> e = "liubin0329@gmail.com"
30
+ => "liubin0329@gmail.com"
31
+
32
+ irb(main):003:0> AvatarStore.img_src e
33
+ => "//farm.avatarstore.org/2c07a4ee1a8447320fceb4a62989ed71"
34
+
35
+ irb(main):004:0> AvatarStore.img_src e, 64
36
+ => "//farm.avatarstore.org/2c07a4ee1a8447320fceb4a62989ed71/64"
37
+
38
+ irb(main):004:0> AvatarStore.img_src e, 72
39
+ => "//farm.avatarstore.org/2c07a4ee1a8447320fceb4a62989ed71"
40
+ ```
41
+
42
+
43
+ ## Contributing
44
+
45
+ 1. Fork it ( https://github.com/liubin/avatar_store/fork )
46
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
47
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
48
+ 4. Push to the branch (`git push origin my-new-feature`)
49
+ 5. Create a new Pull Request
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
7
+ task :test => :spec
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'avatar_store/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "avatar_store"
8
+ spec.version = AvatarStore::VERSION
9
+ spec.authors = ["bin"]
10
+ spec.email = ["liubin0329@gmail.com"]
11
+ spec.summary = %q{helper methods for avatarstore.org}
12
+ spec.description = %q{helper methods for http://avatarstore.org, the free, simple avatar holding service}
13
+ spec.homepage = "https://github.com/liubin/avatar_store"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "bundler", "~> 1.7"
22
+ spec.add_dependency "rake", "~> 10.0"
23
+ spec.add_dependency "rspec"
24
+
25
+ end
@@ -0,0 +1,19 @@
1
+ require "avatar_store/version"
2
+ require 'digest/md5'
3
+
4
+ module AvatarStore
5
+
6
+ FARM = "http://www.avatarstore.org"
7
+ VALID_SIZE = [64, 128, 256]
8
+
9
+ def self.img_src(email, size = nil)
10
+ key = "#{FARM}/#{Digest::MD5.hexdigest email.downcase}"
11
+ if !size.nil? and VALID_SIZE.include?(size)
12
+ key = "#{key}/#{size}" if not size.nil?
13
+ else
14
+ key = "#{key}"
15
+ end
16
+ key
17
+ end
18
+
19
+ end
@@ -0,0 +1,3 @@
1
+ module AvatarStore
2
+ VERSION = "0.0.3"
3
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe AvatarStore do
4
+ it 'has a version number' do
5
+ expect(AvatarStore::VERSION).not_to be nil
6
+ end
7
+
8
+ it 'should calculate md5 for an email' do
9
+ expect(AvatarStore.img_src('liubin0329@gmail.com')).to eq("#{AvatarStore::FARM}/2c07a4ee1a8447320fceb4a62989ed71")
10
+ expect(AvatarStore.img_src('liubin0329@gmail.com', 64)).to eq("#{AvatarStore::FARM}/2c07a4ee1a8447320fceb4a62989ed71/64")
11
+ end
12
+
13
+ it 'should have the extrat avatar size' do
14
+ expect(AvatarStore.img_src('liubin0329@gmail.com')).to eq("#{AvatarStore::FARM}/2c07a4ee1a8447320fceb4a62989ed71")
15
+ expect(AvatarStore.img_src('liubin0329@gmail.com', 64)).to eq("#{AvatarStore::FARM}/2c07a4ee1a8447320fceb4a62989ed71/64")
16
+ expect(AvatarStore.img_src('liubin0329@gmail.com', 128)).to eq("#{AvatarStore::FARM}/2c07a4ee1a8447320fceb4a62989ed71/128")
17
+ expect(AvatarStore.img_src('liubin0329@gmail.com', 256)).to eq("#{AvatarStore::FARM}/2c07a4ee1a8447320fceb4a62989ed71/256")
18
+ expect(AvatarStore.img_src('liubin0329@gmail.com', 72)).to eq("#{AvatarStore::FARM}/2c07a4ee1a8447320fceb4a62989ed71")
19
+ end
20
+
21
+ end
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'avatar_store'
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: avatar_store
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - bin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-05-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: helper methods for http://avatarstore.org, the free, simple avatar holding
56
+ service
57
+ email:
58
+ - liubin0329@gmail.com
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - .gitignore
64
+ - .rspec
65
+ - .travis.yml
66
+ - Gemfile
67
+ - LICENSE.txt
68
+ - README.md
69
+ - Rakefile
70
+ - avatar_store.gemspec
71
+ - lib/avatar_store.rb
72
+ - lib/avatar_store/version.rb
73
+ - spec/avatar_store_spec.rb
74
+ - spec/spec_helper.rb
75
+ homepage: https://github.com/liubin/avatar_store
76
+ licenses:
77
+ - MIT
78
+ metadata: {}
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - '>='
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubyforge_project:
95
+ rubygems_version: 2.0.14
96
+ signing_key:
97
+ specification_version: 4
98
+ summary: helper methods for avatarstore.org
99
+ test_files:
100
+ - spec/avatar_store_spec.rb
101
+ - spec/spec_helper.rb