From: Michael D. Lowis Date: Wed, 27 Dec 2023 04:38:35 +0000 (-0500) Subject: initial commit X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=158caa91bd0450cb5bde32b1311ddfd4803dd16e;p=proto%2Fatv.git initial commit --- diff --git a/atv/.gitignore b/atv/.gitignore new file mode 100644 index 0000000..5b4c009 --- /dev/null +++ b/atv/.gitignore @@ -0,0 +1,9 @@ +/pkg +/lib_gpkg +/Gemfile +/.gpkg* +/.yardoc +/coverage +/rdocs +/doc +/tags diff --git a/atv/Gemfile.lock b/atv/Gemfile.lock new file mode 100644 index 0000000..43c1815 --- /dev/null +++ b/atv/Gemfile.lock @@ -0,0 +1,54 @@ +GEM + remote: https://rubygems.org/ + specs: + diff-lcs (1.5.0) + docile (1.4.0) + gentex-gems-teamcity_utils (1.13.2) + nokogiri (~> 1.6) + rexml (~> 3.0) + gentex-gpkg (1.29.0) + bundler + rexml (~> 3.0) + yawpa (~> 1.1) + json (2.7.1) + nokogiri (1.13.8-x86_64-linux) + racc (~> 1.4) + racc (1.6.0) + rake (13.1.0) + rexml (3.2.5) + rspec (3.12.0) + rspec-core (~> 3.12.0) + rspec-expectations (~> 3.12.0) + rspec-mocks (~> 3.12.0) + rspec-core (3.12.2) + rspec-support (~> 3.12.0) + rspec-expectations (3.12.3) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.12.0) + rspec-mocks (3.12.6) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.12.0) + rspec-support (3.12.1) + simplecov (0.22.0) + docile (~> 1.1) + simplecov-html (~> 0.11) + simplecov_json_formatter (~> 0.1) + simplecov-html (0.12.3) + simplecov_json_formatter (0.1.4) + yard (0.9.34) + yawpa (1.3.0) + +PLATFORMS + x86_64-linux + +DEPENDENCIES + gentex-gems-teamcity_utils (~> 1.3) + gentex-gpkg (>= 1.16, < 99.0) + json (~> 2.0) + rake (~> 13.0) + rspec (~> 3.0) + simplecov (~> 0.9) + yard (~> 0.9) + +BUNDLED WITH + 2.4.7 diff --git a/atv/Rakefile.rb b/atv/Rakefile.rb new file mode 100644 index 0000000..db1be3b --- /dev/null +++ b/atv/Rakefile.rb @@ -0,0 +1,63 @@ +require "bundler" +begin + Bundler.setup(:default, :development) +rescue Bundler::BundlerError => e + raise LoadError.new("Unable to Bundler.setup(): You probably need to run `gpkg install`: #{e.message}") +end + +require "rake/clean" +require "gpkg/rake_tasks" +require "rspec" +require "rspec/core/rake_task" +require "yard" +require "simplecov" +require "json" +require "gentex/gems/teamcity_utils" + +CLEAN.include "pkg" +CLEAN.include "coverage" +CLOBBER.include ".yardoc" +CLOBBER.include "doc" + +task :default => :spec + +RSpec::Core::RakeTask.new(:spec, :example_string) do |task, args| + if args.example_string + ENV["partial_specs"] = "1" + task.rspec_opts = %[-e "#{args.example_string}" -f documentation] + end +end + +task :spec do + # Report coverage % to TeamCity + if Gentex::Gems::TeamcityUtils.server_exec? + begin + cov_pct = JSON.load(File.read("coverage/.last_run.json"))["result"]["line"] + Gentex::Gems::TeamcityUtils.append_build_status(" (cov: #{cov_pct}%)") + rescue Exception => e + $stderr.puts "Error reporting coverage: #{e.message}" + end + end +end + +YARD::Rake::YardocTask.new do |yard| + yard.options = ["--private", "--title", "atv gem"] + yard.files = ["lib/**/*.rb"] +end +# Display undocumented items. +task :yard do + yard_status_output = IO.popen(%w[yard stats --private --list-undoc]) do |io| + io.read + end + if undocumented = yard_status_output[/Undocumented Objects:.*/m] + $stderr.puts undocumented + end +end + +task :build_pkg => :yard + +task :teamcity => [ + :spec, + :yard, + :build_pkg, +] diff --git a/atv/atv.gemspec b/atv/atv.gemspec new file mode 100644 index 0000000..1090831 --- /dev/null +++ b/atv/atv.gemspec @@ -0,0 +1,30 @@ +# -*- encoding: utf-8 -*- +require "gpkg/gem_specification" +lib = File.expand_path("../lib", __FILE__) +$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) +require "gentex/gems/atv/version" + +Gpkg.gem_specification do |gpkg| + gpkg.name = "gems/atv" + gpkg.version = Gentex::Gems::Atv::VERSION + gpkg.authors = ["TODO: Write your name"] + gpkg.email = ["TODO: Write your email address"] + gpkg.summary = %q{TODO: Write a short summary. Required.} + gpkg.description = %q{TODO: Write a longer description. Optional.} + gpkg.homepage = "" + gpkg.licenses = ["Nonstandard"] + + gpkg.files = Dir.glob(["{bin,assets,lib,doc}/**/*", "*.gemspec"]).select {|f| File.file?(f)} + + gpkg.executables = gpkg.files.grep(%r{^bin/}).map{ |f| File.basename(f) } + gpkg.test_files = gpkg.files.grep(%r{^(test|spec|features)/}) + gpkg.require_paths = ["lib"] + + gpkg.add_gpkg_dependency "gpkg", ">= 1.16", "< 99.0" + gpkg.add_gpkg_development_dependency "gems/teamcity_utils", "~> 1.3" + gpkg.add_development_dependency "json", "~> 2.0" + gpkg.add_development_dependency "rspec", "~> 3.0" + gpkg.add_development_dependency "simplecov", "~> 0.9" + gpkg.add_development_dependency "yard", "~> 0.9" + gpkg.add_development_dependency "rake", "~> 13.0" +end diff --git a/atv/gpkgfile b/atv/gpkgfile new file mode 100644 index 0000000..e0a7662 --- /dev/null +++ b/atv/gpkgfile @@ -0,0 +1 @@ +gemspec diff --git a/atv/lib/database.rb b/atv/lib/database.rb new file mode 100644 index 0000000..3b66f4d --- /dev/null +++ b/atv/lib/database.rb @@ -0,0 +1,47 @@ +class Database + CMD="ffprobe -show_entries format=duration -v quiet -of csv=\"p=0\" -i" + + def initialize(root) + @root = root + @path = "#{root}/index.json" + @data = {} + load(path) + end + + def load(path) + if File.exist? @path + @data = JSON.parse(File.read(@path)) + end + end + + def save() + File.open(@path, "wb") do |f| + f.write JSON.dump(@data) + end + end + + def reload() + end + + def files + @data.keys + end + + def [](key) + @data[key] + end + + def cleanup() + files.each do |f| + @db.delete(f) if not File.exist?(f) + end + end + + def scan() + Dir.glob("#{@path}/**/*.{mp4,webm,ogg}").each do |f| + next if @data[f] + duration = `#{CMD} \"#{f}\"`.chomp.to_f + @data[f] = { "duration" => duration } + end + end +end diff --git a/atv/spec/spec_helper.rb b/atv/spec/spec_helper.rb new file mode 100644 index 0000000..f60708e --- /dev/null +++ b/atv/spec/spec_helper.rb @@ -0,0 +1,15 @@ +require "simplecov" + +#require all of the support files! +Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each {|f| require f} + +SimpleCov.start do + add_filter "/spec/" + if ENV["partial_specs"] + command_name "RSpec-partial" + else + command_name "RSpec" + end +end + +require "gentex/gems/atv"