number_station 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 19f6960535277617764be78d50c2465a1477b873ebdac59c8ba9398c8d3a61fd
4
- data.tar.gz: b346b5ed340e27e5d980bbbb411853b4e114563cc361ace0e1b9c5cbcf54bd4d
3
+ metadata.gz: 307e4f7227c11f3a5f102d751834125e78313460b0687db0b66fc27767119412
4
+ data.tar.gz: fcc9d8d383ab9858bfb8b641598ccac627e8710d3486832cb96331bf9b44e6ef
5
5
  SHA512:
6
- metadata.gz: 3c04ea2c09f461d42a49bc34820191c58df0d4eea7c6c6ba4ff2f8c7672414bc1bff202435e564f2db3f902f323f95b9c020823feef4f24b418c52b7c72e8759
7
- data.tar.gz: 67f4fcf01885614927aa59dfeac41717ca135faa046fc7f6ed748fbb89cbd62c707d4b795ac86d201f76c9b25f4aa05a43aad9652b34e7485b8a7bce3188a904
6
+ metadata.gz: 3604feb7f2e4e0a40c68d934112a0ca59b418b8a1858613f5e94e0d3b33933d9548cb316f63d64b1cde68dd7abe3e59c9ed4f1bd474d37503622037d086dc40c
7
+ data.tar.gz: bee70668d29379c88b725ef7328a8a6af982b7299b888a6fbba7576f1da0f59c00451e04f0eb9e1df586bac4002274910fae7755c67290a85b650b4146d556a6
@@ -0,0 +1,35 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us improve
4
+
5
+ ---
6
+
7
+ **Describe the bug**
8
+ A clear and concise description of what the bug is.
9
+
10
+ **To Reproduce**
11
+ Steps to reproduce the behavior:
12
+ 1. Go to '...'
13
+ 2. Click on '....'
14
+ 3. Scroll down to '....'
15
+ 4. See error
16
+
17
+ **Expected behavior**
18
+ A clear and concise description of what you expected to happen.
19
+
20
+ **Screenshots**
21
+ If applicable, add screenshots to help explain your problem.
22
+
23
+ **Desktop (please complete the following information):**
24
+ - OS: [e.g. iOS]
25
+ - Browser [e.g. chrome, safari]
26
+ - Version [e.g. 22]
27
+
28
+ **Smartphone (please complete the following information):**
29
+ - Device: [e.g. iPhone6]
30
+ - OS: [e.g. iOS8.1]
31
+ - Browser [e.g. stock browser, safari]
32
+ - Version [e.g. 22]
33
+
34
+ **Additional context**
35
+ Add any other context about the problem here.
@@ -0,0 +1,7 @@
1
+ ---
2
+ name: Custom issue template
3
+ about: Describe this issue template's purpose here.
4
+
5
+ ---
6
+
7
+
@@ -0,0 +1,17 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for this project
4
+
5
+ ---
6
+
7
+ **Is your feature request related to a problem? Please describe.**
8
+ A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
9
+
10
+ **Describe the solution you'd like**
11
+ A clear and concise description of what you want to happen.
12
+
13
+ **Describe alternatives you've considered**
14
+ A clear and concise description of any alternative solutions or features you've considered.
15
+
16
+ **Additional context**
17
+ Add any other context or screenshots about the feature request here.
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ tmp/*
2
+ *.gem
3
+ Gemfile.lock
@@ -0,0 +1,6 @@
1
+ # Contributor Code of Conduct
2
+
3
+ This project adheres to No Code of Conduct. We are all adults. We accept anyone's contributions. Nothing else matters.
4
+
5
+ For more information please visit the [No Code of Conduct](https://github.com/domgetter/NCoC) homepage.
6
+
data/Gemfile CHANGED
@@ -1 +1,6 @@
1
- gem "rake"
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in number_station.gemspec
6
+ gemspec
data/README.asciidoc CHANGED
@@ -2,7 +2,8 @@
2
2
  This gem (WIP) contains a number of utilities to aid in the running of a number station.
3
3
 
4
4
  === Contributing ===
5
- X
5
+ Contributions are welcome, please fork the repo, create a branch, add your code, and make a PR
6
+ against master on this repo.
6
7
 
7
8
  === Licence ===
8
9
  number_station is distributed under the GPL 3.0 licence. For more information see the _COPYING_
data/Rakefile CHANGED
@@ -1,4 +1,24 @@
1
- require 'rubygems'
1
+ =begin
2
+ Ruby Number Station
3
+ Author: David Kirwan https://gitub.com/davidkirwan
4
+ Licence: GPL 3.0
5
+ NumberStation is a collection of utilities to aid in the running of a number station
6
+ Copyright (C) 2018 David Kirwan
7
+
8
+ This program is free software: you can redistribute it and/or modify
9
+ it under the terms of the GNU General Public License as published by
10
+ the Free Software Foundation, either version 3 of the License, or
11
+ (at your option) any later version.
12
+
13
+ This program is distributed in the hope that it will be useful,
14
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ GNU General Public License for more details.
17
+
18
+ You should have received a copy of the GNU General Public License
19
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
20
+ =end
21
+
2
22
  require 'bundler'
3
23
  require 'fileutils'
4
24
  Bundler::GemHelper.install_tasks
@@ -7,8 +27,8 @@ task :default => :menu
7
27
 
8
28
  task :menu do
9
29
  puts welcomeMsg = <<-MSG
10
- rake build # Build usefuldb-x.x.x.gem into the pkg directory
11
- rake install # Build and install usefuldb-x.x.x.gem into system gems
30
+ rake build # Build number_station-x.x.x.gem into the pkg directory
31
+ rake install # Build and install number_station-x.x.x.gem into system gems
12
32
  rake release # Create tag vx.x.x and build and push number_station-x.x.x.gem to http://rubygems.org/
13
33
  MSG
14
34
  end
@@ -16,6 +36,5 @@ end
16
36
  desc "Clean up build artifacts"
17
37
  task :clean do
18
38
  FileUtils.rm_rf("./pkg/")
19
- FileUtils.rm_rf("./tmp/")
20
39
  end
21
40
 
data/bin/number_station CHANGED
@@ -1,3 +1,25 @@
1
1
  #!/usr/bin/env ruby
2
+ =begin
3
+ Ruby Number Station
4
+ Author: David Kirwan https://gitub.com/davidkirwan
5
+ Licence: GPL 3.0
6
+ NumberStation is a collection of utilities to aid in the running of a number station
7
+ Copyright (C) 2018 David Kirwan
2
8
 
3
- puts "numberstation_launcher"
9
+ This program is free software: you can redistribute it and/or modify
10
+ it under the terms of the GNU General Public License as published by
11
+ the Free Software Foundation, either version 3 of the License, or
12
+ (at your option) any later version.
13
+
14
+ This program is distributed in the hope that it will be useful,
15
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ GNU General Public License for more details.
18
+
19
+ You should have received a copy of the GNU General Public License
20
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
21
+ =end
22
+ require "number_station"
23
+
24
+ # Start the CLI
25
+ NumberStation::CLI.start(ARGV)
data/config/conf.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "logging":{
3
+ "level":0
4
+ },
5
+ "server":{
6
+ "host":"localhost",
7
+ "port":8080
8
+ },
9
+ "resources":{
10
+ "path":"resources",
11
+ "intro":"intro.txt",
12
+ "message":"message.txt",
13
+ "outro":"outro.txt"
14
+ }
15
+ }
@@ -0,0 +1,71 @@
1
+ =begin
2
+ Ruby Number Station
3
+ Author: David Kirwan https://gitub.com/davidkirwan
4
+ Licence: GPL 3.0
5
+ NumberStation is a collection of utilities to aid in the running of a number station
6
+ Copyright (C) 2018 David Kirwan
7
+
8
+ This program is free software: you can redistribute it and/or modify
9
+ it under the terms of the GNU General Public License as published by
10
+ the Free Software Foundation, either version 3 of the License, or
11
+ (at your option) any later version.
12
+
13
+ This program is distributed in the hope that it will be useful,
14
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ GNU General Public License for more details.
17
+
18
+ You should have received a copy of the GNU General Public License
19
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
20
+ =end
21
+
22
+ module NumberStation
23
+
24
+ ALPHABET ={
25
+ '0' => "zero",
26
+ '1' => "one",
27
+ '2' => "two",
28
+ '3' => "three",
29
+ '4' => "four",
30
+ '5' => "five",
31
+ '6' => "six",
32
+ '7' => "seven",
33
+ '8' => "eight",
34
+ '9' => "nine",
35
+ 'a' => "alpha",
36
+ 'b' => "bravo",
37
+ 'c' => "charlie",
38
+ 'd' => "delta",
39
+ 'e' => "echo",
40
+ 'f' => "foxtrot",
41
+ 'g' => "gamma",
42
+ 'h' => "hotel",
43
+ 'i' => "india",
44
+ 'j' => "juliette",
45
+ 'k' => "kilo",
46
+ 'l' => "lima",
47
+ 'm' => "mike",
48
+ 'n' => "november",
49
+ 'o' => "oscar",
50
+ 'p' => "pappa",
51
+ 'q' => "quebec",
52
+ 'r' => "romeo",
53
+ 's' => "sierra",
54
+ 't' => "tango",
55
+ 'u' => "uniform",
56
+ 'v' => "victor",
57
+ 'w' => "whiskey",
58
+ 'x' => "xray",
59
+ 'y' => "yankee",
60
+ 'z' => "zulu"
61
+ }
62
+
63
+ def self.lookup(c)
64
+ begin
65
+ return NumberStation::ALPHABET[c] + ' ' || ' '
66
+ rescue Exception => e
67
+ return ' '
68
+ end
69
+ end
70
+
71
+ end
@@ -0,0 +1,134 @@
1
+ =begin
2
+ Ruby Number Station
3
+ Author: David Kirwan https://gitub.com/davidkirwan
4
+ Licence: GPL 3.0
5
+ NumberStation is a collection of utilities to aid in the running of a number station
6
+ Copyright (C) 2018 David Kirwan
7
+
8
+ This program is free software: you can redistribute it and/or modify
9
+ it under the terms of the GNU General Public License as published by
10
+ the Free Software Foundation, either version 3 of the License, or
11
+ (at your option) any later version.
12
+
13
+ This program is distributed in the hope that it will be useful,
14
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ GNU General Public License for more details.
17
+
18
+ You should have received a copy of the GNU General Public License
19
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
20
+ =end
21
+
22
+ require 'thor'
23
+ require 'fileutils'
24
+
25
+ module NumberStation
26
+ class CLI < Thor
27
+
28
+ # create_config
29
+ desc "create_config [--path PATH]", "copy the sample config to current directory."
30
+ long_desc <<-CREATE_CONFIG_LONG_DESC
31
+ `create_config` will copy the sample config from config/config.json to the current directory. If the
32
+ optional parameter `--path PATH` is passed then this file is copied to the location specified by the
33
+ PATH parameter.
34
+ CREATE_CONFIG_LONG_DESC
35
+ option :path, :type => :string
36
+ def create_config()
37
+ NumberStation::ConfigReader.read_config()
38
+ config_file_path = File.join(File.dirname(__FILE__), "../../config/conf.json")
39
+
40
+ if options[:path]
41
+ path = options[:path]
42
+ unless File.file?(File.join(path, "/conf.json"))
43
+ #write config to path
44
+ NumberStation.log.debug "Copying sample config to #{path}"
45
+ FileUtils.cp(config_file_path, path)
46
+ else
47
+ NumberStation.log.debug "File already exists at #{File.join(path, "/conf.json")}"
48
+ end
49
+ else
50
+ path = Dir.pwd
51
+ unless File.file?(File.join(path, "/conf.json"))
52
+ #write config to local directory the binary was called from
53
+ NumberStation.log.debug "Copying sample config to #{path}"
54
+ FileUtils.cp(config_file_path, path)
55
+ else
56
+ NumberStation.log.debug "File already exists at #{File.join(path, "/conf.json")}"
57
+ end
58
+ end
59
+ end
60
+
61
+
62
+ # convert_message
63
+ desc "convert_message [MESSAGE]", "Convert a message to phonetic output."
64
+ long_desc <<-CONVERT_MESSAGE_LONG_DESC
65
+ convert_message takes a parameter which should point to a text file containing a message.
66
+ Optional parameters:\n
67
+ --intro [INTRO] should be a text file containing intro message.\n
68
+ --outro [OUTRO] should be a text file containing the outro message.
69
+
70
+ Final message will be created from intro + message + outro
71
+ CONVERT_MESSAGE_LONG_DESC
72
+ option :intro, :type => :string
73
+ option :outro, :type => :string
74
+ option :mp3, :type => :string
75
+ def convert_message(message)
76
+ NumberStation::ConfigReader.read_config()
77
+
78
+ intro_path = options[:intro]
79
+ message_path = message
80
+ outro_path = options[:outro]
81
+ mp3_path = options[:mp3]
82
+ NumberStation.log.debug "intro_path: #{intro_path}" if options[:intro]
83
+ NumberStation.log.debug "message_path: #{message_path}"
84
+ NumberStation.log.debug "outro_path: #{outro_path}" if options[:outro]
85
+ NumberStation.log.debug "mp3_output: " if options[:mp3]
86
+
87
+ output = ""
88
+ output += NumberStation.read_message(intro_path) if options[:intro]
89
+ output += NumberStation.read_message(message_path)
90
+ output += NumberStation.read_message(outro_path) if options[:outro]
91
+
92
+ NumberStation.log.info "output: #{output}"
93
+
94
+ if options[:mp3]
95
+ NumberStation.log.debug "Generating mp3 output: #{mp3_path}"
96
+ NumberStation.run(output, mp3_path)
97
+ end
98
+
99
+ return output
100
+ end
101
+
102
+
103
+ # convert_message
104
+ desc "make_one_time_pad [--path PATH --num NUM --length LENGTH]", "Generate a one time pad of LENGTH containing NUM entries"
105
+ long_desc <<-MAKE_ONE_TIME_PAD_LONG_DESC
106
+ Generate a one time pad of LENGTH containing NUM entries
107
+ Optional parameters:\n
108
+ --path PATH\n
109
+ --num NUM\n
110
+ --length LENGTH
111
+
112
+ If no parameters are passed it will generate a single one time pad in the current
113
+ directory of size 250 characters.
114
+ MAKE_ONE_TIME_PAD_LONG_DESC
115
+ option :length, :type => :numeric
116
+ option :num_pads, :type => :numeric
117
+ option :path, :type => :string
118
+ def make_one_time_pad()
119
+ NumberStation::ConfigReader.read_config()
120
+ NumberStation.log.debug "make_one_time_pad"
121
+
122
+ length = options[:length]
123
+ num_pads = options[:num_pads]
124
+ path = options[:path]
125
+
126
+ NumberStation.log.debug "length: #{length}" if options[:length]
127
+ NumberStation.log.debug "num_pads: #{num_pads}" if options[:num_pads]
128
+ NumberStation.log.debug "path: #{path}" if options[:path]
129
+
130
+ NumberStation.make_otp(path, length, num_pads)
131
+ end
132
+
133
+ end
134
+ end
@@ -0,0 +1,43 @@
1
+ =begin
2
+ Ruby Number Station
3
+ Author: David Kirwan https://gitub.com/davidkirwan
4
+ Licence: GPL 3.0
5
+ NumberStation is a collection of utilities to aid in the running of a number station
6
+ Copyright (C) 2018 David Kirwan
7
+
8
+ This program is free software: you can redistribute it and/or modify
9
+ it under the terms of the GNU General Public License as published by
10
+ the Free Software Foundation, either version 3 of the License, or
11
+ (at your option) any later version.
12
+
13
+ This program is distributed in the hope that it will be useful,
14
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ GNU General Public License for more details.
17
+
18
+ You should have received a copy of the GNU General Public License
19
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
20
+ =end
21
+
22
+ module NumberStation
23
+ class ConfigReader
24
+
25
+ def self.read_config()
26
+ begin
27
+ config_file_path = File.join(Dir.pwd, "conf.json")
28
+ NumberStation.set_data( JSON.parse(File.read(config_file_path)) )
29
+ NumberStation.set_log( Logger.new(STDOUT) )
30
+ NumberStation.log.level = NumberStation.data["logging"]["level"]
31
+ NumberStation.log.debug "Reading in config file: #{config_file_path}"
32
+ rescue Exception => e
33
+ config_file_path = File.join(File.dirname(__FILE__), "../../config/conf.json")
34
+ NumberStation.set_data( JSON.parse(File.read(config_file_path)) )
35
+ NumberStation.set_log( Logger.new(STDOUT) )
36
+ NumberStation.log.level = NumberStation.data["logging"]["level"]
37
+ NumberStation.log.debug "Reading in default config file: #{config_file_path}"
38
+ end
39
+ NumberStation.log.debug "NumberStation::ConfigReader#read_config"
40
+ end
41
+
42
+ end
43
+ end
@@ -0,0 +1,51 @@
1
+ =begin
2
+ Ruby Number Station
3
+ Author: David Kirwan https://gitub.com/davidkirwan
4
+ Licence: GPL 3.0
5
+ NumberStation is a collection of utilities to aid in the running of a number station
6
+ Copyright (C) 2018 David Kirwan
7
+
8
+ This program is free software: you can redistribute it and/or modify
9
+ it under the terms of the GNU General Public License as published by
10
+ the Free Software Foundation, either version 3 of the License, or
11
+ (at your option) any later version.
12
+
13
+ This program is distributed in the hope that it will be useful,
14
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ GNU General Public License for more details.
17
+
18
+ You should have received a copy of the GNU General Public License
19
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
20
+ =end
21
+ require "securerandom"
22
+ require "json"
23
+
24
+ module NumberStation
25
+ def self.make_otp(pad_path, length, num_pads)
26
+ path = pad_path || Dir.pwd
27
+ len = length.to_i || 250
28
+ num = num_pads.to_i || 5
29
+
30
+ NumberStation.log.debug "make_otp"
31
+ pads = {}
32
+ id = rand(0..99999).to_s.rjust(5, "0")
33
+ file_name = File.join(path, "one_time_pad_#{id}.json")
34
+ NumberStation.log.debug "file_name: #{file_name}"
35
+
36
+ 0.upto(num - 1) {|i| pads[i] = SecureRandom.hex(len)}
37
+ one_time_pads = {
38
+ :id=> id,
39
+ :pads=> pads
40
+ }
41
+
42
+ unless File.file?(file_name)
43
+ f = File.open(file_name, "w")
44
+ f.write(one_time_pads.to_json)
45
+ f.close
46
+ else
47
+ raise Exception.new("Exception #{file_name} already exists")
48
+ end
49
+
50
+ end
51
+ end
@@ -0,0 +1,24 @@
1
+ =begin
2
+ Ruby Number Station
3
+ Author: David Kirwan https://gitub.com/davidkirwan
4
+ Licence: GPL 3.0
5
+ NumberStation is a collection of utilities to aid in the running of a number station
6
+ Copyright (C) 2018 David Kirwan
7
+
8
+ This program is free software: you can redistribute it and/or modify
9
+ it under the terms of the GNU General Public License as published by
10
+ the Free Software Foundation, either version 3 of the License, or
11
+ (at your option) any later version.
12
+
13
+ This program is distributed in the hope that it will be useful,
14
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ GNU General Public License for more details.
17
+
18
+ You should have received a copy of the GNU General Public License
19
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
20
+ =end
21
+
22
+ module NumberStation
23
+ VERSION = "0.0.2"
24
+ end
@@ -1,66 +1,130 @@
1
- ####################################################
2
- # Ruby Number Station
3
- # Author: David Kirwan https://gitub.com/davidkirwan
4
- ####################################################
5
- require File.join(File.dirname(__FILE__), 'utils/char_lookup')
1
+ =begin
2
+ Ruby Number Station
3
+ Author: David Kirwan https://gitub.com/davidkirwan
4
+ Licence: GPL 3.0
5
+ NumberStation is a collection of utilities to aid in the running of a number station
6
+ Copyright (C) 2018 David Kirwan
7
+
8
+ This program is free software: you can redistribute it and/or modify
9
+ it under the terms of the GNU General Public License as published by
10
+ the Free Software Foundation, either version 3 of the License, or
11
+ (at your option) any later version.
12
+
13
+ This program is distributed in the hope that it will be useful,
14
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ GNU General Public License for more details.
17
+
18
+ You should have received a copy of the GNU General Public License
19
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
20
+ =end
21
+ require 'pastel'
22
+ require 'json'
23
+ require 'logger'
24
+ require 'number_station/alphabet'
25
+ require 'number_station/cli'
26
+ require 'number_station/config_reader'
27
+ require 'number_station/make_pad'
28
+ require 'number_station/version'
29
+
30
+
31
+ module NumberStation
32
+
33
+ def self.hexlify(s)
34
+ a = []
35
+ s.each_byte do |b|
36
+ a << sprintf('%02X', b)
37
+ end
38
+ a.join
39
+ end
40
+
41
+ def self.unhexlify(s)
42
+ a = s.split
43
+ return a.pack('H*')
44
+ end
6
45
 
46
+ def self.command?(name)
47
+ `which #{name}`
48
+ $?.success?
49
+ end
7
50
 
8
- def word_template(word)
9
- return "<prosody pitch=\"#{randomsign + rand(0..200).to_s}\">#{word}</prosody>"
10
- end
51
+ def self.set_log(log)
52
+ @log = log
53
+ end
11
54
 
55
+ def self.log()
56
+ return @log
57
+ end
12
58
 
13
- def randomsign()
14
- rand(0..1) == 0 ? "-" : "+"
15
- end
59
+ def self.set_data(data)
60
+ @data = data
61
+ end
16
62
 
63
+ def self.data()
64
+ return @data
65
+ end
17
66
 
18
- def generate_sentence(message)
19
- sentence = ""
20
- message.split(" ").each do |i|
21
- sentence += word_template(i)
67
+ def self.word_template(word)
68
+ return "<prosody pitch=\"#{randomsign + rand(0..200).to_s}\">#{word}</prosody>"
22
69
  end
23
70
 
24
- sentence_template = "<speak version=\"1.0\" xmlns=\"\" xmlns:xsi=\"\" xsi:schemaLocation=\"\" xml:lang=\"\"><voice gender=\"female\">#{sentence}</voice></speak>"
25
- return sentence_template
26
- end
27
71
 
72
+ def self.randomsign()
73
+ rand(0..1) == 0 ? "-" : "+"
74
+ end
28
75
 
29
- def write_template_file(filename, sentence)
30
- f = File.open(filename, "w")
31
- f.write(sentence)
32
- f.close
33
- end
34
76
 
77
+ def self.generate_sentence(message)
78
+ sentence = ""
79
+ message.split(" ").each do |i|
80
+ sentence += word_template(i)
81
+ end
35
82
 
36
- def call_espeak(filename)
37
- cmd = "espeak -ven+f3 -m -p 60 -s 180 -f #{filename} --stdout | ffmpeg -i - -ar 44100 -ac 2 -ab 192k -f mp3 output.mp3"
38
- `#{cmd}`
39
- end
83
+ sentence_template = "<speak version=\"1.0\" xmlns=\"\" xmlns:xsi=\"\" xsi:schemaLocation=\"\" xml:lang=\"\"><voice gender=\"female\">#{sentence}</voice></speak>"
84
+ return sentence_template
85
+ end
40
86
 
41
87
 
42
- def run(message)
43
- filename = "tmp/GLaDOS_tmp.xml"
44
- sentence = generate_sentence(message)
45
- write_template_file(filename, sentence)
46
- call_espeak(filename)
47
- end
88
+ def self.write_template_file(filename, sentence)
89
+ f = File.open(filename, "w")
90
+ f.write(sentence)
91
+ f.close
92
+ end
48
93
 
49
94
 
50
- def read_message(file_name)
51
- f = File.open(file_name)
52
- message = f.readlines()
53
- f.close()
54
- return message
55
- end
95
+ def self.call_espeak(input_file_path, output_file_path)
96
+ cmd = "espeak -ven+f3 -m -p 60 -s 180 -f #{input_file_path} --stdout | ffmpeg -i - -ar 44100 -ac 2 -ab 192k -f mp3 #{output_file_path}"
97
+
98
+ unless NumberStation.command?('espeak') || NumberStation.command?('ffmpeg')
99
+ NumberStation.log.error "number_station requires the espeak and ffmpeg utilities are installed in order to output an mp3 file."
100
+ else
101
+ `#{cmd}`
102
+ end
103
+ end
104
+
56
105
 
106
+ def self.run(message, output_file_path)
107
+ filename = "/tmp/GLaDOS_tmp.xml"
108
+ sentence = NumberStation.generate_sentence(message)
109
+ NumberStation.write_template_file(filename, sentence)
110
+ NumberStation.call_espeak(filename, output_file_path)
111
+ end
112
+
113
+
114
+ def self.read_message(file_name)
115
+ message = ''
57
116
 
58
- ###################################################
59
- message, intro, body, outro = "", "", "", ""
117
+ f = File.open(file_name)
118
+ raw_message = f.readlines()
119
+ f.close()
60
120
 
61
- intro = read_message("resources/intro_message.txt")
62
- body = read_message("resources/body_message.txt")
63
- outro = read_message("resources/outro_message.txt")
64
- message = intro + body + outro
65
- puts message
66
- #run(message)
121
+ raw_message.each do |i|
122
+ # puts i
123
+ i.gsub!(/\n/, "").strip.each_char do |c|
124
+ message += NumberStation.lookup(c)
125
+ end
126
+ end
127
+ return message + "\n"
128
+ end
129
+
130
+ end
@@ -0,0 +1,61 @@
1
+ =begin
2
+ Ruby Number Station
3
+ Author: David Kirwan https://gitub.com/davidkirwan
4
+ Licence: GPL 3.0
5
+ NumberStation is a collection of utilities to aid in the running of a number station
6
+ Copyright (C) 2018 David Kirwan
7
+
8
+ This program is free software: you can redistribute it and/or modify
9
+ it under the terms of the GNU General Public License as published by
10
+ the Free Software Foundation, either version 3 of the License, or
11
+ (at your option) any later version.
12
+
13
+ This program is distributed in the hope that it will be useful,
14
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ GNU General Public License for more details.
17
+
18
+ You should have received a copy of the GNU General Public License
19
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
20
+ =end
21
+
22
+ lib = File.expand_path("../lib", __FILE__)
23
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
24
+ require "number_station/version"
25
+
26
+ Gem::Specification.new do |spec|
27
+ spec.name = "number_station"
28
+ spec.version = NumberStation::VERSION
29
+ spec.date = "2018-10-12"
30
+ spec.authors = ["David Kirwan"]
31
+ spec.email = ["davidkirwanirl@gmail.com"]
32
+ spec.license = "GPL 3.0"
33
+
34
+ spec.summary = "(WIP) Run your own number station!"
35
+ spec.description = "(WIP) A collection of utilities to aid in running your own number station!"
36
+ spec.homepage = "https://rubygems.org/gems/number_station"
37
+
38
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
39
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
40
+ if spec.respond_to?(:metadata)
41
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
42
+ else
43
+ raise "RubyGems 2.0 or newer is required to protect against " \
44
+ "public gem pushes."
45
+ end
46
+
47
+ # Specify which files should be added to the gem when it is released.
48
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
49
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
50
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
51
+ end
52
+ spec.bindir = "bin"
53
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
54
+ spec.require_paths = ["lib"]
55
+
56
+ spec.add_dependency "pastel"
57
+ spec.add_dependency "thor"
58
+
59
+ spec.add_development_dependency "bundler", "~> 1.16"
60
+ spec.add_development_dependency "rake", "~> 10.0"
61
+ end
@@ -1 +1 @@
1
- echo india seven hotel tango bravo echo india seven hotel tango bravo
1
+ ei7htb ei7htb
@@ -1 +1 @@
1
- echo india seven hotel tango bravo echo india seven hotel tango bravo
1
+ ei7htb ei7htb
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: number_station
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Kirwan
@@ -11,13 +11,13 @@ cert_chain: []
11
11
  date: 2018-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: bundler
14
+ name: pastel
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
- type: :development
20
+ type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
@@ -25,20 +25,48 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: test-unit
28
+ name: thor
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
- type: :development
34
+ type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- description: A collection of utilities to aid in running your own number station!
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.16'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.16'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ description: "(WIP) A collection of utilities to aid in running your own number station!"
42
70
  email:
43
71
  - davidkirwanirl@gmail.com
44
72
  executables:
@@ -46,21 +74,32 @@ executables:
46
74
  extensions: []
47
75
  extra_rdoc_files: []
48
76
  files:
77
+ - ".github/ISSUE_TEMPLATE/bug_report.md"
78
+ - ".github/ISSUE_TEMPLATE/custom.md"
79
+ - ".github/ISSUE_TEMPLATE/feature_request.md"
80
+ - ".gitignore"
81
+ - CODE_OF_CONDUCT.md
49
82
  - COPYING
50
83
  - Gemfile
51
- - Gemfile.lock
52
84
  - README.asciidoc
53
85
  - Rakefile
54
86
  - bin/number_station
87
+ - config/conf.json
55
88
  - lib/number_station.rb
56
- - lib/utils/char_lookup.rb
89
+ - lib/number_station/alphabet.rb
90
+ - lib/number_station/cli.rb
91
+ - lib/number_station/config_reader.rb
92
+ - lib/number_station/make_pad.rb
93
+ - lib/number_station/version.rb
94
+ - number_station.gemspec
57
95
  - resources/body_message.txt
58
96
  - resources/intro_message.txt
59
97
  - resources/outro_message.txt
60
- homepage: http://rubygems.org/gems/usefuldb
98
+ homepage: https://rubygems.org/gems/number_station
61
99
  licenses:
62
100
  - GPL 3.0
63
- metadata: {}
101
+ metadata:
102
+ allowed_push_host: https://rubygems.org
64
103
  post_install_message:
65
104
  rdoc_options: []
66
105
  require_paths:
@@ -69,7 +108,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
69
108
  requirements:
70
109
  - - ">="
71
110
  - !ruby/object:Gem::Version
72
- version: 2.0.0
111
+ version: '0'
73
112
  required_rubygems_version: !ruby/object:Gem::Requirement
74
113
  requirements:
75
114
  - - ">="
@@ -80,5 +119,5 @@ rubyforge_project:
80
119
  rubygems_version: 2.7.7
81
120
  signing_key:
82
121
  specification_version: 4
83
- summary: number_station - run your own number station!
122
+ summary: "(WIP) Run your own number station!"
84
123
  test_files: []
data/Gemfile.lock DELETED
@@ -1,12 +0,0 @@
1
- GEM
2
- specs:
3
- rake (12.3.0)
4
-
5
- PLATFORMS
6
- ruby
7
-
8
- DEPENDENCIES
9
- rake
10
-
11
- BUNDLED WITH
12
- 1.16.2
@@ -1,66 +0,0 @@
1
- ######################################################
2
- # Ruby Number Station
3
- # Author: David Kirwan https://gitub.com/davidkirwan
4
- # Licence: GPL 3.0
5
- ######################################################
6
-
7
- class Char_list
8
- class << self
9
- attr_accessor :chars, :lookup
10
-
11
- @c = nil
12
-
13
- def chars
14
- @c ={
15
- '0' => "zero",
16
- '1' => "one",
17
- '2' => "two",
18
- '3' => "three",
19
- '4' => "four",
20
- '5' => "five",
21
- '6' => "six",
22
- '7' => "seven",
23
- '8' => "eight",
24
- '9' => "nine",
25
- 'a' => "alpha",
26
- 'b' => "bravo",
27
- 'c' => "charlie",
28
- 'd' => "delta",
29
- 'e' => "echo",
30
- 'f' => "foxtrot",
31
- 'g' => "gamma",
32
- 'h' => "hotel",
33
- 'i' => "india",
34
- 'j' => "juliette",
35
- 'k' => "kilo",
36
- 'l' => "lima",
37
- 'm' => "mike",
38
- 'n' => "november",
39
- 'o' => "oscar",
40
- 'p' => "pappa",
41
- 'q' => "quebec",
42
- 'r' => "romeo",
43
- 's' => "sierra",
44
- 't' => "tango",
45
- 'u' => "uniform",
46
- 'v' => "victor",
47
- 'w' => "whiskey",
48
- 'x' => "xray",
49
- 'y' => "yankee",
50
- 'z' => "zulu"
51
- }
52
- end
53
-
54
-
55
- def lookup(c)
56
- begin
57
- x
58
- rescue Exception => e
59
- x
60
- end
61
- end
62
-
63
-
64
- end
65
- end
66
-