wahwah 0.1.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +21 -0
  3. data/lib/wahwah.rb +74 -3
  4. data/lib/wahwah/asf/object.rb +39 -0
  5. data/lib/wahwah/asf_tag.rb +220 -0
  6. data/lib/wahwah/errors.rb +6 -0
  7. data/lib/wahwah/flac/block.rb +57 -0
  8. data/lib/wahwah/flac/streaminfo_block.rb +51 -0
  9. data/lib/wahwah/flac_tag.rb +84 -0
  10. data/lib/wahwah/helper.rb +37 -0
  11. data/lib/wahwah/id3/comment_frame_body.rb +21 -0
  12. data/lib/wahwah/id3/frame.rb +180 -0
  13. data/lib/wahwah/id3/frame_body.rb +36 -0
  14. data/lib/wahwah/id3/genre_frame_body.rb +15 -0
  15. data/lib/wahwah/id3/image_frame_body.rb +60 -0
  16. data/lib/wahwah/id3/text_frame_body.rb +16 -0
  17. data/lib/wahwah/id3/v1.rb +96 -0
  18. data/lib/wahwah/id3/v2.rb +60 -0
  19. data/lib/wahwah/id3/v2_header.rb +53 -0
  20. data/lib/wahwah/mp3/mpeg_frame_header.rb +141 -0
  21. data/lib/wahwah/mp3/vbri_header.rb +47 -0
  22. data/lib/wahwah/mp3/xing_header.rb +45 -0
  23. data/lib/wahwah/mp3_tag.rb +110 -0
  24. data/lib/wahwah/mp4/atom.rb +105 -0
  25. data/lib/wahwah/mp4_tag.rb +126 -0
  26. data/lib/wahwah/ogg/flac_tag.rb +37 -0
  27. data/lib/wahwah/ogg/opus_tag.rb +33 -0
  28. data/lib/wahwah/ogg/packets.rb +41 -0
  29. data/lib/wahwah/ogg/page.rb +121 -0
  30. data/lib/wahwah/ogg/pages.rb +24 -0
  31. data/lib/wahwah/ogg/vorbis_comment.rb +51 -0
  32. data/lib/wahwah/ogg/vorbis_tag.rb +35 -0
  33. data/lib/wahwah/ogg_tag.rb +66 -0
  34. data/lib/wahwah/riff/chunk.rb +54 -0
  35. data/lib/wahwah/riff_tag.rb +140 -0
  36. data/lib/wahwah/tag.rb +59 -0
  37. data/lib/wahwah/tag_delegate.rb +16 -0
  38. data/lib/wahwah/version.rb +4 -2
  39. metadata +94 -23
  40. data/.gitignore +0 -8
  41. data/.travis.yml +0 -5
  42. data/Gemfile +0 -6
  43. data/Gemfile.lock +0 -22
  44. data/README.md +0 -35
  45. data/Rakefile +0 -10
  46. data/bin/console +0 -14
  47. data/bin/setup +0 -8
  48. data/wahwah.gemspec +0 -27
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WahWah
4
+ class Tag
5
+ INTEGER_ATTRIBUTES = %i(disc disc_total track track_total)
6
+ INSPECT_ATTRIBUTES = %i(title artist album albumartist composer track track_total genre year disc disc_total duration bitrate sample_rate)
7
+
8
+ attr_reader(
9
+ :title,
10
+ :artist,
11
+ :album,
12
+ :albumartist,
13
+ :composer,
14
+ :comments,
15
+ :track,
16
+ :track_total,
17
+ :genre,
18
+ :year,
19
+ :disc,
20
+ :disc_total,
21
+ :images,
22
+ :duration,
23
+ :bitrate,
24
+ :sample_rate,
25
+ :file_size
26
+ )
27
+
28
+ def initialize(file)
29
+ if file.is_a?(IO) || file.is_a?(StringIO)
30
+ @file_size = file.size
31
+ @file_io = file
32
+ else
33
+ @file_size = File.size(file)
34
+ @file_io = File.open(file)
35
+ end
36
+
37
+ @comments = []
38
+ @images = []
39
+
40
+ parse if @file_size > 0
41
+
42
+ INTEGER_ATTRIBUTES.each do |attr_name|
43
+ value = instance_variable_get("@#{attr_name}")&.to_i
44
+ instance_variable_set("@#{attr_name}", value)
45
+ end
46
+ end
47
+
48
+ def parse
49
+ raise WahWahNotImplementedError, 'The parse method is not implemented'
50
+ end
51
+
52
+ def inspect
53
+ inspect_id = ::Kernel.format '%x', (object_id * 2)
54
+ inspect_attributes_values = INSPECT_ATTRIBUTES.map { |attr_name| "#{attr_name}=#{self.send(attr_name)}" }.join(' ')
55
+
56
+ "<#{self.class.name}:0x#{inspect_id} #{inspect_attributes_values}>"
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WahWah
4
+ module TagDelegate
5
+ def tag_delegate(accessor, *attributes)
6
+ attributes.each do |attr|
7
+ define_method(attr) do
8
+ tag = instance_variable_get(accessor)
9
+
10
+ return super() if tag.nil?
11
+ tag.send(attr)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -1,3 +1,5 @@
1
- module Wahwah
2
- VERSION = "0.1.0"
1
+ # frozen_string_literal: true
2
+
3
+ module WahWah
4
+ VERSION = '1.0.0'
3
5
  end
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wahwah
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - aidewoode
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-12 00:00:00.000000000 Z
11
+ date: 2020-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.16'
19
+ version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1.16'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '13.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '13.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: minitest
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -52,26 +52,97 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '5.0'
55
- description: complete later
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.80.1
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.80.1
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop-performance
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 1.5.2
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 1.5.2
83
+ - !ruby/object:Gem::Dependency
84
+ name: codecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.1.17
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.1.17
97
+ description: WahWah is an audio metadata reader ruby gem, it supports many popular
98
+ formats including mp3(ID3 v1, v2.2, v2.3, v2.4), m4a, ogg, oga, opus, wav, flac
99
+ and wma.
56
100
  email:
57
101
  - aidewoode@gmail.com
58
102
  executables: []
59
103
  extensions: []
60
104
  extra_rdoc_files: []
61
105
  files:
62
- - ".gitignore"
63
- - ".travis.yml"
64
- - Gemfile
65
- - Gemfile.lock
66
- - README.md
67
- - Rakefile
68
- - bin/console
69
- - bin/setup
106
+ - LICENSE
70
107
  - lib/wahwah.rb
108
+ - lib/wahwah/asf/object.rb
109
+ - lib/wahwah/asf_tag.rb
110
+ - lib/wahwah/errors.rb
111
+ - lib/wahwah/flac/block.rb
112
+ - lib/wahwah/flac/streaminfo_block.rb
113
+ - lib/wahwah/flac_tag.rb
114
+ - lib/wahwah/helper.rb
115
+ - lib/wahwah/id3/comment_frame_body.rb
116
+ - lib/wahwah/id3/frame.rb
117
+ - lib/wahwah/id3/frame_body.rb
118
+ - lib/wahwah/id3/genre_frame_body.rb
119
+ - lib/wahwah/id3/image_frame_body.rb
120
+ - lib/wahwah/id3/text_frame_body.rb
121
+ - lib/wahwah/id3/v1.rb
122
+ - lib/wahwah/id3/v2.rb
123
+ - lib/wahwah/id3/v2_header.rb
124
+ - lib/wahwah/mp3/mpeg_frame_header.rb
125
+ - lib/wahwah/mp3/vbri_header.rb
126
+ - lib/wahwah/mp3/xing_header.rb
127
+ - lib/wahwah/mp3_tag.rb
128
+ - lib/wahwah/mp4/atom.rb
129
+ - lib/wahwah/mp4_tag.rb
130
+ - lib/wahwah/ogg/flac_tag.rb
131
+ - lib/wahwah/ogg/opus_tag.rb
132
+ - lib/wahwah/ogg/packets.rb
133
+ - lib/wahwah/ogg/page.rb
134
+ - lib/wahwah/ogg/pages.rb
135
+ - lib/wahwah/ogg/vorbis_comment.rb
136
+ - lib/wahwah/ogg/vorbis_tag.rb
137
+ - lib/wahwah/ogg_tag.rb
138
+ - lib/wahwah/riff/chunk.rb
139
+ - lib/wahwah/riff_tag.rb
140
+ - lib/wahwah/tag.rb
141
+ - lib/wahwah/tag_delegate.rb
71
142
  - lib/wahwah/version.rb
72
- - wahwah.gemspec
73
143
  homepage: https://github.com/aidewoode
74
- licenses: []
144
+ licenses:
145
+ - MIT
75
146
  metadata: {}
76
147
  post_install_message:
77
148
  rdoc_options: []
@@ -81,7 +152,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
81
152
  requirements:
82
153
  - - ">="
83
154
  - !ruby/object:Gem::Version
84
- version: '0'
155
+ version: 2.5.0
85
156
  required_rubygems_version: !ruby/object:Gem::Requirement
86
157
  requirements:
87
158
  - - ">="
@@ -89,8 +160,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
160
  version: '0'
90
161
  requirements: []
91
162
  rubyforge_project:
92
- rubygems_version: 2.7.6
163
+ rubygems_version: 2.7.6.2
93
164
  signing_key:
94
165
  specification_version: 4
95
- summary: complete later
166
+ summary: Audio metadata reader ruby gem
96
167
  test_files: []
data/.gitignore DELETED
@@ -1,8 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
@@ -1,5 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- rvm:
4
- - 2.4.1
5
- before_install: gem install bundler -v 1.16.1
data/Gemfile DELETED
@@ -1,6 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
-
5
- # Specify your gem's dependencies in wahwah.gemspec
6
- gemspec
@@ -1,22 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- wahwah (0.1.0)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- minitest (5.11.3)
10
- rake (10.5.0)
11
-
12
- PLATFORMS
13
- ruby
14
-
15
- DEPENDENCIES
16
- bundler (~> 1.16)
17
- minitest (~> 5.0)
18
- rake (~> 10.0)
19
- wahwah!
20
-
21
- BUNDLED WITH
22
- 1.16.1
data/README.md DELETED
@@ -1,35 +0,0 @@
1
- # Wahwah
2
-
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/wahwah`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
6
-
7
- ## Installation
8
-
9
- Add this line to your application's Gemfile:
10
-
11
- ```ruby
12
- gem 'wahwah'
13
- ```
14
-
15
- And then execute:
16
-
17
- $ bundle
18
-
19
- Or install it yourself as:
20
-
21
- $ gem install wahwah
22
-
23
- ## Usage
24
-
25
- TODO: Write usage instructions here
26
-
27
- ## Development
28
-
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
-
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
-
33
- ## Contributing
34
-
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/wahwah.
data/Rakefile DELETED
@@ -1,10 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rake/testtask"
3
-
4
- Rake::TestTask.new(:test) do |t|
5
- t.libs << "test"
6
- t.libs << "lib"
7
- t.test_files = FileList["test/**/*_test.rb"]
8
- end
9
-
10
- task :default => :test
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "wahwah"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
@@ -1,27 +0,0 @@
1
-
2
- lib = File.expand_path("../lib", __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "wahwah/version"
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "wahwah"
8
- spec.version = Wahwah::VERSION
9
- spec.authors = ["aidewoode"]
10
- spec.email = ["aidewoode@gmail.com"]
11
-
12
- spec.summary = 'complete later'
13
- spec.description = 'complete later'
14
- spec.homepage = 'https://github.com/aidewoode'
15
-
16
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
- f.match(%r{^(test|spec|features)/})
18
- end
19
-
20
- spec.bindir = "exe"
21
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
- spec.require_paths = ["lib"]
23
-
24
- spec.add_development_dependency "bundler", "~> 1.16"
25
- spec.add_development_dependency "rake", "~> 10.0"
26
- spec.add_development_dependency "minitest", "~> 5.0"
27
- end