├── .ruby-version ├── Gemfile ├── Gemfile.lock ├── LICENSE.md ├── README.md ├── Rakefile ├── bin └── setup ├── lib └── .gitkeep └── spec └── .gitkeep /.ruby-version: -------------------------------------------------------------------------------- 1 | 2.2.1 2 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | gem "rspec" 4 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | diff-lcs (1.2.5) 5 | rspec (3.2.0) 6 | rspec-core (~> 3.2.0) 7 | rspec-expectations (~> 3.2.0) 8 | rspec-mocks (~> 3.2.0) 9 | rspec-core (3.2.1) 10 | rspec-support (~> 3.2.0) 11 | rspec-expectations (3.2.0) 12 | diff-lcs (>= 1.2.0, < 2.0) 13 | rspec-support (~> 3.2.0) 14 | rspec-mocks (3.2.1) 15 | diff-lcs (>= 1.2.0, < 2.0) 16 | rspec-support (~> 3.2.0) 17 | rspec-support (3.2.2) 18 | 19 | PLATFORMS 20 | ruby 21 | 22 | DEPENDENCIES 23 | rspec 24 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright © 2015-2018 [thoughtbot, inc.](http://thoughtbot.com) 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 all 13 | 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 THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Ruby Challenges / Analyzing Shakespeare 2 | 3 | Hey there! We're [thoughtbot](https://thoughtbot.com), a design and 4 | development consultancy that brings your digital product ideas to life. 5 | We also love to share what we learn. 6 | 7 | This coding exercise comes from [Upcase](https://thoughtbot.com/upcase), 8 | the online learning platform we run. It's part of the 9 | [Ruby Challenges](https://thoughtbot.com/upcase/ruby-challenges) course and is just one small sample of all 10 | the great material available on Upcase, so be sure to visit and check out the rest. 11 | 12 | ## Exercise Intro 13 | 14 | Difficulty: **Easy, but requires isolating an external service during testing.** 15 | 16 | As a Shakespeare buff, statistics junkie, and Unix lover, Ben finds himself wanting a command-line tool for analyzing Macbeth. 17 | 18 | Write a command-line program that prints the number of lines spoken by each character in the play. 19 | 20 | ## Instructions 21 | 22 | To start, you'll want to clone and run the setup script for the repo 23 | 24 | git clone git@github.com:thoughtbot-upcase-exercises/analyzing-shakespeare.git 25 | cd analyzing-shakespeare 26 | bin/setup 27 | 28 | Sample usage/output (using made-up numbers): 29 | 30 | $ ruby macbeth_analyzer.rb 31 | 543 Macbeth 32 | 345 Banquo 33 | 220 Duncan 34 | (etc.) 35 | 36 | You can find an XML-encoded version of Macbeth here: http://www.ibiblio.org/xml/examples/shakespeare/macbeth.xml. Your program should download and parse this file at runtime. 37 | 38 | Your solution must be tested, preferably via TDD. Running your tests _should not_ download the play from the ibiblio.org server. 39 | 40 | Note: some lines are attributed to a speaker called "ALL". Your program should ignore these. 41 | 42 | ## Featured Solution 43 | 44 | Check out the [featured solution branch](https://github.com/thoughtbot-upcase-exercises/analyzing-shakespeare/compare/featured-solution#toc) to 45 | see the approach we recommend for this exercise. 46 | 47 | ## Forum Discussion 48 | 49 | If you find yourself stuck, be sure to check out the associated 50 | [Upcase Forum discussion](https://forum.upcase.com/t/ruby-challenges-analyzing-shakespeare/4604) 51 | for this exercise to see what other folks have said. 52 | 53 | ## Next Steps 54 | 55 | When you've finished the exercise, head on back to the 56 | [Ruby Challenges](https://thoughtbot.com/upcase/ruby-challenges) course to find the next exercise, 57 | or explore any of the other great content on 58 | [Upcase](https://thoughtbot.com/upcase). 59 | 60 | ## License 61 | 62 | analyzing-shakespeare is Copyright © 2015-2018 thoughtbot, inc. It is free software, 63 | and may be redistributed under the terms specified in the 64 | [LICENSE](/LICENSE.md) file. 65 | 66 | ## Credits 67 | 68 | ![thoughtbot](https://thoughtbot.com/thoughtbot-logo-for-readmes.svg) 69 | 70 | This exercise is maintained and funded by 71 | [thoughtbot, inc](http://thoughtbot.com/community). 72 | 73 | The names and logos for Upcase and thoughtbot are registered trademarks of 74 | thoughtbot, inc. 75 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env rake 2 | 3 | require 'rspec/core/rake_task' 4 | 5 | RSpec::Core::RakeTask.new(:spec) 6 | 7 | task default: :spec 8 | -------------------------------------------------------------------------------- /bin/setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # Exit if any subcommand fails 4 | set -e 5 | 6 | # Set up Ruby dependencies via Bundler 7 | gem install bundler --conservative --no-document 8 | bundle check || bundle install 9 | 10 | # Add binstubs to PATH via export PATH=".git/safe/../../bin:$PATH" in ~/.zshenv 11 | mkdir -p .git/safe 12 | -------------------------------------------------------------------------------- /lib/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thoughtbot-upcase-exercises/analyzing-shakespeare/0b1189c85239b5865e84491a6903a24cda06367f/lib/.gitkeep -------------------------------------------------------------------------------- /spec/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thoughtbot-upcase-exercises/analyzing-shakespeare/0b1189c85239b5865e84491a6903a24cda06367f/spec/.gitkeep --------------------------------------------------------------------------------