stackoverflair 0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "shoulda", ">= 0"
10
+ gem "bundler", "~> 1.0.0"
11
+ gem "jeweler", "~> 1.5.2"
12
+ gem "rcov", ">= 0"
13
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,20 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ git (1.2.5)
5
+ jeweler (1.5.2)
6
+ bundler (~> 1.0.0)
7
+ git (>= 1.2.5)
8
+ rake
9
+ rake (0.8.7)
10
+ rcov (0.9.9)
11
+ shoulda (2.11.3)
12
+
13
+ PLATFORMS
14
+ x86-mingw32
15
+
16
+ DEPENDENCIES
17
+ bundler (~> 1.0.0)
18
+ jeweler (~> 1.5.2)
19
+ rcov
20
+ shoulda
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 nashby
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,51 @@
1
+ = stackoverflair
2
+
3
+ Put your stackoverflow flair on blog or wherever you want.
4
+
5
+ == Usage
6
+
7
+ gem install stackoverflair
8
+
9
+ or add to Gemfile:
10
+
11
+ gem 'stackoverflair'
12
+
13
+ and
14
+
15
+ bundle install
16
+
17
+ In your rails app config/application.rb:
18
+
19
+ Stackoverflair::defaults[:id] = "336626"
20
+ Stackoverflair::defaults[:name] = "nash"
21
+ ...
22
+
23
+ Options:
24
+
25
+ :id => "", # your id http://stackoverflow.com/users/336626/nash <-- here
26
+ :name => "", # your stackoverflow name
27
+ :theme => "default", # flair theme ("default", "dark", "hotdog")
28
+ :width => "208", # image width
29
+ :height => "58", # image height
30
+ :alt => false, # alt text
31
+ :title => false # title
32
+
33
+ Show the flair:
34
+
35
+ <% stackoverflow_flair %>
36
+
37
+ == Contributing to stackoverflair
38
+
39
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
40
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
41
+ * Fork the project
42
+ * Start a feature/bugfix branch
43
+ * Commit and push until you are happy with your contribution
44
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
45
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
46
+
47
+ == Copyright
48
+
49
+ Copyright (c) 2011 nashby. See LICENSE.txt for
50
+ further details.
51
+
data/Rakefile ADDED
@@ -0,0 +1,49 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'rake'
11
+
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |gem|
14
+ gem.name = "stackoverflair"
15
+ gem.homepage = "http://github.com/nashby/stackoverflair"
16
+ gem.license = "MIT"
17
+ gem.version = "0.1"
18
+ gem.summary = %Q{put your stackoverflow flair wherever you want}
19
+ gem.description = %Q{put your stackoverflow flair wherever you want}
20
+ gem.email = "younash@gmail.com"
21
+ gem.authors = ["nashby"]
22
+ end
23
+ Jeweler::RubygemsDotOrgTasks.new
24
+
25
+ require 'rake/testtask'
26
+ Rake::TestTask.new(:test) do |test|
27
+ test.libs << 'lib' << 'test'
28
+ test.pattern = 'test/**/test_*.rb'
29
+ test.verbose = true
30
+ end
31
+
32
+ require 'rcov/rcovtask'
33
+ Rcov::RcovTask.new do |test|
34
+ test.libs << 'test'
35
+ test.pattern = 'test/**/test_*.rb'
36
+ test.verbose = true
37
+ end
38
+
39
+ task :default => :test
40
+
41
+ require 'rake/rdoctask'
42
+ Rake::RDocTask.new do |rdoc|
43
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
+
45
+ rdoc.rdoc_dir = 'rdoc'
46
+ rdoc.title = "stackoverflair #{version}"
47
+ rdoc.rdoc_files.include('README*')
48
+ rdoc.rdoc_files.include('lib/**/*.rb')
49
+ end
@@ -0,0 +1,25 @@
1
+ module Stackoverflair
2
+ class Flair
3
+
4
+ THEMES = ["default", "clean", "dark", "hotdog"]
5
+
6
+ def self.put
7
+ return "You can use only these themes: #{themes}" unless THEMES.include? Stackoverflair::defaults[:theme]
8
+ "<a href='http://stackoverflow.com/users/#{Stackoverflair::defaults[:id]}'>
9
+ <img src='http://stackoverflow.com/users/flair/#{Stackoverflair::defaults[:id]}.png?theme=#{Stackoverflair::defaults[:theme]}' width='#{Stackoverflair::defaults[:width]}' height='#{Stackoverflair::defaults[:height]}' alt='#{set_default_alt}' title='#{set_default_title}'></a>"
10
+ end
11
+
12
+ def self.set_default_alt
13
+ Stackoverflair::defaults[:alt] ||= "profile for #{Stackoverflair::defaults[:name]} at Stack Overflow, Q&amp;A for professional and enthusiast programmers "
14
+ end
15
+
16
+ def self.set_default_title
17
+ Stackoverflair::defaults[:title] ||= "profile for #{Stackoverflair::defaults[:name]} at Stack Overflow, Q&amp;A for professional and enthusiast programmers "
18
+ end
19
+
20
+ def self.themes
21
+ THEMES.join(', ')
22
+ end
23
+
24
+ end
25
+ end
@@ -0,0 +1,3 @@
1
+ def stackoverflow_flair
2
+ raw Stackoverflair::Flair.put
3
+ end
@@ -0,0 +1,18 @@
1
+ %w[view_helpers flair].each do |file|
2
+ require File.join(File.dirname(__FILE__), "stackoverflair", file)
3
+ end
4
+ module Stackoverflair
5
+ @defaults = {
6
+ :id => "",
7
+ :name => "",
8
+ :theme => "default",
9
+ :width => "208",
10
+ :height => "58",
11
+ :alt => false,
12
+ :title => false
13
+ }
14
+
15
+ def self.defaults
16
+ @defaults
17
+ end
18
+ end
@@ -0,0 +1,64 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{stackoverflair}
8
+ s.version = "0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["nashby"]
12
+ s.date = %q{2011-02-28}
13
+ s.description = %q{put your stackoverflow flair wherever you want}
14
+ s.email = %q{younash@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ "Gemfile",
22
+ "Gemfile.lock",
23
+ "LICENSE.txt",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "lib/stackoverflair.rb",
27
+ "lib/stackoverflair/flair.rb",
28
+ "lib/stackoverflair/view_helpers.rb",
29
+ "stackoverflair.gemspec",
30
+ "test/helper.rb",
31
+ "test/test_stackoverflair.rb"
32
+ ]
33
+ s.homepage = %q{http://github.com/nashby/stackoverflair}
34
+ s.licenses = ["MIT"]
35
+ s.require_paths = ["lib"]
36
+ s.rubygems_version = %q{1.5.0}
37
+ s.summary = %q{put your stackoverflow flair wherever you want}
38
+ s.test_files = [
39
+ "test/helper.rb",
40
+ "test/test_stackoverflair.rb"
41
+ ]
42
+
43
+ if s.respond_to? :specification_version then
44
+ s.specification_version = 3
45
+
46
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
47
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
48
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
49
+ s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
50
+ s.add_development_dependency(%q<rcov>, [">= 0"])
51
+ else
52
+ s.add_dependency(%q<shoulda>, [">= 0"])
53
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
54
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
55
+ s.add_dependency(%q<rcov>, [">= 0"])
56
+ end
57
+ else
58
+ s.add_dependency(%q<shoulda>, [">= 0"])
59
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
60
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
61
+ s.add_dependency(%q<rcov>, [">= 0"])
62
+ end
63
+ end
64
+
data/test/helper.rb ADDED
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'test/unit'
11
+ require 'shoulda'
12
+
13
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
15
+ require 'stackoverflair'
16
+
17
+ class Test::Unit::TestCase
18
+ end
@@ -0,0 +1,41 @@
1
+ require 'helper'
2
+
3
+ class TestStackoverflair < Test::Unit::TestCase
4
+
5
+ def setup
6
+ Stackoverflair::defaults[:id] = "336626"
7
+ Stackoverflair::defaults[:name] = "nash"
8
+ Stackoverflair::defaults[:theme] = "default"
9
+ Stackoverflair::defaults[:title] = false
10
+ Stackoverflair::defaults[:alt] = false
11
+ end
12
+
13
+ should "return the flair" do
14
+ assert_equal "<a href='http://stackoverflow.com/users/336626'>
15
+ <img src='http://stackoverflow.com/users/flair/336626.png?theme=default' width='208' height='58' alt='profile for nash at Stack Overflow, Q&amp;A for professional and enthusiast programmers ' title='profile for nash at Stack Overflow, Q&amp;A for professional and enthusiast programmers '></a>", Stackoverflair::Flair.put
16
+ end
17
+
18
+ should "change default alt" do
19
+ Stackoverflair::defaults[:alt] = "test"
20
+ assert_equal "<a href='http://stackoverflow.com/users/336626'>
21
+ <img src='http://stackoverflow.com/users/flair/336626.png?theme=default' width='208' height='58' alt='test' title='profile for nash at Stack Overflow, Q&amp;A for professional and enthusiast programmers '></a>", Stackoverflair::Flair.put
22
+ end
23
+
24
+ should "change default title" do
25
+ Stackoverflair::defaults[:title] = "test"
26
+ assert_equal "<a href='http://stackoverflow.com/users/336626'>
27
+ <img src='http://stackoverflow.com/users/flair/336626.png?theme=default' width='208' height='58' alt='profile for nash at Stack Overflow, Q&amp;A for professional and enthusiast programmers ' title='test'></a>", Stackoverflair::Flair.put
28
+ end
29
+
30
+ should "change default theme" do
31
+ Stackoverflair::defaults[:theme] = "hotdog"
32
+ assert_equal "<a href='http://stackoverflow.com/users/336626'>
33
+ <img src='http://stackoverflow.com/users/flair/336626.png?theme=hotdog' width='208' height='58' alt='profile for nash at Stack Overflow, Q&amp;A for professional and enthusiast programmers ' title='profile for nash at Stack Overflow, Q&amp;A for professional and enthusiast programmers '></a>", Stackoverflair::Flair.put
34
+ end
35
+
36
+ should "raise exception when use wrong theme" do
37
+ Stackoverflair::defaults[:theme] = "wrong_theme"
38
+ assert_equal "You can use only these themes: #{Stackoverflair::Flair.themes}", Stackoverflair::Flair.put
39
+ end
40
+
41
+ end
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: stackoverflair
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ prerelease: !!null
6
+ platform: ruby
7
+ authors:
8
+ - nashby
9
+ autorequire: !!null
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-02-28 00:00:00.000000000 +02:00
13
+ default_executable: !!null
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: shoulda
17
+ requirement: &16512708 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: *16512708
26
+ - !ruby/object:Gem::Dependency
27
+ name: bundler
28
+ requirement: &16511688 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 1.0.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: *16511688
37
+ - !ruby/object:Gem::Dependency
38
+ name: jeweler
39
+ requirement: &16510680 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ version: 1.5.2
45
+ type: :development
46
+ prerelease: false
47
+ version_requirements: *16510680
48
+ - !ruby/object:Gem::Dependency
49
+ name: rcov
50
+ requirement: &16509924 !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ type: :development
57
+ prerelease: false
58
+ version_requirements: *16509924
59
+ description: put your stackoverflow flair wherever you want
60
+ email: younash@gmail.com
61
+ executables: []
62
+ extensions: []
63
+ extra_rdoc_files:
64
+ - LICENSE.txt
65
+ - README.rdoc
66
+ files:
67
+ - .document
68
+ - Gemfile
69
+ - Gemfile.lock
70
+ - LICENSE.txt
71
+ - README.rdoc
72
+ - Rakefile
73
+ - lib/stackoverflair.rb
74
+ - lib/stackoverflair/flair.rb
75
+ - lib/stackoverflair/view_helpers.rb
76
+ - stackoverflair.gemspec
77
+ - test/helper.rb
78
+ - test/test_stackoverflair.rb
79
+ has_rdoc: true
80
+ homepage: http://github.com/nashby/stackoverflair
81
+ licenses:
82
+ - MIT
83
+ post_install_message: !!null
84
+ rdoc_options: []
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ! '>='
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ segments:
94
+ - 0
95
+ hash: -921630285
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ requirements: []
103
+ rubyforge_project: !!null
104
+ rubygems_version: 1.5.0
105
+ signing_key: !!null
106
+ specification_version: 3
107
+ summary: put your stackoverflow flair wherever you want
108
+ test_files:
109
+ - test/helper.rb
110
+ - test/test_stackoverflair.rb