cw_parser 0.0.1 → 0.0.2

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.
data/README.md ADDED
@@ -0,0 +1,8 @@
1
+ cw_parser
2
+ =========
3
+
4
+ cw_parser
5
+
6
+ Takes Morse Code and translates it to text and vise versa.
7
+
8
+ gem install cw_parser-0.0.1.gem
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
data/cw_parser.gemspec CHANGED
@@ -5,16 +5,16 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "cw_parser"
8
- s.version = "0.0.1"
8
+ s.version = "0.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["wsugg"]
12
- s.date = "2012-12-11"
12
+ s.date = "2012-12-13"
13
13
  s.description = "Takes Morse Code and translates it to text and vise versa. Fall UW Ruby Class Final Project."
14
14
  s.email = "sugg.will@gmail.com"
15
- s.executables = ["cw_parser_init.rb", "morsecode.txt", "morsecode.txt~"]
16
15
  s.extra_rdoc_files = [
17
16
  "LICENSE.txt",
17
+ "README.md",
18
18
  "README.rdoc"
19
19
  ]
20
20
  s.files = [
@@ -22,12 +22,10 @@ Gem::Specification.new do |s|
22
22
  "Gemfile",
23
23
  "Gemfile.lock",
24
24
  "LICENSE.txt",
25
+ "README.md",
25
26
  "README.rdoc",
26
27
  "Rakefile",
27
28
  "VERSION",
28
- "bin/cw_parser_init.rb",
29
- "bin/morsecode.txt",
30
- "cw_parser-0.0.1.gem",
31
29
  "cw_parser.gemspec",
32
30
  "lib/cw_parse_code.rb",
33
31
  "lib/cw_parse_text.rb",
data/lib/cw_parse_code.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  module CW_Parse_Code
4
4
 
5
5
  def parse_code(code_to_translate)
6
- puts "code_to_translate: #{code_to_translate}"
6
+ #puts "code_to_translate: #{code_to_translate}"
7
7
  code_to_translate_ary = Array.new
8
8
  result_str = ""
9
9
 
data/lib/cw_parser.rb CHANGED
@@ -0,0 +1,79 @@
1
+ #!usr/bin/env ruby
2
+ #require "rubygems"
3
+ #require "bundler/setup"
4
+
5
+ require 'cw_parse_text'
6
+ require 'cw_parse_code'
7
+
8
+ #args to cw_parser: text | code, file, filepath, play code sounds (implement sound later)
9
+
10
+ class CW_Parser
11
+
12
+ include CW_Parse_Text
13
+ include CW_Parse_Code
14
+
15
+ attr_reader :morse_code
16
+ attr_accessor :mode, :sound, :filepath
17
+
18
+ def initialize(mode=[:text],filepath="",sound="no")
19
+ @mode = mode
20
+ @filepath = filepath
21
+ @sound = sound
22
+
23
+ @morse_code = {
24
+ "A" => '.-', "B" => '-...', "C" => '-.-.', "D" => '-..', "E" => '.', "F" => '..-.', "G" => '--.',
25
+ "H" => '....', "I" => '..', "J" => '.---', "K" => '-.-', "L" => '.-..', "M" => '--',
26
+ "N" => '-.', "O" => '---', "P" => '.--.', "Q" => '--.-', "R" => '.-.', "S" => '...',
27
+ "T" => '-', "U" => '..-', "V" => '...-', "W" => '.--', "X" => '-..-', "Y" => '-.--',
28
+ "Z" => '--..', "1" => '.----', "2" => '..---', "3" => '...--', "4" => '....-', "5" => '.....',
29
+ "6" => '-....', "7" => '--...', "8" => '---..', "9" => '----.', "0" => '-----', " " => ' ', "" =>'',
30
+ }
31
+
32
+ end
33
+
34
+ def translate_file(path="")
35
+ if true == File.exist?(path)
36
+ puts "path: #{path}"
37
+ puts "mode= #{@mode}"
38
+ ftranslate = File.read(path)
39
+ ftranslate.gsub!(/\n/, " ")
40
+ else
41
+ puts "#{path} does not exsist"
42
+ end
43
+
44
+ if @mode == :text
45
+ puts ftranslate.inspect
46
+ parse_text(ftranslate)
47
+ else
48
+ puts ftranslate.inspect
49
+ parse_code(ftranslate)
50
+ end
51
+ end
52
+
53
+ end
54
+
55
+
56
+
57
+ #puts ftranslate
58
+ #ftranslate.each{|line| puts "text line:" ;line = line.chop; parse_text(line)}
59
+ =begin
60
+ if true == File.exist?(filepath)
61
+ puts filepath
62
+ puts "text_symbol:#{:text} code_or_text:#{code_or_text}"
63
+ if code_or_text == [:text]
64
+ ftranslate = File.open(filepath, "r")
65
+ ftranslate.each{|line| line = line.chop; parse_text(line)}
66
+ else ftranslate.each{|line| parse_code(line)}
67
+ end
68
+
69
+ elsif code_or_text == [:text]
70
+ puts :text
71
+ #code_or_text = "this is the text to translate!"
72
+ #parse_text(code_or_text)
73
+
74
+ elsif code_or_text == [:code]
75
+ puts :code
76
+ #code = "this"
77
+ parse_code(code)
78
+ end
79
+ =end
data/lib/test.txt CHANGED
@@ -1,2 +1,2 @@
1
- This is the text to translate in the txt file
2
- this is the second line to translate
1
+ THIS IS THE TEXT TO TRANSLATE IN THE TXT FILE
2
+ THIS IS THE SECOND LINE TO TRANSLATE
@@ -1,7 +1,5 @@
1
- require '~/Fall2012FinalProj/cw_parser/bin/cw_parser_init.rb'
2
- #puts File.dirname(__FILE__)
3
- #puts" #{File.dirname("/bin/cw_parser_init.rb")}"
4
- #puts require "#{File.dirname('../'__FILE__)}/cw_parser_init.rb"
1
+ require '../lib/cw_parser.rb'
2
+
5
3
 
6
4
  describe CW_Parser do
7
5
  testfile = "../lib/test.txt"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cw_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-11 00:00:00.000000000 Z
12
+ date: 2012-12-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rdoc
@@ -62,25 +62,21 @@ dependencies:
62
62
  description: Takes Morse Code and translates it to text and vise versa. Fall UW Ruby
63
63
  Class Final Project.
64
64
  email: sugg.will@gmail.com
65
- executables:
66
- - cw_parser_init.rb
67
- - morsecode.txt
68
- - morsecode.txt~
65
+ executables: []
69
66
  extensions: []
70
67
  extra_rdoc_files:
71
68
  - LICENSE.txt
69
+ - README.md
72
70
  - README.rdoc
73
71
  files:
74
72
  - .document
75
73
  - Gemfile
76
74
  - Gemfile.lock
77
75
  - LICENSE.txt
76
+ - README.md
78
77
  - README.rdoc
79
78
  - Rakefile
80
79
  - VERSION
81
- - bin/cw_parser_init.rb
82
- - bin/morsecode.txt
83
- - cw_parser-0.0.1.gem
84
80
  - cw_parser.gemspec
85
81
  - lib/cw_parse_code.rb
86
82
  - lib/cw_parse_text.rb
@@ -89,7 +85,6 @@ files:
89
85
  - lib/test_code.txt
90
86
  - spec/cw_parser_spec.rb
91
87
  - test/test_cw_parser.rb
92
- - bin/morsecode.txt~
93
88
  homepage: http://github.com/wsugg/cw_parser
94
89
  licenses:
95
90
  - MIT
@@ -103,6 +98,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
103
98
  - - ! '>='
104
99
  - !ruby/object:Gem::Version
105
100
  version: '0'
101
+ segments:
102
+ - 0
103
+ hash: 306435859
106
104
  required_rubygems_version: !ruby/object:Gem::Requirement
107
105
  none: false
108
106
  requirements:
@@ -1,74 +0,0 @@
1
- #!usr/bin/env ruby
2
- #require "rubygems"
3
- #require "bundler/setup"
4
- require '../lib/cw_parse_text.rb'
5
- require '../lib/cw_parse_code.rb'
6
-
7
-
8
- #args to cw_parser: text | code, file, filepath, play code sounds (implement sound later)
9
-
10
- class CW_Parser
11
- include CW_Parse_Text
12
- include CW_Parse_Code
13
-
14
- attr_reader :morse_code
15
- attr_accessor :mode, :sound, :filepath
16
-
17
- def initialize(mode=[:text],filepath="",sound="no")
18
- @mode = mode
19
- @filepath = filepath
20
- @sound = sound
21
-
22
- puts "filepath: #{filepath}"
23
- @morse_code = {}
24
-
25
- f = File.open("../bin/morsecode.txt", "r")
26
- f.each{|l| l.split(/\=/); @morse_code.store(l[0],l[2..10].chomp)}
27
- #@morse_code.each{|i| puts i} #for debugging
28
- end
29
-
30
- def translate_file(path="")
31
- if true == File.exist?(path)
32
- puts "path: #{path}"
33
- puts "mode= #{@mode}"
34
- ftranslate = File.read(path)
35
- ftranslate.gsub!(/\n/, " ")
36
-
37
- if @mode == :text
38
- puts ftranslate.inspect
39
- parse_text(ftranslate)
40
- else
41
- puts ftranslate.inspect
42
- parse_code(ftranslate)
43
- end
44
- else "#{path} does not exsist"
45
- end
46
- end
47
-
48
- end
49
-
50
-
51
-
52
- #puts ftranslate
53
- #ftranslate.each{|line| puts "text line:" ;line = line.chop; parse_text(line)}
54
- =begin
55
- if true == File.exist?(filepath)
56
- puts filepath
57
- puts "text_symbol:#{:text} code_or_text:#{code_or_text}"
58
- if code_or_text == [:text]
59
- ftranslate = File.open(filepath, "r")
60
- ftranslate.each{|line| line = line.chop; parse_text(line)}
61
- else ftranslate.each{|line| parse_code(line)}
62
- end
63
-
64
- elsif code_or_text == [:text]
65
- puts :text
66
- #code_or_text = "this is the text to translate!"
67
- #parse_text(code_or_text)
68
-
69
- elsif code_or_text == [:code]
70
- puts :code
71
- #code = "this"
72
- parse_code(code)
73
- end
74
- =end
data/bin/morsecode.txt DELETED
@@ -1,38 +0,0 @@
1
- A=.-
2
- B=-...
3
- C=-.-.
4
- D=-..
5
- E=.
6
- F=..-.
7
- G=--.
8
- H=....
9
- I=..
10
- J=.---
11
- K=-.-
12
- L=.-..
13
- M=--
14
- N=-.
15
- O=---
16
- P=.--.
17
- Q=--.-
18
- R=.-.
19
- S=...
20
- T=-
21
- U=..-
22
- V=...-
23
- W=.--
24
- X=-..-
25
- Y=-.--
26
- Z=--..
27
- 1=.----
28
- 2=..---
29
- 3=...--
30
- 4=....-
31
- 5=.....
32
- 6=-....
33
- 7=--...
34
- 8=---..
35
- 9=----.
36
- 0=-----
37
- =
38
- =
data/bin/morsecode.txt~ DELETED
@@ -1,38 +0,0 @@
1
- A=.-
2
- B=-...
3
- C=-.-.
4
- D=-..
5
- E=.
6
- F=..-.
7
- G=--.
8
- H=....
9
- I=..
10
- J=.---
11
- K=-.-
12
- L=.-..
13
- M=--
14
- N=-.
15
- O=---
16
- P=.--.
17
- Q=--.-
18
- R=.-.
19
- S=...
20
- T=-
21
- U=..-
22
- V=...-
23
- W=.--
24
- X=-..-
25
- Y=-.--
26
- Z=--..
27
- 1=.----
28
- 2=..---
29
- 3=...--
30
- 4=....-
31
- 5=.....
32
- 6=-....
33
- 7=--...
34
- 8=---..
35
- 9=----.
36
- 0=-----
37
- =
38
- =