moshimoshi-rails-helper 0.0.1

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: 4e1abc8a678c30e3b8a7380fee0ad895814839ab
4
+ data.tar.gz: 71aba6c9dd2f7cba9dc8492b50055e7099b86f2e
5
+ SHA512:
6
+ metadata.gz: b1d5ace0eede863cfe022cb72284bb97c531cc69382643f0c1342ab28e6c1af4c3d1939021f20376173490496ed3fdec9ce2562e7c31b983e62984b4839d8f6f
7
+ data.tar.gz: 2f6416d43eb0a98bc8245291cbf065785e5d7f56164348da96deb3a66bf51acae7fdf20d091a8d7ec80cba94be63102d7930d97a7ee2ec99817ff3182d8545b4
@@ -0,0 +1,18 @@
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
+ *.un~
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+ gem 'rake'
3
+
4
+ # Specify your gem's dependencies in moshimoshi-rails-helper.gemspec
5
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Kristian Freeman
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,44 @@
1
+ # Moshimoshi Rails Helper
2
+
3
+ `moshimoshi-rails-helper` is the official Rails helper for [Moshimoshi](http://moshimoshi.me), a service for setting global user bios.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'moshimoshi-rails-helper'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install moshimoshi-rails-helper
18
+
19
+ ## Usage
20
+
21
+ `moshimoshi-rails-helper` uses a text tag, which means it can be easily integrated into any Rails view.
22
+
23
+ ```erb
24
+ <%= moshimoshi_tag(@user.email) %>
25
+ ```
26
+
27
+ *Moshimoshi* uses the MD5 of your user's email to retrieve the bio, so no user
28
+ emails are passed across the web.
29
+
30
+ You can customize the error message if a bio cannot be retrieved for the user's email:
31
+
32
+ ```erb
33
+ <%= moshimoshi_tag(@user.email), error: 'Bio missing from Moshimoshi' %>
34
+ ```
35
+
36
+ ## Contributing
37
+
38
+ Pull requests always welcome!
39
+
40
+ 1. Fork it
41
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
42
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
43
+ 4. Push to the branch (`git push origin my-new-feature`)
44
+ 5. Create new Pull Request
@@ -0,0 +1,6 @@
1
+ require 'rspec/core/rake_task'
2
+
3
+ RSpec::Core::RakeTask.new('spec')
4
+
5
+ # If you want to make this the default task
6
+ task :default => :spec
@@ -0,0 +1,21 @@
1
+ require 'httparty'
2
+ require "moshimoshi-rails-helper/helper"
3
+ require "moshimoshi-rails-helper/version"
4
+
5
+ module Rails
6
+ module MoshimoshiRailsHelper
7
+ if defined?(::Rails::Engine)
8
+ class Engine < ::Rails::Engine
9
+ initializer 'rails-moshimoshi', group: :all do |app|
10
+ ActiveSupport.on_load(:action_controller) do
11
+ include Rails::MoshimoshiRailsHelper::Helper
12
+ end
13
+
14
+ ActiveSupport.on_load(:action_view) do
15
+ include Rails::MoshimoshiRailsHelper::Helper
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,19 @@
1
+ module Rails
2
+ module MoshimoshiRailsHelper
3
+ module Helper
4
+ def moshimoshi_tag(email, options = {})
5
+ options[:error] ||= "This user has not yet established a bio at http://moshimoshi.me."
6
+
7
+ require 'httparty'
8
+ email_address = email.downcase
9
+ hash = Digest::MD5.hexdigest(email_address)
10
+ response = HTTParty.get("http://moshimoshi.me/api/users/show/#{ hash }")
11
+ unless response.nil?
12
+ return response.body
13
+ else
14
+ return options[:error]
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,3 @@
1
+ module MoshimoshiRailsHelper
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'moshimoshi-rails-helper/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "moshimoshi-rails-helper"
8
+ gem.version = MoshimoshiRailsHelper::VERSION
9
+ gem.authors = ["Kristian Freeman"]
10
+ gem.email = ["kristian@kristianfreeman.com"]
11
+ gem.description = %q{A Rails helper for accessing Moshimoshi bios for users}
12
+ gem.summary = %q{A Rails helper for accessing Moshimoshi bios for users}
13
+ gem.homepage = "http://moshimoshi.me/api"
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
+
20
+ gem.add_dependency "httparty"
21
+
22
+ gem.add_development_dependency "rspec"
23
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe Rails::MoshimoshiRailsHelper::Helper do
4
+ before do
5
+ @stub = MoshimoshiRailsHelperStub.new
6
+ end
7
+
8
+ it "should return a greeting" do
9
+ email = "kristian@kristianfreeman.com"
10
+ @stub.moshimoshi_tag(email).should == "Foo"
11
+ end
12
+ end
@@ -0,0 +1,16 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'moshimoshi-rails-helper'
4
+ require 'stub'
5
+
6
+ RSpec.configure do |config|
7
+ config.treat_symbols_as_metadata_keys_with_true_values = true
8
+ config.run_all_when_everything_filtered = true
9
+ config.filter_run :focus
10
+
11
+ # Run specs in random order to surface order dependencies. If you find an
12
+ # order dependency and want to debug it, you can fix the order by providing
13
+ # the seed, which is printed after each run.
14
+ # --seed 1234
15
+ config.order = 'random'
16
+ end
@@ -0,0 +1,11 @@
1
+ class MoshimoshiRailsHelperStub
2
+ include Rails::MoshimoshiRailsHelper::Helper
3
+
4
+ def moshimoshi_tag(email)
5
+ require 'httparty'
6
+ email_address = email.downcase
7
+ hash = Digest::MD5.hexdigest(email_address)
8
+ response = HTTParty.get("http://moshimoshi.me/api/users/show/#{ hash }")
9
+ return response.body
10
+ end
11
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: moshimoshi-rails-helper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Kristian Freeman
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-05-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: A Rails helper for accessing Moshimoshi bios for users
42
+ email:
43
+ - kristian@kristianfreeman.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - .gitignore
49
+ - .rspec
50
+ - Gemfile
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
54
+ - lib/moshimoshi-rails-helper.rb
55
+ - lib/moshimoshi-rails-helper/helper.rb
56
+ - lib/moshimoshi-rails-helper/version.rb
57
+ - moshimoshi-rails-helper.gemspec
58
+ - spec/moshimoshi_rails_helper_spec.rb
59
+ - spec/spec_helper.rb
60
+ - spec/stub.rb
61
+ homepage: http://moshimoshi.me/api
62
+ licenses: []
63
+ metadata: {}
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubyforge_project:
80
+ rubygems_version: 2.0.3
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: A Rails helper for accessing Moshimoshi bios for users
84
+ test_files:
85
+ - spec/moshimoshi_rails_helper_spec.rb
86
+ - spec/spec_helper.rb
87
+ - spec/stub.rb