jumping_words 0.2.2 → 0.3.0

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
  SHA1:
3
- metadata.gz: 82844693cb24864743765197552c1edf7ca646bb
4
- data.tar.gz: 923a5737bff48c0d898d5bdb6e117d322e605405
3
+ metadata.gz: d199af8b2036ffcecbf92972854db0c3416ffc49
4
+ data.tar.gz: e5dff6a63542450915ab3ee205d97c2b3b2f92e0
5
5
  SHA512:
6
- metadata.gz: b3938b732a19e8ca5d74852ee232bda850f456d94f0f99dcaab77fe7ea3faf9851ece4b14228106d3d9a030baa4964695981e3d4f3a6ced75f945f278d46e1ae
7
- data.tar.gz: cbca22ed0a45c3ffdbee5fd435a0603f0238c2f430be995e3a7f6f91ce41f1edb8578e099c9fadd8b1c1f57045a86392e0df1e6f68da947ebc3c843961df6cde
6
+ metadata.gz: 92edfbc425f21b5321ebec92976aa0527f93307fb1b0903ae033b11d04a948402050d2d333d5c4b30cf2882196d18ee8bc9d1ae6d0749bcb77283ab8626ba4cd
7
+ data.tar.gz: 02943d04bfa6ca7bf864b22167b507d5fd902a99883352427e66a38a32345a3ed7dfebb16ee7d5868f3cd03a5ed05506b3bb9a018ab5d107c06eac0065e88b29
data/README.rdoc CHANGED
@@ -1,35 +1,55 @@
1
1
  = Jumping Words
2
- The program for Ubuntu or MAC OS X(!!! Only 10.8 or higher version MAC OS X).
3
- Does this: speaks and displays in the pop-up window the word (phrase) and then translated word (phrase).
4
- After end of list back to start.
2
+ The program speaks and displays in the pop-up window the word or phrase and the word's translation or phrase.
3
+ After end of list back to the start.
4
+
5
+ Supports OS MAC OS X 10.8 or higher or Ubuntu
5
6
 
6
7
  == Dependencies
7
8
  For linux
8
9
  sudo apt-get install libnotify-bin
9
10
 
10
- For MAC OS X for the Russian users you must change the voice of system to Milena
11
+ On MAC OS X before you start, you should add to your system the voices for words and translates.
12
+ To enable the speech recognition ability and use speech commands on your Mac, the first thing you have to do is open the Speech menu from System Preferences.
13
+
14
+ For example for Russian you should install the Milena voice.
15
+
16
+ == Config
17
+ Default:
18
+ Show message: true
19
+ Timeout between a word and translate: 3 sec.
20
+ Timeout to start list: 10 sec.
21
+ MAC OS X word voice: Vicki.
22
+ MAC OS X translate voice: Milena.
11
23
 
24
+ More:
25
+ jwords -h
12
26
 
13
27
  == Actions
14
28
  Starting
15
- jwords -s
29
+ jwords start
30
+ or
31
+ jwords -v Fiona -t Milena -i5 start
16
32
 
17
33
  Stoping
18
34
  ctrl+c
19
35
 
20
36
  View a list of words
21
- jwords -l
37
+ jwords list
22
38
 
23
- 1 to write: писать
24
- 2 root: корень
25
- 3 list: список
39
+ 1 convenient: удобный | 7
40
+ 2 If I were you: на твоем месте | 6
41
+ 3 in turns: по очереди | 5
42
+ 4 endurance: выносливость | 2
43
+ 5 spoil, spoilt, spoilt: портиться, испортилось | 2
44
+ 6 to lead, led, led: приводить, привели | 2
45
+ 7 to achieve: достигать | 2
26
46
  ...
27
47
 
28
48
  Adding words to the database
29
49
  jwords -a root: корень
30
50
  jwords -a to play: играть
31
51
 
32
- Delete a word from the database (indicated by the index of the word)
52
+ Delete a word from the database (indicated by the index of the word in the list)
33
53
  jwords -d 1
34
54
 
35
55
  If you want to change words in directly in CSV find .jwords directory in your home directory, then open jumping_words_db.csv. After saving the file restart the script.
data/bin/jwords CHANGED
@@ -1,13 +1,47 @@
1
1
  #!/usr/bin/env ruby
2
2
  # encoding: utf-8
3
3
  require 'optparse'
4
+ require 'ostruct'
4
5
  require 'pp'
5
6
 
6
7
  $:.push File.expand_path("../../lib", __FILE__)
7
8
  require 'jumping_words'
8
9
 
9
- options = {}
10
- optparse = OptionParser.new do|opts|
10
+ include OS
11
+
12
+ options = OpenStruct.new
13
+ options.message = SHOW_MESSAGE
14
+ options.space_words = SPACE_WORDS
15
+ options.space_interation = SPACE_INTERATION
16
+ options.mac_word_voice = MAC_WORD_VOICE
17
+ options.mac_translate_voice = MAC_TRANSLATE_VOICE
18
+ options.repeat = REPEAT
19
+
20
+ optparse = OptionParser.new do |opts|
21
+
22
+ opts.on( '-n', '--no-message', 'No display message' ) do
23
+ options.message = false
24
+ end
25
+
26
+ opts.on( '-r', '--repeat [TIMES]', Integer, "How many times repeat each word in the cycle. Default: #{REPEAT}" ) do |times|
27
+ options.repeat = times
28
+ end
29
+
30
+ opts.on( '-w', '--timeout-words [SPACE]', Integer, "Timeout between the word and translate. Default: #{SPACE_WORDS}" ) do |space_words|
31
+ options.space_words = space_words
32
+ end
33
+
34
+ opts.on( '-i', '--timeout-interation [SPACE]', Integer, "Timeout an each interation. Default: #{SPACE_INTERATION}" ) do |space_interation|
35
+ options.space_interation = space_interation
36
+ end
37
+
38
+ opts.on( '-v', '--mac-word-voice [VOICE]', String, "MAC OS X word voice" ) do |voice|
39
+ options.mac_word_voice = voice
40
+ end
41
+
42
+ opts.on( '-t', '--mac-translate-voice [VOICE]', String, "MAC OS X translate voice" ) do |voice|
43
+ options.mac_translate_voice = voice
44
+ end
11
45
 
12
46
  #The command addes a word
13
47
  opts.on( '-a', '--add', 'Add the word' ) do
@@ -33,25 +67,40 @@ optparse = OptionParser.new do|opts|
33
67
  end
34
68
  end
35
69
 
36
- #The list of words
37
- opts.on( '-l', '--list', 'List of words' ) do
38
- db = DbWords.new
39
- db.list
40
- exit
41
- end
42
-
43
- #run the application
44
- opts.on( '-s', '--start', 'Start of app' ) do
45
- db = DbWords.new
46
- app = SayWords.new(:show_message => SHOW_MESSAGE, :space_words => SPACE_WORDS, :space_interation => SPACE_INTERATION)
47
70
 
48
- begin
49
- app.run
50
- rescue Interrupt
51
- puts "Exiting..."
52
- end
53
- end
54
71
 
55
72
  end
56
73
 
57
74
  optparse.parse!
75
+
76
+ puts "Show message: #{options.message}"
77
+ puts "Timeout between a word and translate: #{options.space_words} sec."
78
+ puts "Timeout to start list: #{options.space_interation} sec."
79
+ if mac?
80
+ puts "MAC OS X word voice: #{options.mac_word_voice}."
81
+ puts "MAC OS X translate voice: #{options.mac_translate_voice}."
82
+ end
83
+
84
+ puts "How many times repeat each word in the cycle: #{options.repeat}"
85
+
86
+ #run the application
87
+ if ARGV.first == 'start'
88
+ db = DbWords.new
89
+ app = SayWords.new(:show_message => options.message, :space_words => options.space_words,
90
+ :space_interation => options.space_interation, :mac_word_voice => options.mac_word_voice,
91
+ :mac_translate_voice => options.mac_translate_voice, :repeat => options.repeat )
92
+
93
+ begin
94
+ app.run
95
+ rescue Interrupt
96
+ puts "Exiting..."
97
+ end
98
+ end
99
+
100
+
101
+ #The list of words
102
+ if ARGV.first == 'list'
103
+ db = DbWords.new
104
+ db.list
105
+ exit
106
+ end
data/config.rb CHANGED
@@ -3,8 +3,14 @@ DATABASE = "jumping_words_db"
3
3
  # Database directory
4
4
  DATABASE_DIR = ".jwords"
5
5
  # space between word and translate
6
- SPACE_WORDS = 3
6
+ SPACE_WORDS = 2
7
7
  # space iteration
8
8
  SPACE_INTERATION = 10
9
9
  #show message box true or false
10
10
  SHOW_MESSAGE = true
11
+ #MAC OS X word voice
12
+ MAC_WORD_VOICE = 'Vicki'
13
+ #MAC OS X translate voice
14
+ MAC_TRANSLATE_VOICE = 'Milena'
15
+ #how many times repeat each word in the cycle
16
+ REPEAT = 1
@@ -60,14 +60,12 @@ class DbWords
60
60
  end
61
61
  end
62
62
  end
63
-
64
- GC.start
65
63
  end
66
64
 
67
65
  #Print the list of words
68
66
  def list
69
67
  list_of_words do |word, idx|
70
- puts "#{idx + 1} #{word[0]} | #{word[1]} | #{word[2]}"
68
+ puts "#{idx + 1} #{word[0]}: #{word[1]} | #{word[2]}"
71
69
  end
72
70
  end
73
71
 
@@ -4,9 +4,12 @@ class SayWords
4
4
  def initialize(options={})
5
5
  @db = DbWords.new
6
6
  @collection = @db.collection
7
- @show_message = options[:show_message] || SHOW_MESSAGE
7
+ @show_message = options[:show_message].nil? ? SHOW_MESSAGE : options[:show_message]
8
8
  @space_words = options[:space_words] || SPACE_WORDS
9
9
  @space_interation = options[:space_interation] || SPACE_INTERATION
10
+ @mac_word_voice = options[:mac_word_voice] || MAC_WORD_VOICE
11
+ @mac_translate_voice = options[:mac_translate_voice] || MAC_TRANSLATE_VOICE
12
+ @repeat = options[:repeat] || REPEAT
10
13
  end
11
14
 
12
15
  def run
@@ -21,39 +24,60 @@ class SayWords
21
24
  def do_ubuntu
22
25
  loop do
23
26
  @collection.each_with_index do |word, idx|
24
- puts "#{word[0]}: #{word[1]} | #{word[2]}"
25
- system 'notify-send -i /usr/share/pixmaps/gnome-irc.png "'+ word[0] +'" "'+ word[1] +'" -t 1' if @show_message
26
- system 'espeak -v en -s120 "'+ word[0] +'"'
27
- sleep @space_words
28
- #puts "I say #{word[1]}"
29
- system 'espeak -v ru -s120 "'+ word[1] +'"'
27
+ rep_times = !word[2].nil? ? word[2].to_i : 1
28
+ @repeat.times do
30
29
 
31
- #set number of showing
32
- @db.update(idx, [word[0], word[1], !word[2].nil? ? word[2].to_i + 1 : 1])
30
+ rep_times += 1
33
31
 
32
+ puts "#{word[0]}: #{word[1]} | #{rep_times}"
33
+ system 'notify-send -i /usr/share/pixmaps/gnome-irc.png "'+ word[0] +'" "'+ word[1] +'" -t 1' if @show_message
34
+ system 'espeak -v en -s120 "'+ word[0] +'"'
35
+ sleep @space_words
36
+
37
+ system 'espeak -v ru -s120 "'+ word[1] +'"'
38
+
39
+ #set number of showing
40
+ @db.update(idx, [word[0], word[1], rep_times])
41
+
42
+ sleep @space_words
43
+ end
34
44
  sleep @space_interation
35
45
  end
36
46
  sleep 4 # for notification hiding
47
+
48
+ #cleaning
49
+ GC.start
37
50
  end
38
51
  end
39
52
 
40
53
  def do_mac
41
54
  loop do
42
55
  @collection.each_with_index do |word, idx|
43
- puts "#{word[0]}: #{word[1]} | #{!word[2].nil? ? word[2].to_i + 1 : 1}"
44
- #puts 'terminal-notifier -message "'+ word[0] +': '+ word[1] +'" -title "JWords"' if @show_message
45
- system 'terminal-notifier -message "'+ word[0] +': '+ word[1] +'" -title ""' if @show_message
46
- system 'say -v Vicki "'+ word[0] +'"'
47
- sleep @space_words
48
- #puts "I say #{word[1]}"
49
- system 'say -v Milena "'+ word[1] +'"'
56
+ rep_times = !word[2].nil? ? word[2].to_i : 1
57
+ @repeat.times do
58
+
59
+ rep_times += 1
50
60
 
51
- #set number of showing
52
- @db.update(idx, [word[0], word[1], !word[2].nil? ? word[2].to_i + 1 : 1])
61
+ puts "#{word[0]}: #{word[1]} | #{rep_times}"
53
62
 
63
+ system 'terminal-notifier -message "'+ word[0] +': '+ word[1] +'" -title ""' if @show_message
64
+ system 'say -v ' + @mac_word_voice + ' "'+ word[0] +'"'
65
+
66
+ sleep @space_words
67
+
68
+ system 'say -v '+ @mac_translate_voice +' "'+ word[1] +'"'
69
+
70
+ #set number of showing
71
+ @db.update(idx, [word[0], word[1], rep_times])
72
+
73
+ sleep @space_words
74
+ end
54
75
  sleep @space_interation
55
76
  end
56
77
  sleep 4 # for notification hiding
78
+
79
+ #cleaning
80
+ GC.start
57
81
  end
58
82
 
59
83
  end
@@ -1,3 +1,3 @@
1
1
  module Jwords
2
- VERSION = "0.2.2"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jumping_words
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Dmitriev