moshimoshi-rails-helper 0.0.1
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 +7 -0
- data/.gitignore +18 -0
- data/.rspec +2 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +22 -0
- data/README.md +44 -0
- data/Rakefile +6 -0
- data/lib/moshimoshi-rails-helper.rb +21 -0
- data/lib/moshimoshi-rails-helper/helper.rb +19 -0
- data/lib/moshimoshi-rails-helper/version.rb +3 -0
- data/moshimoshi-rails-helper.gemspec +23 -0
- data/spec/moshimoshi_rails_helper_spec.rb +12 -0
- data/spec/spec_helper.rb +16 -0
- data/spec/stub.rb +11 -0
- metadata +87 -0
checksums.yaml
ADDED
@@ -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
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -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.
|
data/README.md
ADDED
@@ -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
|
data/Rakefile
ADDED
@@ -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,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
|
data/spec/spec_helper.rb
ADDED
@@ -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
|
data/spec/stub.rb
ADDED
@@ -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
|