jumping_words 0.0.3 → 0.1.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.
data/Gemfile CHANGED
@@ -2,3 +2,5 @@ source "http://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in jwords.gemspec
4
4
  gemspec
5
+
6
+ gem 'terminal-notifier'
data/README.rdoc CHANGED
@@ -1,15 +1,24 @@
1
1
  = Jumping Words
2
- The program for Ubuntu speaks and displays in the pop-up window the word (phrase) and then translated word (phrase).
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.
3
5
 
4
6
  == Dependencies
7
+ For linux
5
8
  sudo apt-get install libnotify-bin
6
9
 
10
+ For MAC OS X for the Russian users you must change the voice of system to Milena
11
+
12
+
7
13
  == Actions
8
14
  Starting
9
- jword -s
15
+ jwords -s
16
+
17
+ Stoping
18
+ ctrl+c
10
19
 
11
20
  View a list of words
12
- jword -l
21
+ jwords -l
13
22
 
14
23
  1 to write: писать
15
24
  2 root: корень
@@ -17,13 +26,15 @@ View a list of words
17
26
  ...
18
27
 
19
28
  Adding words to the database
20
- jword -a root: корень
21
- jword -a to game: играть
29
+ jwords -a root: корень
30
+ jwords -a to game: играть
22
31
 
23
32
  Delete a word from the database (indicated by the index of the word)
24
- jword -d 1
25
- jword -d 1 2
33
+ jwords -d 1
34
+ jwords -d 1 2
26
35
 
27
36
  == Install
28
37
  gem install jumping_words
29
38
 
39
+ == ToDo
40
+ For Ubuntu users give config for changing language system voice.
File without changes
data/config.rb CHANGED
@@ -1,8 +1,10 @@
1
1
  # Database name
2
- DATABASE = "jumping_words"
2
+ DATABASE = "jumping_words_db"
3
+ # Database directory
4
+ DATABASE_DIR = ".jwords"
3
5
  # space between word and translate
4
6
  SPACE_WORDS = 3
5
7
  # space iteration
6
- SPACE_INTERATION = 20
8
+ SPACE_INTERATION = 10
7
9
  #show message box true or false
8
10
  SHOW_MESSAGE = true
data/jwords.gemspec CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
9
9
  s.email = ["alex@devmen.com"]
10
10
  s.homepage = "https://github.com/devmen/jumping_words"
11
11
  s.summary = %q{Jumping Words is gem for learning new words foreign languages}
12
- s.description = %q{Jumping Words is gem for learning new words foreign languages, only ubuntu}
12
+ s.description = %q{Jumping Words is gem for learning new words foreign languages, only Ubuntu or MAC OS X(10.8 or higher}
13
13
 
14
14
  s.rubyforge_project = "jumping_words"
15
15
 
@@ -20,5 +20,5 @@ Gem::Specification.new do |s|
20
20
 
21
21
  # specify any dependencies here; for example:
22
22
  # s.add_development_dependency "rspec"
23
- # s.add_runtime_dependency "rest-client"
23
+ s.add_runtime_dependency "terminal-notifier"
24
24
  end
data/lib/jumping_words.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require File.dirname(__FILE__) + "/jwords/os"
1
2
  require File.dirname(__FILE__) + "/jwords/version"
2
3
  require File.dirname(__FILE__) + '/jwords/db_words'
3
4
  require File.dirname(__FILE__) + '/jwords/say_words'
@@ -7,8 +7,8 @@ class DbWords
7
7
  def initialize(argv=nil)
8
8
  @argv = argv
9
9
  @words = Array.new
10
-
11
- @file = File.dirname(__FILE__) + "/../../db/" + DATABASE + ".csv"
10
+ @file = File.join(Dir.home, DATABASE_DIR, "#{DATABASE}.csv")
11
+ create_db unless File.exist?(@file)
12
12
  end
13
13
 
14
14
  #collecion of words
@@ -61,7 +61,7 @@ class DbWords
61
61
  def split
62
62
  w = @argv.join(" ").split(":")
63
63
  if w.size < 2
64
- pp 'You mast set ":" on word. Like this: "./word -a to run: бежать"'
64
+ pp 'You mast set ":" on word. Like this: "jword -a to run: бежать"'
65
65
  end
66
66
  @words = w.map(&:strip)
67
67
  end
@@ -78,4 +78,9 @@ class DbWords
78
78
  yield(word, idx)
79
79
  end
80
80
  end
81
+
82
+ def create_db
83
+ Dir.mkdir(File.join(Dir.home, DATABASE_DIR), 0700)
84
+ File.new(@file, File::RDWR|File::CREAT, 0644)
85
+ end
81
86
  end
data/lib/jwords/os.rb ADDED
@@ -0,0 +1,18 @@
1
+ module OS
2
+ def windows?
3
+ /cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM
4
+ end
5
+
6
+ def mac?
7
+ /darwin/ =~ RUBY_PLATFORM
8
+ end
9
+
10
+ def unix?
11
+ !OS.windows?
12
+ end
13
+
14
+ def linux?
15
+ OS.unix? and not OS.mac?
16
+ end
17
+ end
18
+
@@ -1,13 +1,23 @@
1
1
  class SayWords
2
+ include OS
2
3
 
3
4
  def initialize(collection, options={})
4
5
  @collection = collection
5
- @show_message = options[:show_message] || true
6
- @space_words = options[:space_words] || 3
7
- @space_interation = options[:space_interation] || 10
6
+ @show_message = options[:show_message] || SHOW_MESSAGE
7
+ @space_words = options[:space_words] || SPACE_WORDS
8
+ @space_interation = options[:space_interation] || SPACE_INTERATION
8
9
  end
9
10
 
10
11
  def run
12
+ if mac?
13
+ do_mac
14
+ elsif linux?
15
+ do_ubuntu
16
+ end
17
+ end
18
+
19
+ private
20
+ def do_ubuntu
11
21
  loop do
12
22
  @collection.each do |word|
13
23
  puts "I say #{word[0]}"
@@ -22,4 +32,21 @@ class SayWords
22
32
  end
23
33
  end
24
34
 
35
+ def do_mac
36
+ loop do
37
+ @collection.each do |word|
38
+ puts "I say #{word[0]}"
39
+ 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
41
+ system 'say "'+ word[0] +'"'
42
+ sleep @space_words
43
+ #puts "I say #{word[1]}"
44
+ system 'say "'+ word[1] +'"'
45
+ sleep @space_interation
46
+ end
47
+ sleep 4 # for notification hiding
48
+ end
49
+
50
+ end
51
+
25
52
  end
@@ -1,3 +1,3 @@
1
1
  module Jwords
2
- VERSION = "0.0.3"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,66 +1,75 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: jumping_words
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
4
5
  prerelease:
5
- version: 0.0.3
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Alex Dmitriev
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2012-01-29 00:00:00 Z
14
- dependencies: []
15
-
16
- description: Jumping Words is gem for learning new words foreign languages, only ubuntu
17
- email:
12
+ date: 2012-09-21 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: terminal-notifier
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ description: Jumping Words is gem for learning new words foreign languages, only Ubuntu
31
+ or MAC OS X(10.8 or higher
32
+ email:
18
33
  - alex@devmen.com
19
- executables:
20
- - jword
34
+ executables:
35
+ - jwords
21
36
  extensions: []
22
-
23
37
  extra_rdoc_files: []
24
-
25
- files:
38
+ files:
26
39
  - .gitignore
27
40
  - Gemfile
28
41
  - README.rdoc
29
42
  - Rakefile
30
- - bin/jword
43
+ - bin/jwords
31
44
  - config.rb
32
- - db/jumping_words.csv
33
45
  - jwords.gemspec
34
46
  - lib/jumping_words.rb
35
47
  - lib/jwords/db_words.rb
48
+ - lib/jwords/os.rb
36
49
  - lib/jwords/say_words.rb
37
50
  - lib/jwords/version.rb
38
51
  homepage: https://github.com/devmen/jumping_words
39
52
  licenses: []
40
-
41
53
  post_install_message:
42
54
  rdoc_options: []
43
-
44
- require_paths:
55
+ require_paths:
45
56
  - lib
46
- required_ruby_version: !ruby/object:Gem::Requirement
57
+ required_ruby_version: !ruby/object:Gem::Requirement
47
58
  none: false
48
- requirements:
49
- - - ">="
50
- - !ruby/object:Gem::Version
51
- version: "0"
52
- required_rubygems_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
64
  none: false
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- version: "0"
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
58
69
  requirements: []
59
-
60
70
  rubyforge_project: jumping_words
61
- rubygems_version: 1.8.15
71
+ rubygems_version: 1.8.24
62
72
  signing_key:
63
73
  specification_version: 3
64
74
  summary: Jumping Words is gem for learning new words foreign languages
65
75
  test_files: []
66
-
data/db/jumping_words.csv DELETED
@@ -1,3 +0,0 @@
1
- skimpy,"скудный, экономный, короткий, скупой"
2
- overview,"обзор, обозрение"
3
- straight,прямой