trecs 0.1.21 → 0.2.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: 808c1efc9acc70084baea5d936c95e2a3a078650
4
- data.tar.gz: ed3f006bdbfc55253124b44ac1db10b2124ee58e
3
+ metadata.gz: 9b6cb65a9817834ddc64593c4ba0904acb887f32
4
+ data.tar.gz: 07272efaeb6bde645cb54150deff7e9fff423143
5
5
  SHA512:
6
- metadata.gz: ab7a530adc8efb82038297fa43adfd5060c74020f6e2abd1129ca59fbe1482ae7cfef6d39877874d1042f43fb7a8fa6150254175156b92270eba6c769fb08249
7
- data.tar.gz: ea03a2b7c38aa1cc271c2348cdb4ca39445c6bfcfdef56615f9de553eb0e4601d7ef82a2eb8e4841db8c94b28e995c0582c92343069d7904cb150f6321dcec47
6
+ metadata.gz: 149f1455fc76a1db2447414a975093dee98f2bd5849255b5b82530be9b8f50d015d3d47defd3d201b7b7e1d3b68cd5344e6b8bdf37dbac42bd2501085f5c31f8
7
+ data.tar.gz: 69059d77a1a0f0c1e09e79e6bc98e4458593f00822777ec9cf6f49f06a3510f8b5eafbc1bb650f631e86d54e90570b625f20f5a6fb035d4d8c18451057221983
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- trecs (0.1.21)
4
+ trecs (0.2.0)
5
5
  minitar (~> 0.5.4)
6
6
  trollop (~> 2.0)
7
7
 
data/bin/trecs CHANGED
@@ -80,7 +80,11 @@ player_options = {
80
80
  }
81
81
 
82
82
 
83
-
83
+ audio_file = Array(source.audio_files).first
84
+ if audio_file
85
+ `notify-send #{audio_file}`
86
+ start_sound_player(audio_file)
87
+ end
84
88
  player = TRecs::Player.new(player_options)
85
89
 
86
90
  if opts[:duration]
@@ -99,3 +103,4 @@ end
99
103
  player.play
100
104
 
101
105
  finish(opts)
106
+ Pathname(source.tmpdir).rmtree
data/bin/trecs_record CHANGED
@@ -19,7 +19,7 @@ opts = Trollop::options do
19
19
  opt :terminal, "Launch terminal", default: true
20
20
  opt :color, "Record colors", default: true
21
21
 
22
- opt :audio, "Record audio", type: String
22
+ opt :audio, "Record audio"
23
23
  end
24
24
  opts[:trecs_backend] = ARGV[0]
25
25
 
@@ -66,12 +66,12 @@ puts "Recording ..."
66
66
 
67
67
  if strategy_class.to_s == "TRecs::TtyrecStrategy" || strategy_class.to_s == "TRecs::TmuxSessionStrategy"
68
68
  opts[:height], opts[:width] = `stty size`.split(" ").map(&:to_i)
69
- opts[:audio] && start_sound_recording(opts[:audio])
69
+ opts[:audio] && start_sound_recording("/tmp/recording.ogg")
70
70
 
71
71
  system "ttyrec #{opts[:input_file]}" if opts[:terminal]
72
72
  end
73
73
 
74
- opts[:audio_files] = [opts[:audio]] if opts[:audio]
74
+ opts[:audio_files] = ["/tmp/recording.ogg"] if opts[:audio]
75
75
 
76
76
  recorder_options = {
77
77
  writer: writer_class.new(opts),
@@ -19,7 +19,7 @@ module TRecs
19
19
  def get_frames
20
20
  frames = {}
21
21
  source.read do
22
- json_string = source.read_file("frames.json")
22
+ json_string = source.read_entry("frames.json") || "{}"
23
23
  parsed_json = JSON.parse(json_string)
24
24
  parsed_json.each do |time, content|
25
25
  frames[Integer(time)] = content
@@ -7,88 +7,11 @@ require "tmpdir"
7
7
  require "pathname"
8
8
  require "yaml"
9
9
 
10
- #module TRecs
11
- # class TgzSource
12
- # include Archive::Tar
13
- #
14
- # def initialize(options={})
15
- # @trecs_backend = options.fetch(:trecs_backend)
16
- # end
17
- #
18
- # def create_recording
19
- # in_tmp_dir do
20
- # @tgz = Zlib::GzipWriter.new(trecs_backend)
21
- #
22
- # yield self if block_given?
23
- #
24
- # create_entry('manifest.yaml') do |f|
25
- # f.write manifest.to_yaml
26
- # end
27
- #
28
- # Minitar.pack(@files_to_add.flatten, @tgz)
29
- # end
30
- # end
31
- #
32
- # # TODO: Este es el punto de intersección entre read y create_recording
33
- # def manifest
34
- # @manifest ||= {}
35
- # end
36
- #
37
- # def []=(key, value)
38
- # manifest[key] = value
39
- # end
40
- #
41
- # def [](key)
42
- # manifest[key]
43
- # end
44
- #
45
- # def read_file(file_name)
46
- # File.read(file_name)
47
- # end
48
- #
49
- # def create_entry(file_name)
50
- # File.open(file_name, File::CREAT|File::TRUNC|File::RDWR, 0644) do |f|
51
- # yield f
52
- # end
53
- # add_file(file_name)
54
- # end
55
- #
56
- # def add_file(file_name)
57
- # @files_to_add ||= []
58
- # @files_to_add << file_name
59
- # end
60
- #
61
- # def add_audio_file(file_name)
62
- # Dir.mkdir("audio") unless File.exist? "audio"
63
- #
64
- # orig_file = file_name
65
- # file_name = "./audio/" + Pathname(file_name).basename.to_s
66
- # FileUtils.symlink(orig_file, file_name)
67
- # add_file(file_name)
68
- # end
69
- #
70
- # private
71
- #
72
- # attr_reader :trecs_backend
73
- #
74
- # #Investigar como hacer para descomprimir en memoria
75
- # def in_tmp_dir
76
- # Dir.mktmpdir("trecs_record") do |dir|
77
- # Dir.chdir(dir) do
78
- # yield
79
- # end
80
- # end
81
- # end
82
- # end
83
- #end
84
- #
85
-
86
10
  module TRecs
87
11
  class TgzSource
88
12
  include Archive::Tar
89
13
 
90
14
  attr_reader :trecs_backend
91
- attr_reader :audio_files
92
15
 
93
16
  def initialize(options={})
94
17
  @trecs_backend = options.fetch(:trecs_backend)
@@ -121,7 +44,7 @@ module TRecs
121
44
  reader = nil
122
45
  options[:source] = self
123
46
  read do |source|
124
- @manifest = YAML.load(source.read_file("manifest.yaml"))
47
+ @manifest = YAML.load(source.read_entry("manifest.yaml"))
125
48
 
126
49
  format = manifest["format"]
127
50
  reader_file = "readers/#{format}_reader"
@@ -139,14 +62,45 @@ module TRecs
139
62
 
140
63
  # Investigar como hacer para descomprimir en memoria
141
64
  def in_tmp_dir
142
- Dir.mktmpdir("trecs_record") do |dir|
143
- Dir.chdir(dir) do
144
- yield
145
- end
65
+ unless tmpdir_exists?
66
+ p tmpdir
67
+ Pathname(tmpdir).mkdir
68
+ end
69
+ Dir.chdir(tmpdir) do
70
+ yield
146
71
  end
147
72
  end
148
73
 
149
- def read_file(file_name)
74
+ def tmpdir_exists?
75
+ tmpdir && Pathname(tmpdir).exist?
76
+ end
77
+
78
+ def finalize
79
+ Pathname(tmpdir).delete if tmpdir_exists?
80
+ end
81
+
82
+ def tmpdir
83
+ @tmpdir ||= generate_tmpdir_name
84
+ end
85
+
86
+ def generate_tmpdir_name
87
+ "#{Dir.tmpdir}/#{timestamp}-#{file_name}"
88
+ end
89
+
90
+ def timestamp
91
+ Time.now.strftime("%Y%M%d%H%m%s")
92
+ end
93
+
94
+ def file_name
95
+ filename = Pathname(trecs_backend)
96
+ filename.basename.to_s.delete(filename.extname)
97
+ name = filename.basename.to_s
98
+ ext = filename.extname
99
+ name[ext] = ""
100
+ name
101
+ end
102
+
103
+ def read_entry(file_name)
150
104
  File.read(file_name)
151
105
  end
152
106
 
@@ -175,6 +129,16 @@ module TRecs
175
129
  manifest[key.to_s] = value
176
130
  end
177
131
 
132
+ def audio_files
133
+ return @audio_files if @audio_files
134
+
135
+ in_tmp_dir do
136
+ (Dir.open(tmpdir + "/audio").entries - %w[. ..]).map { |file|
137
+ Pathname("./audio/" + file).expand_path
138
+ }
139
+
140
+ end
141
+ end
178
142
  private
179
143
 
180
144
  # TODO: Este es el punto de intersección entre read y create_recording
data/lib/trecs/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module TRecs
2
- VERSION = "0.1.21"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trecs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.21
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Federico Iachetti
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-26 00:00:00.000000000 Z
11
+ date: 2014-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: trollop