acnh_villager 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e71b476143c30137d828c99001b236cbfdaa019e652c9726d35ce2eb9b9e23e8
4
+ data.tar.gz: 8bf451bd380a69311527ca1005a17a32a8078c5681ca9267b324b9047d20aae6
5
+ SHA512:
6
+ metadata.gz: c4b7c5c24855da0d0c779ba8019807b9c7581fba70421401d740d320c6c6b622622cdd2a7f1ebbef9cee2169113ecb5b2bcd1b4b806000945141509aa0448238
7
+ data.tar.gz: 6a13ecf968051f4e00ff76ca1aac2ae509d31a87fbfa559e3227668a7f9dc555e39d3458fd0e135955e4f601d9d326676f9a10934b183de2c8dec9e609e3d85d
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.6.1
6
+ before_install: gem install bundler -v 2.1.4
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in acnh_villager.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
@@ -0,0 +1,65 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ acnh_villager (0.1.0)
5
+ bundler (~> 2.1.4)
6
+ colorize (~> 0.8.1)
7
+ json (~> 2.3.1)
8
+ rest-client (~> 2.1.0)
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ coderay (1.1.3)
14
+ colorize (0.8.1)
15
+ diff-lcs (1.4.4)
16
+ domain_name (0.5.20190701)
17
+ unf (>= 0.0.5, < 1.0.0)
18
+ http-accept (1.7.0)
19
+ http-cookie (1.0.3)
20
+ domain_name (~> 0.5)
21
+ json (2.3.1)
22
+ method_source (0.8.2)
23
+ mime-types (3.3.1)
24
+ mime-types-data (~> 3.2015)
25
+ mime-types-data (3.2020.0512)
26
+ netrc (0.11.0)
27
+ pry (0.10.4)
28
+ coderay (~> 1.1.0)
29
+ method_source (~> 0.8.1)
30
+ slop (~> 3.4)
31
+ rake (12.3.3)
32
+ rest-client (2.1.0)
33
+ http-accept (>= 1.7.0, < 2.0)
34
+ http-cookie (>= 1.0.2, < 2.0)
35
+ mime-types (>= 1.16, < 4.0)
36
+ netrc (~> 0.8)
37
+ rspec (3.9.0)
38
+ rspec-core (~> 3.9.0)
39
+ rspec-expectations (~> 3.9.0)
40
+ rspec-mocks (~> 3.9.0)
41
+ rspec-core (3.9.2)
42
+ rspec-support (~> 3.9.3)
43
+ rspec-expectations (3.9.2)
44
+ diff-lcs (>= 1.2.0, < 2.0)
45
+ rspec-support (~> 3.9.0)
46
+ rspec-mocks (3.9.1)
47
+ diff-lcs (>= 1.2.0, < 2.0)
48
+ rspec-support (~> 3.9.0)
49
+ rspec-support (3.9.3)
50
+ slop (3.6.0)
51
+ unf (0.1.4)
52
+ unf_ext
53
+ unf_ext (0.0.7.7)
54
+
55
+ PLATFORMS
56
+ ruby
57
+
58
+ DEPENDENCIES
59
+ acnh_villager!
60
+ pry (~> 0.10.3)
61
+ rake (~> 12.0)
62
+ rspec (~> 3.9.0)
63
+
64
+ BUNDLED WITH
65
+ 2.1.4
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 ellenupark
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,38 @@
1
+ # AcnhVillager
2
+
3
+ View detailed information on villagers from Animal Crossing New Horizons.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'acnh_villager'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install acnh_villager
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Development
26
+
27
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
28
+
29
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
30
+
31
+ ## Contributing
32
+
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ellenupark/acnh_villager.
34
+
35
+
36
+ ## License
37
+
38
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,37 @@
1
+ require_relative 'lib/acnh_villager/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "acnh_villager"
5
+ spec.version = AcnhVillager::VERSION
6
+ spec.authors = ["ellenupark"]
7
+ spec.email = ["ellenupark@gmail.com"]
8
+
9
+ spec.summary = %q{Animal Crossing New Horizons villager info generator}
10
+ spec.description = %q{Generates info about Animal Crossing New Horizons villagers.}
11
+ spec.homepage = "https://github.com/ellenupark/acnh_villager"
12
+ spec.license = "MIT"
13
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
14
+
15
+ # spec.metadata["allowed_push_host"] = "https://github.com/ellenupark/acnh_villager"
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = "https://github.com/ellenupark/acnh_villager"
19
+ spec.metadata["changelog_uri"] = "https://github.com/ellenupark/acnh_villager"
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
24
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ end
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_dependency "rest-client", "~> 2.1.0"
31
+ spec.add_dependency "json", "~> 2.3.1"
32
+ spec.add_dependency "colorize", "~> 0.8.1"
33
+ spec.add_dependency "bundler", "~> 2.1.4"
34
+
35
+ spec.add_development_dependency "rspec", "~> 3.9.0"
36
+ spec.add_development_dependency "pry", "~> 0.10.3"
37
+ end
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../lib/acnh_villager'
3
+
4
+ AcnhVillager::CLI.new.call
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "acnh_villager"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,11 @@
1
+ #Environment file
2
+
3
+ require 'rest-client'
4
+ require 'json'
5
+ require 'pry'
6
+ require 'colorize'
7
+ require 'bundler'
8
+ require_relative "acnh_villager/version"
9
+ require_relative './acnh_villager/cli'
10
+ require_relative './acnh_villager/api'
11
+ require_relative './acnh_villager/villager'
@@ -0,0 +1,25 @@
1
+ class AcnhVillager::API
2
+
3
+ def self.scrape_villagers
4
+ resp = RestClient.get('http://acnhapi.com/v1/villagers/')
5
+ villager_hash = JSON.parse(resp.body, symbolize_names:true)
6
+ villager_hash.each do | k, v |
7
+ AcnhVillager::Villager.new(villager_hash[k])
8
+ end
9
+ end
10
+
11
+ def self.scrape_villager_details(villager)
12
+ resp = RestClient.get(villager.url)
13
+ villager_hash = JSON.parse(resp.body, symbolize_names:true)
14
+ villager.jp_name = villager_hash[:name][:"name-JPja"]
15
+ villager.personality = villager_hash[:personality]
16
+ villager.birthday = villager_hash[:'birthday-string']
17
+ villager.species = villager_hash[:species]
18
+ villager.gender = villager_hash[:gender]
19
+ villager.hobby = villager_hash[:hobby]
20
+ villager.catch_phrase = villager_hash[:"catch-phrase"]
21
+ villager.image_url = villager_hash[:image_uri]
22
+ villager.saying = villager_hash[:saying]
23
+ end
24
+
25
+ end
@@ -0,0 +1,191 @@
1
+ class AcnhVillager::CLI
2
+ @@list = []
3
+ @@search_list = []
4
+
5
+ def initialize
6
+ AcnhVillager::API.scrape_villagers
7
+ until @@list.length == 10
8
+ random_villager = AcnhVillager::Villager.all[rand(1..AcnhVillager::Villager.all.count - 1)]
9
+ @@list << random_villager if !@@list.include?(random_villager)
10
+ end
11
+ end
12
+
13
+ def call
14
+ puts " ------------------------------------------------".colorize(:magenta)
15
+ puts " | |".colorize(:magenta)
16
+ puts " | Animal Crossing |".colorize(:magenta)
17
+ puts " | New Horizons |".colorize(:magenta)
18
+ puts " | Villager Directory |".colorize(:magenta)
19
+ puts " | |".colorize(:magenta)
20
+ puts " ------------------------------------------------".colorize(:magenta)
21
+ sleep(1)
22
+ puts ""
23
+ puts "Welcome to the Animal Crossing New Horizons Villager Directory!"
24
+ sleep(1)
25
+ list_villagers
26
+ menu
27
+ end
28
+
29
+ def line
30
+ puts "----------------------------------------------------------------"
31
+ end
32
+
33
+ def self.clear_search
34
+ @@search_list.clear
35
+ end
36
+
37
+ def list_villagers
38
+ puts ""
39
+ puts "Listing Today's Featured Villagers..."
40
+ sleep (1)
41
+ puts ""
42
+ @@list.each.with_index(1) do | villager, i |
43
+ puts "#{i}. #{villager.name}"
44
+ end
45
+ end
46
+
47
+ def search_villagers
48
+ puts "Please type the first letter of your desired villager's name."
49
+ line
50
+ input = gets.strip.downcase
51
+ line
52
+ sleep(1)
53
+
54
+ if input == 'x'
55
+ puts "Could not locate villager with name that begins with 'X'."
56
+ search_villagers
57
+ elsif input[/[a-z]\z/] == input
58
+ select_villager(input)
59
+ elsif input == 'exit'
60
+ goodbye
61
+ else
62
+ puts "Invalid input."
63
+ search_villagers
64
+ end
65
+ end
66
+
67
+ def select_villager(letter)
68
+ puts ""
69
+ search_by_letter = AcnhVillager::Villager.all.select { | villager | villager.name[0].downcase == letter }.sort_by{ | villager | villager.name }
70
+ search_by_letter.each.with_index(1) do | villager, i |
71
+ puts "#{i}. #{villager.name}"
72
+ @@search_list << villager
73
+ end
74
+ puts ""
75
+ puts "Select an above number to view villager details."
76
+ search_again(letter)
77
+ end
78
+
79
+ def search_again(letter=nil)
80
+ puts "Type 'back' to search again or type 'menu' to return to main menu."
81
+ line
82
+ selection = gets.strip.downcase
83
+ line
84
+ sleep(1)
85
+ if selection.to_i.between?(1, @@search_list.count)
86
+ villager = @@search_list.find { | villager | villager.name == @@search_list[selection.to_i - 1].name }
87
+ display_villager_details(villager)
88
+ AcnhVillager::CLI.clear_search
89
+ sleep(1)
90
+ search_again
91
+ elsif selection == 'menu'
92
+ AcnhVillager::CLI.clear_search
93
+ sleep(1)
94
+ list_villagers
95
+ menu
96
+ elsif selection == 'back'
97
+ AcnhVillager::CLI.clear_search
98
+ search_villagers
99
+ elsif selection == 'exit'
100
+ goodbye
101
+ else
102
+ puts "Invalid input."
103
+ if letter
104
+ line
105
+ sleep(1)
106
+ select_villager(letter)
107
+ else
108
+ search_again
109
+ end
110
+ end
111
+ end
112
+
113
+ def menu
114
+ puts ""
115
+ puts "Select an above number to view villager details."
116
+ puts "Type 'search' to look up a specific villager or type 'exit' to quit."
117
+ line
118
+ input = gets.strip.downcase
119
+ line
120
+ sleep(1)
121
+ if input.to_i.between?(1, 10)
122
+ villager = AcnhVillager::Villager.all.find { | villager | villager.name == @@list[input.to_i - 1].name }
123
+ display_villager_details(villager)
124
+ sleep(1)
125
+ restart
126
+ elsif input == 'search'
127
+ search_villagers
128
+ line
129
+ search_villagers
130
+ elsif input == 'exit'
131
+ goodbye
132
+ else
133
+ puts "Invalid input."
134
+ line
135
+ sleep(1)
136
+ list_villagers
137
+ menu
138
+ end
139
+ end
140
+
141
+ def display_villager_details(villager)
142
+ AcnhVillager::API.scrape_villager_details(villager)
143
+ puts ""
144
+ puts "Villager Information: ".colorize(:magenta) + "#{villager.name}:"
145
+ puts ""
146
+ puts "Japanese Name: ".colorize(:magenta) + "#{villager.jp_name}"
147
+ puts "Personality: ".colorize(:magenta) + "#{villager.personality}"
148
+ puts "Birthday: ".colorize(:magenta) + "#{villager.birthday}"
149
+ puts "Species: ".colorize(:magenta) + "#{villager.species}"
150
+ puts "Gender: ".colorize(:magenta) + "#{villager.gender}"
151
+ puts "Hobby: ".colorize(:magenta) + "#{villager.hobby}"
152
+ puts "Catch Phrase: ".colorize(:magenta) + "#{villager.catch_phrase}"
153
+ puts "Favorite Saying: ".colorize(:magenta) + "#{villager.saying}"
154
+ puts "Profile Picture: ".colorize(:magenta) + "#{villager.image_url}"
155
+ puts ""
156
+ line
157
+ end
158
+
159
+ def restart
160
+ puts "Type 'menu' to return to main menu or type 'exit' to quit."
161
+ line
162
+ input = gets.strip.downcase
163
+ line
164
+ sleep(1)
165
+ case input
166
+ when "menu"
167
+ list_villagers
168
+ menu
169
+ when "exit"
170
+ goodbye
171
+ else
172
+ puts "Invalid input."
173
+ restart
174
+ end
175
+ end
176
+
177
+ def goodbye
178
+ puts ""
179
+ puts " _ _ _ ".colorize(:magenta)
180
+ puts "__(.)< __(.)> __(.)=".colorize(:magenta)
181
+ puts "\\___) \\___) \\___)".colorize(:magenta)
182
+ puts ""
183
+ puts "Thanks for visiting!".colorize(:cyan)
184
+ puts " _ _ _".colorize(:magenta)
185
+ puts ">(.)__ <(.)__ =(.)__".colorize(:magenta)
186
+ puts " (___/ (___/ (___/".colorize(:magenta)
187
+ puts ""
188
+ line
189
+ exit
190
+ end
191
+ end
@@ -0,0 +1,3 @@
1
+ module AcnhVillager
2
+ VERSION = "0.1.1"
3
+ end
@@ -0,0 +1,15 @@
1
+ class AcnhVillager::Villager
2
+ @@all = []
3
+
4
+ attr_accessor :url, :name, :jp_name, :personality, :birthday, :species, :gender, :hobby, :catch_phrase, :image_url, :saying
5
+
6
+ def initialize(villager)
7
+ self.name = villager[:name][:'name-USen']
8
+ self.url = "http://acnhapi.com/v1/villagers/#{villager[:id].to_s}"
9
+ @@all << self
10
+ end
11
+
12
+ def self.all
13
+ @@all
14
+ end
15
+ end
metadata ADDED
@@ -0,0 +1,147 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: acnh_villager
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - ellenupark
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-09-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rest-client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 2.1.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 2.1.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 2.3.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 2.3.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: colorize
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.8.1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.8.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 2.1.4
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 2.1.4
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 3.9.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 3.9.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.10.3
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.10.3
97
+ description: Generates info about Animal Crossing New Horizons villagers.
98
+ email:
99
+ - ellenupark@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".rspec"
106
+ - ".travis.yml"
107
+ - Gemfile
108
+ - Gemfile.lock
109
+ - LICENSE.txt
110
+ - README.md
111
+ - Rakefile
112
+ - acnh_villager.gemspec
113
+ - bin/acnh_villager
114
+ - bin/console
115
+ - bin/setup
116
+ - lib/acnh_villager.rb
117
+ - lib/acnh_villager/api.rb
118
+ - lib/acnh_villager/cli.rb
119
+ - lib/acnh_villager/version.rb
120
+ - lib/acnh_villager/villager.rb
121
+ homepage: https://github.com/ellenupark/acnh_villager
122
+ licenses:
123
+ - MIT
124
+ metadata:
125
+ homepage_uri: https://github.com/ellenupark/acnh_villager
126
+ source_code_uri: https://github.com/ellenupark/acnh_villager
127
+ changelog_uri: https://github.com/ellenupark/acnh_villager
128
+ post_install_message:
129
+ rdoc_options: []
130
+ require_paths:
131
+ - lib
132
+ required_ruby_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: 2.3.0
137
+ required_rubygems_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ requirements: []
143
+ rubygems_version: 3.1.4
144
+ signing_key:
145
+ specification_version: 4
146
+ summary: Animal Crossing New Horizons villager info generator
147
+ test_files: []