jumping_words 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/Gemfile +4 -0
- data/README.rdoc +30 -0
- data/Rakefile +1 -0
- data/bin/jword +58 -0
- data/config.rb +8 -0
- data/db/jumping_words.csv +3 -0
- data/jwords.gemspec +24 -0
- data/lib/jumping_words.rb +5 -0
- data/lib/jwords/db_words.rb +81 -0
- data/lib/jwords/say_words.rb +25 -0
- data/lib/jwords/version.rb +3 -0
- metadata +66 -0
data/Gemfile
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
= Jumping Words
|
2
|
+
Программа для Ubuntu произносит и выводит в поп-ап окне слово(фразу), а затем переводимое слово(фразу).
|
3
|
+
|
4
|
+
== Зависимости
|
5
|
+
sudo apt-get install libnotify-bin
|
6
|
+
|
7
|
+
== Дейсвия
|
8
|
+
Запуск
|
9
|
+
./word -s
|
10
|
+
|
11
|
+
Просмотр списка слов
|
12
|
+
./word -l
|
13
|
+
|
14
|
+
1 to write: писать
|
15
|
+
2 root: корень
|
16
|
+
3 list: список
|
17
|
+
...
|
18
|
+
|
19
|
+
Добавление слов в базу
|
20
|
+
./word -a root: корень
|
21
|
+
./word -a to game: играть
|
22
|
+
|
23
|
+
Удаление слова из базы(указывается индекс слова)
|
24
|
+
./word -d 1
|
25
|
+
./word -d 1 2
|
26
|
+
|
27
|
+
== Установка
|
28
|
+
|
29
|
+
git clone git://github.com/devmen/jumping_words.git
|
30
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/jword
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
require 'optparse'
|
4
|
+
require 'pp'
|
5
|
+
|
6
|
+
$:.push File.expand_path("../../lib", __FILE__)
|
7
|
+
require 'jumping_words'
|
8
|
+
|
9
|
+
options = {}
|
10
|
+
optparse = OptionParser.new do|opts|
|
11
|
+
|
12
|
+
#The command addes a word
|
13
|
+
opts.on( '-a', '--add', 'Add the word' ) do
|
14
|
+
if ARGV.empty? or ARGV.size < 2
|
15
|
+
puts 'You mast set 2 words! Firs is word, second is translate. Like this: "./word -a to run: бежать"'
|
16
|
+
exit
|
17
|
+
else
|
18
|
+
db = DbWords.new(ARGV)
|
19
|
+
db.add
|
20
|
+
exit
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
#The command deletes a word
|
25
|
+
opts.on( '-d', '--destroy', 'Delete the word' ) do
|
26
|
+
if ARGV.empty?
|
27
|
+
puts 'You mast set number of word!'
|
28
|
+
exit
|
29
|
+
else
|
30
|
+
db = DbWords.new(ARGV)
|
31
|
+
db.destroy
|
32
|
+
exit
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
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(db.collection, :show_message => SHOW_MESSAGE, :space_words => SPACE_WORDS, :space_interation => SPACE_INTERATION)
|
47
|
+
|
48
|
+
begin
|
49
|
+
app.run
|
50
|
+
rescue Interrupt
|
51
|
+
puts "Exiting..."
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
optparse.parse!
|
58
|
+
|
data/config.rb
ADDED
data/jwords.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "jwords/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "jumping_words"
|
7
|
+
s.version = Jwords::VERSION
|
8
|
+
s.authors = ["Alex Dmitriev"]
|
9
|
+
s.email = ["alex@devmen.com"]
|
10
|
+
s.homepage = ""
|
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}
|
13
|
+
|
14
|
+
s.rubyforge_project = "jumping_words"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
# specify any dependencies here; for example:
|
22
|
+
# s.add_development_dependency "rspec"
|
23
|
+
# s.add_runtime_dependency "rest-client"
|
24
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'csv'
|
4
|
+
class DbWords
|
5
|
+
attr_reader :words
|
6
|
+
|
7
|
+
def initialize(argv=nil)
|
8
|
+
@argv = argv
|
9
|
+
@words = Array.new
|
10
|
+
|
11
|
+
@file = File.dirname(__FILE__) + "/../../db/" + DATABASE + ".csv"
|
12
|
+
end
|
13
|
+
|
14
|
+
#collecion of words
|
15
|
+
def collection
|
16
|
+
col = CSV.read(@file)
|
17
|
+
col
|
18
|
+
end
|
19
|
+
|
20
|
+
#adding word in db
|
21
|
+
def add
|
22
|
+
split
|
23
|
+
if double?
|
24
|
+
puts "You have '#{@words[0]}' in database"
|
25
|
+
exit
|
26
|
+
end
|
27
|
+
|
28
|
+
CSV.open(@file, "a") do |csv|
|
29
|
+
csv << [@words[0], @words[1]]
|
30
|
+
end
|
31
|
+
puts "Word is added"
|
32
|
+
end
|
33
|
+
|
34
|
+
#Destroy a word from db file
|
35
|
+
def destroy
|
36
|
+
list_w = collection
|
37
|
+
@argv.map(&:to_i).each do |i|
|
38
|
+
list_w.delete_at(i-1)
|
39
|
+
end
|
40
|
+
|
41
|
+
CSV.open(@file, "w") do |csv|
|
42
|
+
list_w.each do |row|
|
43
|
+
csv << row
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
puts @argv.join(" ") + " deleted"
|
48
|
+
list
|
49
|
+
end
|
50
|
+
|
51
|
+
#Print the list of words
|
52
|
+
def list
|
53
|
+
list_of_words do |word, idx|
|
54
|
+
puts "#{idx + 1} #{word[0]}: #{word[1]}"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
# input is ["to", "run:", "бежать"]
|
60
|
+
# output is ["to run", "бежать"]
|
61
|
+
def split
|
62
|
+
w = @argv.join(" ").split(":")
|
63
|
+
if w.size < 2
|
64
|
+
pp 'You mast set ":" on word. Like this: "./word -a to run: бежать"'
|
65
|
+
end
|
66
|
+
@words = w.map(&:strip)
|
67
|
+
end
|
68
|
+
|
69
|
+
#return true if have double in db
|
70
|
+
def double?
|
71
|
+
w = @words.first
|
72
|
+
list = collection
|
73
|
+
list.map(&:first).include?( w )
|
74
|
+
end
|
75
|
+
|
76
|
+
def list_of_words
|
77
|
+
collection.each_with_index do |word, idx|
|
78
|
+
yield(word, idx)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class SayWords
|
2
|
+
|
3
|
+
def initialize(collection, options={})
|
4
|
+
@collection = collection
|
5
|
+
@show_message = options[:show_message] || true
|
6
|
+
@space_words = options[:space_words] || 3
|
7
|
+
@space_interation = options[:space_interation] || 10
|
8
|
+
end
|
9
|
+
|
10
|
+
def run
|
11
|
+
loop do
|
12
|
+
@collection.each do |word|
|
13
|
+
puts "I say #{word[0]}"
|
14
|
+
system 'notify-send -i /usr/share/pixmaps/gnome-irc.png "'+ word[0] +'" "'+ word[1] +'" -t 1' if @show_message
|
15
|
+
system 'espeak -v en -s120 "'+ word[0] +'"'
|
16
|
+
sleep @space_words
|
17
|
+
#puts "I say #{word[1]}"
|
18
|
+
system 'espeak -v ru -s120 "'+ word[1] +'"'
|
19
|
+
sleep @space_interation
|
20
|
+
end
|
21
|
+
sleep 4 # for notification hiding
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jumping_words
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.2
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Alex Dmitriev
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
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:
|
18
|
+
- alex@devmen.com
|
19
|
+
executables:
|
20
|
+
- jword
|
21
|
+
extensions: []
|
22
|
+
|
23
|
+
extra_rdoc_files: []
|
24
|
+
|
25
|
+
files:
|
26
|
+
- .gitignore
|
27
|
+
- Gemfile
|
28
|
+
- README.rdoc
|
29
|
+
- Rakefile
|
30
|
+
- bin/jword
|
31
|
+
- config.rb
|
32
|
+
- db/jumping_words.csv
|
33
|
+
- jwords.gemspec
|
34
|
+
- lib/jumping_words.rb
|
35
|
+
- lib/jwords/db_words.rb
|
36
|
+
- lib/jwords/say_words.rb
|
37
|
+
- lib/jwords/version.rb
|
38
|
+
homepage: ""
|
39
|
+
licenses: []
|
40
|
+
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options: []
|
43
|
+
|
44
|
+
require_paths:
|
45
|
+
- lib
|
46
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
+
none: false
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: "0"
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: "0"
|
58
|
+
requirements: []
|
59
|
+
|
60
|
+
rubyforge_project: jumping_words
|
61
|
+
rubygems_version: 1.8.15
|
62
|
+
signing_key:
|
63
|
+
specification_version: 3
|
64
|
+
summary: Jumping Words is gem for learning new words foreign languages
|
65
|
+
test_files: []
|
66
|
+
|