Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

converting app to a gem

  • Loading branch information...
commit aa0146a28f9344b9835639f3d2e891a4539f847e 1 parent e2476d5
@jwoertink authored
View
1  .gitignore
@@ -1 +1,2 @@
.DS_Store
+.rvmrc
View
6 Gemfile
@@ -1,3 +1,7 @@
source "http://rubygems.org"
-gem "highline"
+gem "rake"
+gem "highline"
+gem "ruby-termios", :require => "termios"
+gem "bundler", "~> 1.0.0"
+gem "jeweler", "~> 1.6.0"
View
11 Gemfile.lock
@@ -1,10 +1,21 @@
GEM
remote: http://rubygems.org/
specs:
+ git (1.2.5)
highline (1.6.2)
+ jeweler (1.6.4)
+ bundler (~> 1.0)
+ git (>= 1.2.5)
+ rake
+ rake (0.9.2)
+ ruby-termios (0.9.6)
PLATFORMS
ruby
DEPENDENCIES
+ bundler (~> 1.0.0)
highline
+ jeweler (~> 1.6.0)
+ rake
+ ruby-termios
View
42 Rakefile
@@ -0,0 +1,42 @@
+# encoding: utf-8
+
+require 'rubygems'
+require 'bundler'
+begin
+ Bundler.setup(:default)
+rescue Bundler::BundlerError => e
+ $stderr.puts e.message
+ $stderr.puts "Run `bundle install` to install missing gems"
+ exit e.status_code
+end
+require 'rake'
+
+require 'jeweler'
+Jeweler::Tasks.new do |gem|
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
+ gem.name = "dopewars"
+ gem.homepage = "http://github.com/jwoertink/dopewars"
+ gem.license = "MIT"
+ gem.summary = "Ruby port of Dopewars game"
+ gem.description = "Check out the README file for more info"
+ gem.email = "jeremywoertink@gmail.com"
+ gem.authors = ["Jeremy Woertink"]
+ # dependencies defined in Gemfile
+end
+Jeweler::RubygemsDotOrgTasks.new
+
+# require 'rspec/core'
+# require 'rspec/core/rake_task'
+# RSpec::Core::RakeTask.new(:spec) do |spec|
+# spec.pattern = FileList['spec/**/*_spec.rb']
+# end
+#
+# RSpec::Core::RakeTask.new(:rcov) do |spec|
+# spec.pattern = 'spec/**/*_spec.rb'
+# spec.rcov = true
+# end
+#
+# task :default => :spec
+#
+# require 'yard'
+# YARD::Rake::YardocTask.new
View
10 bin/dopewars
@@ -0,0 +1,10 @@
+#!/usr/bin/ruby
+# -*- coding: utf-8 -*-
+
+require 'rubygems'
+$:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
+require 'highline/import'
+require 'utilities'
+require 'application'
+
+Application.run!
View
57 dopewars.gemspec
@@ -0,0 +1,57 @@
+# Generated by jeweler
+# DO NOT EDIT THIS FILE DIRECTLY
+# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
+# -*- encoding: utf-8 -*-
+
+Gem::Specification.new do |s|
+ s.name = %q{dopewars}
+ s.version = "0.1.0"
+
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
+ s.authors = ["Jeremy Woertink"]
+ s.date = %q{2011-08-02}
+ s.description = %q{Check out the README file for more info}
+ s.email = %q{jeremywoertink@gmail.com}
+ s.extra_rdoc_files = [
+ "README.rdoc"
+ ]
+ s.files = [
+ ".rvmrc",
+ "Gemfile",
+ "Gemfile.lock",
+ "NOTES.txt",
+ "README.rdoc",
+ "VERSION",
+ "text.yml"
+ ]
+ s.homepage = %q{http://github.com/jwoertink/dopewars}
+ s.licenses = ["MIT"]
+ s.require_paths = ["lib"]
+ s.rubygems_version = %q{1.5.2}
+ s.summary = %q{Ruby port of Dopewars game}
+
+ if s.respond_to? :specification_version then
+ s.specification_version = 3
+
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
+ s.add_runtime_dependency(%q<rake>, [">= 0"])
+ s.add_runtime_dependency(%q<highline>, [">= 0"])
+ s.add_runtime_dependency(%q<ruby-termios>, [">= 0"])
+ s.add_runtime_dependency(%q<bundler>, ["~> 1.0.0"])
+ s.add_runtime_dependency(%q<jeweler>, ["~> 1.6.0"])
+ else
+ s.add_dependency(%q<rake>, [">= 0"])
+ s.add_dependency(%q<highline>, [">= 0"])
+ s.add_dependency(%q<ruby-termios>, [">= 0"])
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
+ s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
+ end
+ else
+ s.add_dependency(%q<rake>, [">= 0"])
+ s.add_dependency(%q<highline>, [">= 0"])
+ s.add_dependency(%q<ruby-termios>, [">= 0"])
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
+ s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
+ end
+end
+
View
20 dopewars.rb
@@ -1,20 +0,0 @@
-require 'rubygems'
-require 'bundler'
-Bundler.require
-require 'highline/import'
-Dir["#{File.expand_path(File.join(File.dirname(__FILE__), "*.rb"))}"].each { |file| require file unless file.eql?(File.expand_path(__FILE__)) }
-include Utilities
-
-
-echo(Utilities::GAME_TITLE, :green, 0)
-key = ask("[S]tart a new game or [Q]uit?") { |q| q.echo = true }
-
-if key.downcase.eql?('s')
- player_name = ask(game_text(:greeting))
- player_defaults = {name: player_name, wallet: 500, drugs: {weed: 5}}
- @game = Game.new(game_defaults.merge(player: Player.new(player_defaults)))
- @game.start!
-else
- echo("Goodbye!", :red, 0)
- exit
-end
View
0  agent.rb → lib/agent.rb
File renamed without changes
View
20 lib/application.rb
@@ -0,0 +1,20 @@
+module Application
+ include Utilities
+
+ # This just kicks off the application.
+ def self.run!
+ echo(Utilities::GAME_TITLE, :green, 0)
+ key = ask("[S]tart a new game or [Q]uit?") { |q| q.echo = true }
+
+ if key.downcase.eql?('s')
+ player_name = ask(game_text(:greeting))
+ player_defaults = {name: player_name, wallet: 500, drugs: {weed: 5}}
+ @game = Game.new(game_defaults.merge(player: Player.new(player_defaults)))
+ @game.start!
+ else
+ echo("Goodbye!", :red, 0)
+ exit
+ end
+ end
+
+end
View
0  bank.rb → lib/bank.rb
File renamed without changes
View
0  Drug.rb → lib/drug.rb
File renamed without changes
View
0  Game.rb → lib/game.rb
File renamed without changes
View
0  Player.rb → lib/player.rb
File renamed without changes
View
22 lib/term.rb
@@ -0,0 +1,22 @@
+
+
+# get the original settings and save a backup
+term = Termios::getattr($stdin)
+original_term = term.dup
+
+# non-canonical mode: character input
+term.c_lflag &= ~Termios::ICANON
+
+# disable echo
+term.c_lflag &= ~Termios::ECHO
+
+Termios.setattr($stdin, Termios::TCSANOW, term)
+
+
+while c = STDIN.getc
+ puts "Read: #{c.inspect}"
+end
+
+
+
+Termios.setattr($stdin, Termios::TCSANOW, origin_term)
View
0  utilities.rb → lib/utilities.rb
File renamed without changes
Please sign in to comment.
Something went wrong with that request. Please try again.