say-anything 1.2.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9aeb8b60f0f5ec56b2e9bc0d81cca7840165893e
4
- data.tar.gz: 97a390757780d2c4a566462504253bceeeb25618
3
+ metadata.gz: 8819bddd67d5bc8b3616b4e7e6e27e7fead01977
4
+ data.tar.gz: be4ea408451c282abbaea2925223036c7d5851a2
5
5
  SHA512:
6
- metadata.gz: 27537247e5e2c5e4428af6c8476d7b6ca3e54da39502aeb2f33e94c1bfae7bac2f0b0c39ca3d6cca2f24e1e82d7d1dfeb29ce080455ba98d0d609e7011533682
7
- data.tar.gz: 267f84cbd4da19f10a76a050b00223ed9cca114f103d08eaf1f714f8c846775fda9502908910d8b566b9649381fd1c2a392b24a35b1effc118a4f78c1f6ccb6f
6
+ metadata.gz: cdd7464fc6819a48ff3929f23dccede404fd0ea887e35a8bc68c780172f82d48951eca993ec011d3353aca899d1a217432f94b9a5730a8586d6707d48cc65dd4
7
+ data.tar.gz: 7425d040f06afdbc3ad9c7af071fe316d2254b1d9e7267e1b73ffc663c3c84dd7bcef926d3330411f83c0c5ad95760d88b99a80697273394154d53ea2ad7f38d
data/.travis.yml CHANGED
@@ -1,4 +1,8 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 2.1.5
4
+
4
5
  script: ruby spec/say-anything_spec.rb
6
+
7
+ notifications:
8
+ email: false
data/README.md CHANGED
@@ -1,19 +1,37 @@
1
1
  Say-Anything [![Build Status](https://travis-ci.org/rozaxe/say-anything.svg?branch=master)](https://travis-ci.org/rozaxe/say-anything)
2
2
  ============
3
3
 
4
- > Get random words.
4
+ > The impossible Say-Anything-Challenge
5
5
 
6
- The list contains 109 582 english words.
6
+ Computer knows 109 582 english words. Do you think you can beat it ? :stuck_out_tongue:
7
+
8
+ ***
9
+
10
+ The gem can also be used for development (of course :information_desk_person:).
7
11
 
8
12
 
9
13
  Install
10
14
  -------
11
15
 
12
- ```bash
16
+ ```
13
17
  $ gem install say-anything
14
18
  ```
15
19
 
16
20
 
21
+ Play
22
+ ----
23
+
24
+ First of all, rule is really simple, just say anything !
25
+
26
+ If you or your opponent is missing words, it's game over !
27
+
28
+ Rule seems still weird ? Go watch [this](https://www.youtube.com/watch?v=nPansREhHvA) :kissing_smiling_eyes:
29
+
30
+ ```
31
+ $ say-anything --play
32
+ ```
33
+
34
+
17
35
  Usage
18
36
  -----
19
37
 
@@ -48,7 +66,7 @@ Return : `Array`
48
66
  Times random words.
49
67
 
50
68
 
51
- ### .words
69
+ ### .all
52
70
 
53
71
  Return : `Array`
54
72
 
@@ -58,10 +76,13 @@ All words.
58
76
  CLI
59
77
  ---
60
78
 
61
- ```bash
79
+ ```
62
80
  $ say-anything --help
63
81
  Usage: say-anything [OPTION]
64
82
 
83
+ -p, --play
84
+ challenge computer at say-anything
85
+
65
86
  -t, --times [NUMBER]
66
87
  return times random words
67
88
 
data/bin/say-anything CHANGED
@@ -2,11 +2,15 @@
2
2
 
3
3
  require 'say-anything'
4
4
 
5
+ # Display string helper
5
6
  def helper
6
7
 
7
8
  puts %q(
8
9
  Usage: say-anything [OPTION]
9
10
 
11
+ -p, --play
12
+ challenge computer at say-anything
13
+
10
14
  -t, --times [NUMBER]
11
15
  return times random words
12
16
 
@@ -19,12 +23,78 @@ Usage: say-anything [OPTION]
19
23
 
20
24
  end
21
25
 
26
+ # Start a game against the computer
27
+ def challenge
28
+
29
+ remaining = SayAnything.all
30
+ remaining.shuffle!
31
+ found = []
32
+
33
+ puts "Good luck ! ^C to quit"
34
+
35
+ loop do
36
+ puts "say-anything !"
37
+ print " "
38
+
39
+ begin
40
+ word = $stdin.gets
41
+
42
+ rescue Exception => e
43
+ puts "\nAlready ? I still have #{remaining.size} words in stock !"
44
+ break
45
+ end
46
+
47
+ # Clear space withing word
48
+ word.gsub! /\s/, ""
49
+
50
+ puts "\n"
51
+
52
+ # Return nil if not found
53
+ exist = remaining.delete word
54
+
55
+ if exist == nil
56
+ # Word not found !
57
+ if found.include? word
58
+ puts "Already said !"
59
+ else
60
+ puts "Sorry, doesn't exist"
61
+ end
62
+
63
+ puts "You loose =P"
64
+
65
+ # Quit game
66
+ break
67
+ end
68
+
69
+ # Computer turn
70
+ ia = remaining.pop
71
+ if ia == nil
72
+ # Play wins O.o
73
+ puts "You won ! How is that possible ?!"
74
+ break
75
+ end
76
+
77
+ # Write computer's word
78
+ sleep 0.4
79
+ puts "Computer says #{ia}"
80
+
81
+ # Can't say them anymore
82
+ found << word
83
+ found << ia
84
+
85
+ end
86
+
87
+ end
88
+
22
89
  if ARGV.size > 0
23
90
 
24
91
  # Help
25
92
  if ARGV.include? "-h" or ARGV.include? "--help"
26
93
  helper
27
94
 
95
+ elsif ARGV.include? "-p" or ARGV.include? "--play"
96
+ challenge
97
+
28
98
  # Times
29
99
  elsif ARGV.include? "-t" or ARGV.include? "--times"
30
100
  i = ARGV.index do |x| ["-t", "--times"].include?(x) end
@@ -41,7 +111,7 @@ if ARGV.size > 0
41
111
 
42
112
  # All
43
113
  elsif ARGV.include? "-a" or ARGV.include? "--all"
44
- SayAnything.words.each do |x|
114
+ SayAnything.all.each do |x|
45
115
  puts x
46
116
  end
47
117
 
data/lib/say-anything.rb CHANGED
@@ -3,7 +3,7 @@ require "yaml"
3
3
  module SayAnything
4
4
  @list = YAML.load_file File.dirname(__FILE__) + "/say-anything/words.yaml"
5
5
 
6
- def self.words
6
+ def self.all
7
7
  @list
8
8
  end
9
9
 
data/say-anything.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "say-anything"
3
- s.version = "1.2.0"
3
+ s.version = "2.0.0"
4
4
  s.summary = "Rainbow !"
5
5
  s.description = "This literally say anything."
6
6
  s.authors = ["Axel Rozo--Brézillac"]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: say-anything
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Axel Rozo--Brézillac
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-23 00:00:00.000000000 Z
11
+ date: 2015-06-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: This literally say anything.
14
14
  email: axel.rozobrezillac@gmail.com