realnick 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MjFiYjBhYWU0NDg1MTM0YzM3YmJmYzA1MGJiN2UyN2M4YmQ3YmQzMw==
5
+ data.tar.gz: !binary |-
6
+ MTExMzYwMDRlNjYyOWFiMDY1NjNlMWFkM2RmMWJhMzQwNTUxZGYxZQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ OWVjMGQwYTgzZjk0MWJiNzkzOGIyMDcwZTI1NWY1MzU4OWFmNzNhMTMxMDQz
10
+ MzlhMzNjZThiN2U2YzkyOGVjMzlhZDZiMmMzYTdkMWYyMjNjMDlkNThjN2Y3
11
+ YTIzYmE4ZGQ1NTI2ZjE5YjkzNjdjODMwZTk4MzVkODU2NWFhYjY=
12
+ data.tar.gz: !binary |-
13
+ Y2E3ZmM5MzY4NGE0NDIwMDJlODRmMjBjMjY3NDEzMDNjM2U2YjY2ZjRmMjc0
14
+ YjdkZjJkMmVmNmZmOTZjOTMwNDEyNTQ2MTE5MWNkYmY2YjMyMGRiMjFhMTU3
15
+ M2I1ODhlMmJjNTAxYTM1NGYyZmUyOTBhNTE5N2Q1NGEzNmM3YTc=
data/.document ADDED
@@ -0,0 +1,3 @@
1
+ -
2
+ ChangeLog.md
3
+ LICENSE.txt
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ Gemfile.lock
2
+ doc/
3
+ pkg/
4
+ vendor/cache/*.gem
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour --format documentation
data/.travis.yml ADDED
@@ -0,0 +1,12 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 1.9.2
5
+ - jruby-18mode
6
+ - jruby-19mode
7
+ - rbx-18mode
8
+ - rbx-19mode
9
+ - ruby-head
10
+ - jruby-head
11
+ - 1.8.7
12
+ - ree
data/.yardopts ADDED
@@ -0,0 +1 @@
1
+ --markup markdown --title "realnick Documentation" --protected
data/ChangeLog.md ADDED
@@ -0,0 +1,4 @@
1
+ ### 0.1.0 / 2013-08-29
2
+
3
+ * Initial release:
4
+
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ gem 'kramdown'
7
+ end
8
+
9
+ group :test do
10
+ gem 'rake'
11
+ end
12
+
13
+ gem 'nokogiri'
14
+ gem 'json'
15
+ gem 'unicode'
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 Fernando Mumbach
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.md ADDED
@@ -0,0 +1,31 @@
1
+ # realnick
2
+ [![Build Status](https://travis-ci.org/fermuch/realnick.png?branch=master)](https://travis-ci.org/fermuch/realnick)
3
+
4
+ * [Homepage](https://github.com/fermuch/realnick#readme)
5
+ * [Issues](https://github.com/fermuch/realnick/issues)
6
+ * [Documentation](http://rubydoc.info/github/fermuch/realnick/master/frames)
7
+ * [Email](mailto:fermuch at gmail.com)
8
+
9
+ ## Description
10
+
11
+ Tired of creating new nicknames for your bots? Well, I see a lot of people using names based on anime characters, so I made a gem to retrieve some names and use them.
12
+
13
+ ## Features
14
+
15
+ It takes care of unicode problems, bad-characters, and adds some preffix to make them more random!
16
+
17
+ ## Examples
18
+
19
+ require 'realnick'
20
+ Realnick.fetch.first
21
+ # et voila!
22
+
23
+ ## Install
24
+
25
+ $ gem install realnick
26
+
27
+ ## Copyright
28
+
29
+ Copyright (c) 2013 Fernando Mumbach
30
+
31
+ See [LICENSE](LICENSE.txt) for details.
data/Rakefile ADDED
@@ -0,0 +1,34 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+
5
+ begin
6
+ require 'bundler'
7
+ rescue LoadError => e
8
+ warn e.message
9
+ warn "Run `gem install bundler` to install Bundler."
10
+ exit -1
11
+ end
12
+
13
+ begin
14
+ Bundler.setup(:development)
15
+ rescue Bundler::BundlerError => e
16
+ warn e.message
17
+ warn "Run `bundle install` to install missing gems."
18
+ exit e.status_code
19
+ end
20
+
21
+ require 'rake'
22
+
23
+ require 'rubygems/tasks'
24
+ Gem::Tasks.new
25
+
26
+ require 'rspec/core/rake_task'
27
+ RSpec::Core::RakeTask.new
28
+
29
+ task :test => :spec
30
+ task :default => :spec
31
+
32
+ require 'yard'
33
+ YARD::Rake::YardocTask.new
34
+ task :doc => :yard
data/lib/realnick.rb ADDED
@@ -0,0 +1,49 @@
1
+ require 'realnick/version'
2
+ require 'open-uri'
3
+ require 'json'
4
+ require 'nokogiri'
5
+ require 'realnick/utils'
6
+
7
+
8
+ module Realnick
9
+ class << self
10
+
11
+ # Main method. With this you fetch a nick based on the method.
12
+ # Available methods: popular_anime, top_anime, upcoming_anime, just_added_anime
13
+ def fetch(method = 'popular_anime')
14
+ methods = ['popular_anime', 'top_anime', 'upcoming_anime']
15
+ raise ArgumentError, 'method not found' unless methods.include? method
16
+
17
+ case method
18
+ when 'top_anime'
19
+ @url = 'http://mal-api.com/anime/top'
20
+ when 'popular_anime'
21
+ @url = 'http://mal-api.com/anime/popular'
22
+ when 'upcoming_anime'
23
+ @url = 'http://mal-api.com/anime/upcoming'
24
+ end
25
+
26
+ anime = JSON.parse(open(@url).read).sample
27
+ url = URI::encode("http://myanimelist.net/anime/#{anime['id']}/#{anime['title']}/characters")
28
+
29
+ characters = parse_characters(url)
30
+
31
+ # randomize a little more by adding a suffix
32
+ characters.shuffle.map{ |c|
33
+ c << ["", "-san", "-sama", "-sensei"].sample
34
+ }
35
+ end
36
+
37
+ private
38
+ # parse characters from MyAnimeList
39
+ def parse_characters(url)
40
+ #@search = 'td[class="borderClass bgColor2"]'
41
+ @search = 'div[style="padding: 0 7px;"] td[width="27"] a img'
42
+ d = Nokogiri::HTML(open(url).read)
43
+ d.css(@search).map do |c|
44
+ c.attribute('alt').to_s.split(/(?:\s*(?:,|\s|\')\s*)+/).shuffle.join("-").downcase
45
+ end
46
+ end
47
+
48
+ end
49
+ end
@@ -0,0 +1,7 @@
1
+ require 'unicode'
2
+
3
+ class String
4
+ def downcase
5
+ Unicode::downcase(self)
6
+ end
7
+ end
@@ -0,0 +1,4 @@
1
+ module Realnick
2
+ # realnick version
3
+ VERSION = "0.1.3"
4
+ end
data/realnick.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require File.expand_path('../lib/realnick/version', __FILE__)
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.name = "realnick"
7
+ gem.version = Realnick::VERSION
8
+ gem.summary = %q{Get real nicknames, usables for bots}
9
+ gem.description = %q{Get real nicknames, usables for bots}
10
+ gem.license = "MIT"
11
+ gem.authors = ["Fernando Mumbach"]
12
+ gem.email = "fermuch@gmail.com"
13
+ gem.homepage = "https://github.com/fermuch/realnick#readme"
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_development_dependency 'bundler', '~> 1.0'
21
+ gem.add_development_dependency 'rake', '~> 0.8'
22
+ gem.add_development_dependency 'rspec', '~> 2.4'
23
+ gem.add_development_dependency 'rubygems-tasks', '~> 0.2'
24
+ gem.add_development_dependency 'yard', '~> 0.8'
25
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+ require 'realnick'
3
+
4
+ describe Realnick do
5
+
6
+ it "should have a VERSION constant" do
7
+ subject.const_get('VERSION').should_not be_empty
8
+ end
9
+
10
+ it "should raise error when method is not valid" do
11
+ expect {
12
+ Realnick.fetch(:method => 'I am not a valid method')
13
+ }.to raise_error(ArgumentError)
14
+ end
15
+
16
+ it "should return a valid nick" do
17
+ Realnick.fetch.first.should be_an_instance_of(String)
18
+ end
19
+
20
+ end
@@ -0,0 +1,4 @@
1
+ require 'rspec'
2
+ require 'realnick/version'
3
+
4
+ include Realnick
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: realnick
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.3
5
+ platform: ruby
6
+ authors:
7
+ - Fernando Mumbach
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-08-29 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.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '0.8'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '0.8'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '2.4'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '2.4'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubygems-tasks
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '0.2'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '0.2'
69
+ - !ruby/object:Gem::Dependency
70
+ name: yard
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '0.8'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '0.8'
83
+ description: Get real nicknames, usables for bots
84
+ email: fermuch@gmail.com
85
+ executables: []
86
+ extensions: []
87
+ extra_rdoc_files: []
88
+ files:
89
+ - .document
90
+ - .gitignore
91
+ - .rspec
92
+ - .travis.yml
93
+ - .yardopts
94
+ - ChangeLog.md
95
+ - Gemfile
96
+ - LICENSE.txt
97
+ - README.md
98
+ - Rakefile
99
+ - lib/realnick.rb
100
+ - lib/realnick/utils.rb
101
+ - lib/realnick/version.rb
102
+ - realnick.gemspec
103
+ - spec/realnick_spec.rb
104
+ - spec/spec_helper.rb
105
+ homepage: https://github.com/fermuch/realnick#readme
106
+ licenses:
107
+ - MIT
108
+ metadata: {}
109
+ post_install_message:
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ! '>='
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ requirements: []
124
+ rubyforge_project:
125
+ rubygems_version: 2.0.7
126
+ signing_key:
127
+ specification_version: 4
128
+ summary: Get real nicknames, usables for bots
129
+ test_files:
130
+ - spec/realnick_spec.rb
131
+ - spec/spec_helper.rb
132
+ has_rdoc: