jumping_words 0.1.1 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2c73efa6291f37d1833611a0932f16f2fff36bc1
4
+ data.tar.gz: 6b1ece8f49ff753321cb3df4250dc0780d064b7a
5
+ SHA512:
6
+ metadata.gz: 6862549694ca66c1888a9d46eb457489de411fe38669bcf1d4d911250e55ee3955be924f6adfffcc1ba8e56958b3a2238c1c7c2c923d0cb8ab50d4a35dedece2
7
+ data.tar.gz: a3148c23ace3b12ba3b58bd822aae7ebc4f4257c54469fc2dc4691daad8e46b58a0f4c2d061c60e6d714df13d5c720788fdbeba0ff706e6ae953c5f579e521c2
data/README.rdoc CHANGED
@@ -32,8 +32,13 @@ Adding words to the database
32
32
  Delete a word from the database (indicated by the index of the word)
33
33
  jwords -d 1
34
34
 
35
+ 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.
36
+
35
37
  == Install
36
- gem install jumping_words
38
+ gem install jumping_words
39
+
40
+ For OS X users: you also should install the https://github.com/alloy/terminal-notifier for notifications.
41
+ brew install terminal-notifier
37
42
 
38
43
  == ToDo
39
44
  For Ubuntu users give config for changing language system voice.
data/bin/jwords CHANGED
@@ -12,7 +12,7 @@ optparse = OptionParser.new do|opts|
12
12
  #The command addes a word
13
13
  opts.on( '-a', '--add', 'Add the word' ) do
14
14
  if ARGV.empty? or ARGV.size < 2
15
- puts 'You mast set 2 words! Firs is word, second is translate. Like this: "jwords -a to run: бежать"'
15
+ puts 'You mast set 2 words! First is word, second is translate. Like this: "jwords -a to run: бежать"'
16
16
  exit
17
17
  else
18
18
  db = DbWords.new(ARGV)
@@ -21,7 +21,7 @@ optparse = OptionParser.new do|opts|
21
21
  end
22
22
  end
23
23
 
24
- #The command deletes a word
24
+ #The command deletes the word
25
25
  opts.on( '-d', '--destroy', 'Delete the word' ) do
26
26
  if ARGV.empty?
27
27
  puts 'You mast set number of word!'
@@ -43,7 +43,7 @@ optparse = OptionParser.new do|opts|
43
43
  #run the application
44
44
  opts.on( '-s', '--start', 'Start of app' ) do
45
45
  db = DbWords.new
46
- app = SayWords.new(db.collection, :show_message => SHOW_MESSAGE, :space_words => SPACE_WORDS, :space_interation => SPACE_INTERATION)
46
+ app = SayWords.new(:show_message => SHOW_MESSAGE, :space_words => SPACE_WORDS, :space_interation => SPACE_INTERATION)
47
47
 
48
48
  begin
49
49
  app.run
@@ -55,4 +55,3 @@ optparse = OptionParser.new do|opts|
55
55
  end
56
56
 
57
57
  optparse.parse!
58
-
@@ -48,10 +48,26 @@ class DbWords
48
48
  list
49
49
  end
50
50
 
51
+ def update(index, updated_row)
52
+ list_w = collection
53
+
54
+ CSV.open(@file, "w") do |csv|
55
+ list_w.each_with_index do |row, idx|
56
+ if index == idx
57
+ csv << updated_row
58
+ else
59
+ csv << row
60
+ end
61
+ end
62
+ end
63
+
64
+ GC.start
65
+ end
66
+
51
67
  #Print the list of words
52
68
  def list
53
69
  list_of_words do |word, idx|
54
- puts "#{idx + 1} #{word[0]}: #{word[1]}"
70
+ puts "#{idx + 1} #{word[0]} | #{word[1]} | #{word[2]}"
55
71
  end
56
72
  end
57
73
 
@@ -1,8 +1,9 @@
1
1
  class SayWords
2
2
  include OS
3
3
 
4
- def initialize(collection, options={})
5
- @collection = collection
4
+ def initialize(options={})
5
+ @db = DbWords.new
6
+ @collection = @db.collection
6
7
  @show_message = options[:show_message] || SHOW_MESSAGE
7
8
  @space_words = options[:space_words] || SPACE_WORDS
8
9
  @space_interation = options[:space_interation] || SPACE_INTERATION
@@ -19,13 +20,17 @@ class SayWords
19
20
  private
20
21
  def do_ubuntu
21
22
  loop do
22
- @collection.each do |word|
23
- puts "I say #{word[0]}"
23
+ @collection.each_with_index do |word, idx|
24
+ puts "#{word[0]}: #{word[1]} | #{word[2]}"
24
25
  system 'notify-send -i /usr/share/pixmaps/gnome-irc.png "'+ word[0] +'" "'+ word[1] +'" -t 1' if @show_message
25
26
  system 'espeak -v en -s120 "'+ word[0] +'"'
26
27
  sleep @space_words
27
28
  #puts "I say #{word[1]}"
28
29
  system 'espeak -v ru -s120 "'+ word[1] +'"'
30
+
31
+ #set number of showing
32
+ @db.update(idx, [word[0], word[1], !word[2].nil? ? word[2].to_i + 1 : 1])
33
+
29
34
  sleep @space_interation
30
35
  end
31
36
  sleep 4 # for notification hiding
@@ -34,14 +39,18 @@ class SayWords
34
39
 
35
40
  def do_mac
36
41
  loop do
37
- @collection.each do |word|
38
- puts "I say #{word[0]}"
42
+ @collection.each_with_index do |word, idx|
43
+ puts "#{word[0]}: #{word[1]} | #{!word[2].nil? ? word[2].to_i + 1 : 1}"
39
44
  #puts 'terminal-notifier -message "'+ word[0] +': '+ word[1] +'" -title "JWords"' if @show_message
40
- system '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
41
46
  system 'say -v Vicki "'+ word[0] +'"'
42
47
  sleep @space_words
43
48
  #puts "I say #{word[1]}"
44
49
  system 'say -v Milena "'+ word[1] +'"'
50
+
51
+ #set number of showing
52
+ @db.update(idx, [word[0], word[1], !word[2].nil? ? word[2].to_i + 1 : 1])
53
+
45
54
  sleep @space_interation
46
55
  end
47
56
  sleep 4 # for notification hiding
@@ -1,3 +1,3 @@
1
1
  module Jwords
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,30 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jumping_words
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
5
- prerelease:
4
+ version: 0.2.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Alex Dmitriev
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-09-21 00:00:00.000000000 Z
11
+ date: 2015-03-14 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: terminal-notifier
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  description: Jumping Words is gem for learning new words foreign languages, only Ubuntu
@@ -36,7 +33,7 @@ executables:
36
33
  extensions: []
37
34
  extra_rdoc_files: []
38
35
  files:
39
- - .gitignore
36
+ - ".gitignore"
40
37
  - Gemfile
41
38
  - README.rdoc
42
39
  - Rakefile
@@ -50,26 +47,25 @@ files:
50
47
  - lib/jwords/version.rb
51
48
  homepage: https://github.com/devmen/jumping_words
52
49
  licenses: []
50
+ metadata: {}
53
51
  post_install_message:
54
52
  rdoc_options: []
55
53
  require_paths:
56
54
  - lib
57
55
  required_ruby_version: !ruby/object:Gem::Requirement
58
- none: false
59
56
  requirements:
60
- - - ! '>='
57
+ - - ">="
61
58
  - !ruby/object:Gem::Version
62
59
  version: '0'
63
60
  required_rubygems_version: !ruby/object:Gem::Requirement
64
- none: false
65
61
  requirements:
66
- - - ! '>='
62
+ - - ">="
67
63
  - !ruby/object:Gem::Version
68
64
  version: '0'
69
65
  requirements: []
70
66
  rubyforge_project: jumping_words
71
- rubygems_version: 1.8.24
67
+ rubygems_version: 2.4.3
72
68
  signing_key:
73
- specification_version: 3
69
+ specification_version: 4
74
70
  summary: Jumping Words is gem for learning new words foreign languages
75
71
  test_files: []