link_to_profile 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ vendor/
19
+ bin/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in link_to_profile.gemspec
4
+ gemspec
5
+ gem 'rspec'
6
+ gem 'pry'
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Devon Blandin
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.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # link_to_profile
2
+
3
+ Easily generate profile links.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'link_to_profile'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install link_to_profile
18
+
19
+ ## Usage
20
+
21
+ raw link_to_profile 'username', :twitter
22
+ raw link_to_profile 'username', :linkedin
23
+ raw link_to_profile 'username', :profile
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,9 @@
1
+ module LinkToNetworkHelper
2
+ def link_to_network(options)
3
+ NetworkLinkGenerator.new(options).link
4
+ end
5
+
6
+ def url_to_network(options)
7
+ NetworkLinkGenerator.new(options).url
8
+ end
9
+ end
@@ -0,0 +1,33 @@
1
+ require 'yaml'
2
+
3
+ class ProfileLinkGenerator
4
+ attr_reader :username, :network, :options
5
+
6
+ def initialize(options = {})
7
+ @options = options
8
+ @username = options[:username]
9
+ @network = options[:network]
10
+
11
+ raise ArgumentError if @username.nil? or @network.nil?
12
+ end
13
+
14
+ def url
15
+ templates[network.to_s].sub(/{{username}}/, username)
16
+ end
17
+
18
+ def link
19
+ "<a href='#{url}'>#{network}</a>"
20
+ end
21
+
22
+ private
23
+
24
+ def templates
25
+ options[:templates] ||= YAML.load_file(templates_path)
26
+ end
27
+
28
+ def templates_path
29
+ options[:templates_path] ||= 'lib/link_to_profile/profile_link_templates.yml'
30
+ end
31
+
32
+ class ArgumentError < StandardError; end
33
+ end
@@ -0,0 +1,4 @@
1
+ twitter: 'http://twitter.com/{{username}}'
2
+ github: 'http://github.com/{{username}}'
3
+ facebook: 'http://facebook.com/{{username}}'
4
+ linkedin: 'http://linkedin.com/in/{{username}}'
@@ -0,0 +1,3 @@
1
+ module LinkToProfile
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,5 @@
1
+ require 'link_to_profile/helpers/link_to_profile_helper'
2
+ require 'link_to_profile/profile_link_generator'
3
+ require 'link_to_profile/version'
4
+
5
+ ActionView::Base.send :include, LinkToNetworkHelper
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'link_to_profile/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "link_to_profile"
8
+ gem.version = LinkToProfile::VERSION
9
+ gem.authors = ["Devon Blandin"]
10
+ gem.email = ["dblandin@gmail.com"]
11
+ gem.description = %q{Generate profile links for Twitter, Facebook, LinkedIn, and others}
12
+ gem.summary = %q{Easily generate profile links}
13
+ gem.homepage = "http://github.com/dblandin/link_to_profile"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+ end
@@ -0,0 +1,27 @@
1
+ require 'link_to_profile/profile_link_generator'
2
+
3
+ describe ProfileLinkGenerator do
4
+ describe '#url' do
5
+ it 'generates a twitter url for a user' do
6
+ link = described_class.new(username: 'dblandin', network: :twitter).url
7
+ link.should eq 'http://twitter.com/dblandin'
8
+ end
9
+
10
+ it 'generates a github url for a user' do
11
+ link = described_class.new(username: 'dblandin', network: :github).url
12
+ link.should eq 'http://github.com/dblandin'
13
+ end
14
+ end
15
+
16
+ describe '#link' do
17
+ it 'generates a twitter link for a user' do
18
+ link = described_class.new(username: 'dblandin', network: :twitter).link
19
+ link.should eq "<a href='http://twitter.com/dblandin'>twitter</a>"
20
+ end
21
+
22
+ it 'generates a github link for a user' do
23
+ link = described_class.new(username: 'dblandin', network: :github).link
24
+ link.should eq "<a href='http://github.com/dblandin'>github</a>"
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,3 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'link_to_profile'
metadata ADDED
@@ -0,0 +1,60 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: link_to_profile
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - Devon Blandin
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-02-09 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Generate profile links for Twitter, Facebook, LinkedIn, and others
15
+ email:
16
+ - dblandin@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - Gemfile
23
+ - LICENSE.txt
24
+ - README.md
25
+ - Rakefile
26
+ - lib/link_to_profile.rb
27
+ - lib/link_to_profile/helpers/link_to_profile_helper.rb
28
+ - lib/link_to_profile/profile_link_generator.rb
29
+ - lib/link_to_profile/profile_link_templates.yml
30
+ - lib/link_to_profile/version.rb
31
+ - link_to_profile.gemspec
32
+ - spec/lib/link_to_profile/profile_link_generator_spec.rb
33
+ - spec/spec_helper.rb
34
+ homepage: http://github.com/dblandin/link_to_profile
35
+ licenses: []
36
+ post_install_message:
37
+ rdoc_options: []
38
+ require_paths:
39
+ - lib
40
+ required_ruby_version: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ required_rubygems_version: !ruby/object:Gem::Requirement
47
+ none: false
48
+ requirements:
49
+ - - ! '>='
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ requirements: []
53
+ rubyforge_project:
54
+ rubygems_version: 1.8.24
55
+ signing_key:
56
+ specification_version: 3
57
+ summary: Easily generate profile links
58
+ test_files:
59
+ - spec/lib/link_to_profile/profile_link_generator_spec.rb
60
+ - spec/spec_helper.rb