Skip to content

Commit

Permalink
Merge pull request #10 from ondreian/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
ondreian committed Oct 6, 2016
2 parents 7af8dfc + de5fba3 commit 970b856
Show file tree
Hide file tree
Showing 13 changed files with 310 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,3 +1,4 @@
*.lock
*.log
*.gem
*.sublime*
2 changes: 2 additions & 0 deletions .rspec
@@ -0,0 +1,2 @@
--color
--require spec_helper
3 changes: 3 additions & 0 deletions .travis.yml
@@ -0,0 +1,3 @@
language: ruby
rvm:
- 2.3.1
12 changes: 12 additions & 0 deletions Gemfile
@@ -0,0 +1,12 @@
source "https://rubygems.org"

group :development do
gem 'rspec'
gem 'guard'
gem 'guard-rspec'
gem 'pry'
end

group :test do
gem 'rake'
end
70 changes: 70 additions & 0 deletions Guardfile
@@ -0,0 +1,70 @@
# A sample Guardfile
# More info at https://github.com/guard/guard#readme

## Uncomment and set this to only include directories you want to watch
# directories %w(app lib config test spec features) \
# .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}

## Note: if you are using the `directories` clause above and you are not
## watching the project directory ('.'), then you will want to move
## the Guardfile to a watched dir and symlink it back, e.g.
#
# $ mkdir config
# $ mv Guardfile config/
# $ ln -s config/Guardfile .
#
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"

# Note: The cmd option is now required due to the increasing number of ways
# rspec may be run, below are examples of the most common uses.
# * bundler: 'bundle exec rspec'
# * bundler binstubs: 'bin/rspec'
# * spring: 'bin/rspec' (This will use spring if running and you have
# installed the spring binstubs per the docs)
# * zeus: 'zeus rspec' (requires the server to be started separately)
# * 'just' rspec: 'rspec'

guard :rspec, cmd: "bundle exec rspec" do
require "guard/rspec/dsl"
dsl = Guard::RSpec::Dsl.new(self)

# Feel free to open issues for suggestions and improvements

# RSpec files
rspec = dsl.rspec
watch(rspec.spec_helper) { rspec.spec_dir }
watch(rspec.spec_support) { rspec.spec_dir }
watch(rspec.spec_files)

# Ruby files
ruby = dsl.ruby
dsl.watch_spec_files_for(ruby.lib_files)

# Rails files
rails = dsl.rails(view_extensions: %w(erb haml slim))
dsl.watch_spec_files_for(rails.app_files)
dsl.watch_spec_files_for(rails.views)

watch(rails.controllers) do |m|
[
rspec.spec.call("routing/#{m[1]}_routing"),
rspec.spec.call("controllers/#{m[1]}_controller"),
rspec.spec.call("acceptance/#{m[1]}")
]
end

# Rails config changes
watch(rails.spec_helper) { rspec.spec_dir }
watch(rails.routes) { "#{rspec.spec_dir}/routing" }
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }

# Capybara features specs
watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }

# Turnip features and steps
watch(%r{^spec/acceptance/(.+)\.feature$})
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
end
end
6 changes: 4 additions & 2 deletions README.md
@@ -1,8 +1,8 @@
## Olib
## Olib [![Build Status](https://travis-ci.org/ondreian/Olib.svg?branch=master)](https://travis-ci.org/ondreian/Olib)

`gem install Olib`

This offers a lot of syntatic sugar for scripting in GS
This offers a lot of syntatic sugar for scripting in GS.

examples:

Expand All @@ -18,4 +18,6 @@ Group.members.each { |char|
}
```

[WIP documentation](http://www.rubydoc.info/github/ondreian/Olib/Olib/)

Pull requests and the like as welcome.
7 changes: 7 additions & 0 deletions Rakefile
@@ -0,0 +1,7 @@
require 'rspec/core/rake_task'

RSpec::Core::RakeTask.new do |task|
task.rspec_opts = ['--color', '--format', 'doc']
end

task :default => :spec
1 change: 0 additions & 1 deletion compile.bat

This file was deleted.

27 changes: 18 additions & 9 deletions lib/Olib/bounty.rb
@@ -1,32 +1,37 @@
module Olib
class Bounty
@@procedures = {}

@@re = {}
@@re[:herb] = /requires (?:a|an|some) (?<herb>[a-zA-Z '-]+) found (?:in|on|around) (?<area>[a-zA-Z '-]+). These samples must be in pristine condition. You have been tasked to retrieve (?<number>[\d]+)/
@@re[:escort] = /Go to the (.*?) and WAIT for (?:him|her|them) to meet you there. You must guarantee (?:his|her|their) safety to (?<destiniation>[a-zA-Z '-]+) as soon as/
@@re[:gem] = /has received orders from multiple customers requesting (?:a|an|some) (?<gem>[a-zA-Z '-]+). You have been tasked to retrieve (?<number>[0-9]+)/
@@re[:heirloom] = /You have been tasked to recover ([a-zA-Z '-]+) that an unfortunate citizen lost after being attacked by (a|an|some) (?<creature>[a-zA-Z '-]+) (in|on|around|near|by) (?<area>[a-zA-Z '-]+)./
@@re[:heirloom_found] = /^You have located the heirloom and should bring it back to/
@@re[:turn_in] = /You have succeeded in your task and can return to the Adventurer's Guild to receive your reward/
@@re[:guard_turn_in] = /^You succeeded in your task and should report back to/
@@re[:guard_bounty] = /Go report to ([a-zA-Z ]+) to find out more/
@@re[:succeeded] = /^You have succeeded in your task and can return to the Adventurer's/
@@re[:report_to_guard] = /^You succeeded in your task and should report back to/
@@re[:cull] = /^You have been tasked to suppress (?<creature>^((?!bandit).)*$) activity (?:in|on) (?:the )? (?<area>.*?)(?: near| between| under|\.) ([a-zA-Z' ]+). You need to kill (?<number>[0-9]+)/
@@re[:bandits] = /^You have been tasked to suppress bandit activity (?:in |on )(?:the )(?<area>.*?)(?: near| between| under) ([a-zA-Z' ]+). You need to kill (?<number>[0-9]+)/
@@re[:dangerous] = /You have been tasked to hunt down and kill a particularly dangerous (?<creature>.*) that has established a territory (?:in|on) (?:the )?(?<area>.*?)(?: near| between| under|\.)/
@@re[:get_skin_bounty] = /The local furrier/
@@re[:get_rescue] = /It appears that a local resident urgently needs our help in some matter/
@@re[:get_bandits] = /It appears they have a bandit problem they'd like you to solve./
@@re[:get_heirloom] = /It appears they need your help in tracking down some kind of lost heirloom/
@@re[:get_herb_bounty] = /local herbalist|local healer|local alchemist/
@@re[:get_gem_bounty] = /The local gem dealer, (?<npc>[a-zA-Z ]+), has an order to fill and wants our help/
@@re[:creature_problem] = /It appears they have a creature problem they\'d like you to solve/
@@re[:rescue] = /A local divinist has had visions of the child fleeing from (?:a|an) (?<creature>.*) (?:in|on) (?:the )?(?<area>.*?)(?: near| between| under|\.)/
@@re[:failed_bounty] = /You have failed in your task/
@@re[:no_bounty] = /You are not currently assigned a task/
@@re[:none] = /You are not currently assigned a task/

# convenience list to get all types of bounties
def Bounty.types
@@re.keys
end

##
## @brief provides an accessor to the raw regular expression dictionary for Bounty logic
##
## @return Bounty Regex
##
def Bounty.regex
@@re
end
Expand Down Expand Up @@ -63,16 +68,20 @@ def Bounty.type
Bounty.current[:type]
end

def Bounty.task
Bounty.current
end

def Bounty.current
info = nil
bounty_str = checkbounty
bounty_str = checkbounty.strip
Bounty.regex.each do |type, exp|
if data = exp.match(bounty_str) then
info = Hash[ data.names.map(&:to_sym).zip( data.captures ) ]
info = data.names.length ? Hash[ data.names.map(&:to_sym).zip( data.captures ) ] : {}
info[:type] = type
end
end
return info
return info || {}
end

def Bounty.ask_for_bounty
Expand Down
File renamed without changes.
29 changes: 29 additions & 0 deletions scripts/release
@@ -0,0 +1,29 @@
#!/bin/bash

#sudo apt-get install jq

function parseSemver() {
local RE='[^0-9]*\([0-9]*\)[.]\([0-9]*\)[.]\([0-9]*\)\([0-9A-Za-z-]*\)'
#MAJOR
eval $2=`echo $1 | sed -e "s#$RE#\1#"`
#MINOR
eval $3=`echo $1 | sed -e "s#$RE#\2#"`
#MINOR
eval $4=`echo $1 | sed -e "s#$RE#\3#"`
#SPECIAL
eval $5=`echo $1 | sed -e "s#$RE#\4#"`
}

PREVIOUS_VERION=$(curl -s https://rubygems.org/api/v1/versions/$GEM/latest.json | jq -r ".version")

MAJOR=0
MINOR=0
PATCH=0
SPECIAL=0

parseSemver $PREVIOUS_VERION MAJOR MINOR PATCH SPECIAL

echo $MAJOR
echo $MINOR
echo $PATCH
echo $SPECIAL
61 changes: 61 additions & 0 deletions spec/bounty_spec.rb
@@ -0,0 +1,61 @@
load "lib/Olib/bounty.rb"

$bounty = nil

def checkbounty
$bounty
end

RSpec.describe Bounty do
it "handles no task" do
$bounty = "You are not currently assigned a task."
expect(Bounty.type).to be :none
end

it "handles success => guild" do
$bounty = "You have succeeded in your task and can return to the Adventurer's Guild"
expect(Bounty.type).to be :succeeded
end

it "handles success => guard" do
$bounty = "You succeeded in your task and should report back to"
expect(Bounty.type).to be :report_to_guard
end

context "needs to talk to NPC" do
it "can tell we were assigned a cull task" do
$bounty ="It appears they have a creature problem they'd like you to solve"
end

it "can tell we were assigned an heirloom task" do
$bounty ="It appears they need your help in tracking down some kind of lost heirloom"
expect(Bounty.type).to be :get_heirloom
end

it "can tell we were assigned a skins task" do
$bounty ="The local furrier Furrier has an order to fill and wants our help"
expect(Bounty.type).to be :get_skin_bounty
end

it "can tell we were assigned a gem task" do
$bounty ="The local gem dealer, GemTrader, has an order to fill and wants our help"
expect(Bounty.type).to be :get_gem_bounty
end


it "can tell we were assigned a herb task" do
$bounty ="Hmm, I've got a task here from the town of Ta'Illistim. The local herbalist's assistant, Jhiseth, has asked for our aid. Head over there and see what you can do. Be sure to ASK about BOUNTIES."
expect(Bounty.type).to be :get_herb_bounty
end

it "can tell we were assigned a rescue task" do
$bounty ="It appears that a local resident urgently needs our help in some matter"
expect(Bounty.type).to be :get_rescue
end

it "can tell we were assigned a bandit task" do
$bounty ="The taskmaster told you: \"Hmm, I've got a task here from the town of Ta'Illistim. It appears they have a bandit problem they'd like you to solve. Go report to one of the guardsmen just inside the Ta'Illistim City Gate to find out more. Be sure to ASK about BOUNTIES.\""
expect(Bounty.type).to be :get_bandits
end
end
end
103 changes: 103 additions & 0 deletions spec/spec_helper.rb
@@ -0,0 +1,103 @@
# This file was generated by the `rspec --init` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# The generated `.rspec` file contains `--require spec_helper` which will cause
# this file to always be loaded, without a need to explicitly require it in any
# files.
#
# Given that it is always loaded, you are encouraged to keep this file as
# light-weight as possible. Requiring heavyweight dependencies from this file
# will add to the boot time of your test suite on EVERY test run, even for an
# individual file that may not need all of that loaded. Instead, consider making
# a separate helper file that requires the additional dependencies and performs
# the additional setup, and require it from the spec files that actually need
# it.
#
# The `.rspec` file also contains a few flags that are not defaults but that
# users commonly want.
#
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
RSpec.configure do |config|
# rspec-expectations config goes here. You can use an alternate
# assertion/expectation library such as wrong or the stdlib/minitest
# assertions if you prefer.
config.expect_with :rspec do |expectations|
# This option will default to `true` in RSpec 4. It makes the `description`
# and `failure_message` of custom matchers include text for helper methods
# defined using `chain`, e.g.:
# be_bigger_than(2).and_smaller_than(4).description
# # => "be bigger than 2 and smaller than 4"
# ...rather than:
# # => "be bigger than 2"
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
end

# rspec-mocks config goes here. You can use an alternate test double
# library (such as bogus or mocha) by changing the `mock_with` option here.
config.mock_with :rspec do |mocks|
# Prevents you from mocking or stubbing a method that does not exist on
# a real object. This is generally recommended, and will default to
# `true` in RSpec 4.
mocks.verify_partial_doubles = true
end

# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
# have no way to turn it off -- the option exists only for backwards
# compatibility in RSpec 3). It causes shared context metadata to be
# inherited by the metadata hash of host groups and examples, rather than
# triggering implicit auto-inclusion in groups with matching metadata.
config.shared_context_metadata_behavior = :apply_to_host_groups

# The settings below are suggested to provide a good initial experience
# with RSpec, but feel free to customize to your heart's content.
=begin
# This allows you to limit a spec run to individual examples or groups
# you care about by tagging them with `:focus` metadata. When nothing
# is tagged with `:focus`, all examples get run. RSpec also provides
# aliases for `it`, `describe`, and `context` that include `:focus`
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
config.filter_run_when_matching :focus
# Allows RSpec to persist some state between runs in order to support
# the `--only-failures` and `--next-failure` CLI options. We recommend
# you configure your source control system to ignore this file.
config.example_status_persistence_file_path = "spec/examples.txt"
# Limits the available syntax to the non-monkey patched syntax that is
# recommended. For more details, see:
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
config.disable_monkey_patching!
# This setting enables warnings. It's recommended, but in some cases may
# be too noisy due to issues in dependencies.
config.warnings = true
# Many RSpec users commonly either run the entire suite or an individual
# file, and it's useful to allow more verbose output when running an
# individual spec file.
if config.files_to_run.one?
# Use the documentation formatter for detailed output,
# unless a formatter has already been configured
# (e.g. via a command-line flag).
config.default_formatter = 'doc'
end
# Print the 10 slowest examples and example groups at the
# end of the spec run, to help surface which specs are running
# particularly slow.
config.profile_examples = 10
# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing
# the seed, which is printed after each run.
# --seed 1234
config.order = :random
# Seed global randomization in this process using the `--seed` CLI option.
# Setting this allows you to use `--seed` to deterministically reproduce
# test failures related to randomization by passing the same `--seed` value
# as the one that triggered the failure.
Kernel.srand config.seed
=end
end

0 comments on commit 970b856

Please sign in to comment.