dephine 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -22,6 +22,11 @@ Google dictionary in terminal
22
22
  anything
23
23
 
24
24
  pronoun /ˈenēˌTHiNG/
25
+ Used to refer to a thing, no matter what
26
+ - nobody was saying anything
27
+ - have you found anything?
28
+ - he inquired whether there was anything he could do
29
+
25
30
  Used for emphasis
26
31
  - I was ready for anything
27
32
 
@@ -17,4 +17,5 @@ Gem::Specification.new do |gem|
17
17
  gem.require_paths = ["lib"]
18
18
 
19
19
  gem.add_dependency 'ncursesw', '~> 1.2.4'
20
+ gem.add_dependency 'open-uri-cached'
20
21
  end
@@ -2,3 +2,6 @@ require 'dephine/version'
2
2
  require 'dephine/dictionary'
3
3
  require 'dephine/cli'
4
4
  require 'dephine/tui'
5
+
6
+ # set cache path
7
+ OpenURI::Cache.cache_path = File.join(ENV['HOME'], '.dephine')
@@ -1,5 +1,3 @@
1
- require 'tempfile'
2
-
3
1
  module Dephine
4
2
 
5
3
  # Public: Make a simple Command Line Interface.
@@ -75,20 +73,13 @@ module Dephine
75
73
  end
76
74
 
77
75
  if word.pronunciations.length > 0
78
- # create tempfile
79
- file = Tempfile.new('temp-pronunciation.mp3')
80
-
81
- # download pronunciation mp3 and save to tempfile
82
- File.open(file, "wb") do |saved_file|
83
- open(word.pronunciations[0][:url], 'rb') do |read_file|
84
- saved_file.write(read_file.read)
85
- end
86
- end
87
- file.close()
76
+ # download pronunciation audio file
77
+ open(word.pronunciations[0][:url])
78
+ pronunciation = OpenURI::Cache.send(:filename_from_url, word.pronunciations[0][:url])
88
79
 
89
- # play tempfile
80
+ # play pronunciation
90
81
  t.set_key 'p' do
91
- play(file.path)
82
+ play(pronunciation)
92
83
  end
93
84
  end
94
85
 
@@ -1,4 +1,4 @@
1
- require 'open-uri'
1
+ require 'open-uri/cached'
2
2
  require 'json'
3
3
 
4
4
  module Dephine
@@ -37,7 +37,7 @@ module Dephine
37
37
  end
38
38
 
39
39
  # add meanings
40
- primary['entries'][1..-1].each do |entry|
40
+ primary['entries'].each do |entry|
41
41
  @meanings[-1][:meanings] << {
42
42
  text: entry['terms'][0]['text'].gsub('x27', "'") \
43
43
  .gsub(/x3.*?3e/, ''),
@@ -122,9 +122,6 @@ module Dephine
122
122
  when @callbacks[c]
123
123
  true
124
124
 
125
- else
126
- @screen.move(0, 0)
127
- @screen.addstr("[unknown key `#{Ncurses.keyname(c)}'=#{c}] ")
128
125
  end
129
126
 
130
127
  @screen.move(0, 0)
@@ -1,3 +1,3 @@
1
1
  module Dephine
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dephine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
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: 2013-02-02 00:00:00.000000000 Z
12
+ date: 2013-02-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ncursesw
@@ -27,6 +27,22 @@ dependencies:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
29
  version: 1.2.4
30
+ - !ruby/object:Gem::Dependency
31
+ name: open-uri-cached
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
30
46
  description:
31
47
  email:
32
48
  - contact@s1n4.com