series_reminder 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 500a7a51a22c09672e6ca014bba57f0c9448d3b1
4
+ data.tar.gz: 428c6589c42be636e38b3e5e7613e3b423b475ac
5
+ SHA512:
6
+ metadata.gz: cc44bf0e2e2e86e0dd88b2d911bf71bc8eb72196d21d8f82e8d74075108545abb9add2dd79cbaaa88291bffa74c3e430e11b5338ff9de5af136341ab712ebd74
7
+ data.tar.gz: 1eeff14b92f1599b29d327a7981a05dc97435bb515f8759f0991faf6e12f64efb3b2f306240a71cb2795df07a23baac5bab5e9e470ad85c7d477eb49d019bb6b
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.1
5
+ before_install: gem install bundler -v 1.15.4
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at nightterror@protonmail.ch. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ group(:development) do
6
+ gem "rake"
7
+ end
8
+
9
+ # Specify your gem's dependencies in series_reminder.gemspec
10
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 relmay
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,61 @@
1
+ # Series Reminder
2
+
3
+ ## Installation
4
+
5
+ Install it from rubygems:
6
+
7
+ $ gem install series_reminder
8
+
9
+ Or, get the source and install it:
10
+ ```
11
+ $ git clone https://github.com/relmay/series_reminder
12
+ $ bundle install
13
+ $ bundle exec rake install
14
+ ```
15
+ ## Usage
16
+ Go to the directory where the files are located for viewing, and run the following command:
17
+
18
+ $ series -n
19
+
20
+ This command should start playing the next series. If you don't use the mpv videoplayer, then you need to [specify your videoplayer in the config file](https://github.com/relmay/series_reminder/wiki/Configuring#videoplayer-execution-command).
21
+
22
+ If the standard regular expression does not work with your files, then you can easily fix it by following the [instructions](https://github.com/relmay/series_reminder/wiki/Creating-regular-expressions-for-series_reminder#the-easiest-way-to-write-a-regular-expression).
23
+
24
+ If you want to set custom regex to search for a file of the specified series in this directory:
25
+
26
+ **Notice** that `%%SERIES%%` will be replaced with current series
27
+
28
+ $ series -r "[eE]%%SERIES%%"
29
+
30
+ For more information on creating regular expressions for series_reminder, visit the [wiki page]()
31
+
32
+ Launching the selected series:
33
+
34
+ $ series -s 5
35
+
36
+ To show the number of the last viewed series:
37
+
38
+ $ series -l
39
+
40
+ The rest of the functions can be found in the project [wiki](https://github.com/relmay/series_reminder/wiki).
41
+
42
+ There is also the option of configuring the application. Information about this can be found on the [wiki page](https://github.com/relmay/series_reminder/wiki/config).
43
+
44
+
45
+ ## Development
46
+
47
+ You can run `bin/console` for an interactive prompt that will allow you to experiment.
48
+
49
+ To install this gem onto your local machine, run `bundle exec rake install`.
50
+
51
+ ## Contributing
52
+
53
+ Bug reports and pull requests are welcome on GitHub at https://github.com/relmay/series_reminder. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
54
+
55
+ ## License
56
+
57
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
58
+
59
+ ## Code of Conduct
60
+
61
+ Everyone interacting in the SeriesReminder project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/relmay/series_reminder/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ task :install do
2
+ system "gem build series_reminder*.gemspec"
3
+ system "gem install series_reminder*.gem"
4
+
5
+ puts "Gem was installed"
6
+ end
data/bin/series ADDED
@@ -0,0 +1,42 @@
1
+ #!/bin/ruby
2
+
3
+ require 'series_reminder'
4
+ require 'optparse'
5
+
6
+ series = SeriesReminder::Series.new
7
+
8
+ OptionParser.new do |opts|
9
+ opts.banner = 'Series reminder ' + SeriesReminder::VERSION
10
+
11
+ opts.on('-o', '--open-series [SERIES]', Integer, 'Open the specified series.') do |s|
12
+ series.open_series(s)
13
+ end
14
+
15
+ opts.on('-c', '--config [FILE]', String, 'Read config from file.') do |s|
16
+ series.open_config_file(s)
17
+ end
18
+
19
+ opts.on('-s', '--set-series [SERIES]', String, 'Set last series.') do |s|
20
+ series.set_last_series(s)
21
+ end
22
+
23
+ opts.on('-r', '--set-regex [REGEX]', String, 'Set custom regex.') do |s|
24
+ series.set_regexp(s)
25
+ end
26
+
27
+ opts.on('-n', '--next-series', 'Open next series.') do
28
+ series.open_next
29
+ end
30
+
31
+ opts.on('-l', '--show-last', 'Show number of last viewed series.') do
32
+ puts "Number of last viewed series: #{series.get_last_series}"
33
+ end
34
+
35
+ opts.on('-i', '--init', 'Init program here.') do
36
+ series.init_storage()
37
+ end
38
+
39
+ opts.on('-v', '--version', 'Show version of program.') do
40
+ puts "Series Reminder " + SeriesReminder::VERSION
41
+ end
42
+ end.parse!
data/lib/.series ADDED
@@ -0,0 +1 @@
1
+ 0
@@ -0,0 +1,40 @@
1
+ require 'yaml'
2
+ require 'singleton'
3
+
4
+ class Config
5
+ include Singleton
6
+
7
+ attr_reader :config
8
+
9
+ DEFAULT_CONFIG = {
10
+ "videoplayer_exec" => "mpv",
11
+ "default_regex" => "[Ee]%%SERIES%%",
12
+ "series_filename" => ".series",
13
+ "magic_word" => "%%SERIES%%"
14
+ }
15
+
16
+ def initialize()
17
+ load_config_file!(File.join(Dir.home, ".config/series_reminder/config.yml"))
18
+ end
19
+
20
+
21
+ def load_config_file!(config_location)
22
+ @config = YAML::load_file(config_location)
23
+
24
+ if (@config == false)
25
+ @config = DEFAULT_CONFIG
26
+ else
27
+ complete_with_default_config!
28
+ end
29
+ rescue Errno::ENOENT
30
+ @config = DEFAULT_CONFIG
31
+ end
32
+
33
+ def complete_with_default_config!
34
+ DEFAULT_CONFIG.each do |a, b|
35
+ if (@config[a] == nil)
36
+ @config[a] = b
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,42 @@
1
+ require_relative 'config'
2
+
3
+ module Helpers
4
+ def get_series_with_zero(series)
5
+ if series < 10
6
+ return '0' + series.to_s
7
+ else
8
+ return series.to_s
9
+ end
10
+ end
11
+
12
+ def get_filename_by_series(series, regexp)
13
+ config = Config.instance
14
+ magic_word = config.config["magic_word"]
15
+
16
+ dir = Dir.entries('./')
17
+ valid_filename = nil
18
+
19
+ if regexp.nil?
20
+ default_regexp = config.config["default_regex"]
21
+ valid_regexp = default_regexp.gsub(magic_word, series)
22
+ else
23
+ valid_regexp = regexp.gsub(magic_word, series)
24
+ end
25
+
26
+ dir.each do |f|
27
+ if /#{valid_regexp}/.match?(f)
28
+ valid_filename = f
29
+ break
30
+ end
31
+ end
32
+
33
+ valid_filename
34
+ rescue RegexpError
35
+ puts "Regex compiled incorrectly!"
36
+ exit 1
37
+ end
38
+
39
+ def filename(series, regexp)
40
+ get_filename_by_series(get_series_with_zero(series), regexp)
41
+ end
42
+ end
@@ -0,0 +1,23 @@
1
+ require_relative "config"
2
+
3
+ module Player
4
+ @config = Config.instance
5
+
6
+ def self.open_videoplayer(filename)
7
+ system("#{@config.config["videoplayer_exec"]} \"#{filename}\"")
8
+ end
9
+
10
+ def self.open_next()
11
+ next_series = get_last + 1
12
+ set_last(next_series)
13
+ open_series(next_series)
14
+ end
15
+
16
+ def self.open(filename)
17
+ if filename.nil?
18
+ puts "File not found!"
19
+ else
20
+ open_videoplayer(filename)
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,49 @@
1
+ require_relative 'storage'
2
+ require_relative 'helpers'
3
+ require_relative 'player'
4
+ require_relative 'config'
5
+
6
+ module SeriesReminder
7
+ class Series
8
+ include Helpers
9
+
10
+ def initialize
11
+ @storage = Storage.new
12
+ end
13
+
14
+ def open_series(series)
15
+ Player.open(filename(series))
16
+ end
17
+
18
+ def open_next
19
+ next_series = @storage.get_last + 1
20
+
21
+ Player.open(filename(next_series, @storage.get_regexp))
22
+
23
+ @storage.set_last(next_series)
24
+ rescue Interrupt
25
+ @storage.set_last(next_series)
26
+ end
27
+
28
+ def open_config_file(config_location)
29
+ config = Config.instance
30
+ config.load_config_file!(config_location)
31
+ end
32
+
33
+ def get_last_series
34
+ @storage.get_last
35
+ end
36
+
37
+ def set_regexp(regexp)
38
+ @storage.set_regexp(regexp)
39
+ end
40
+
41
+ def init_storage
42
+ @storage.init_file
43
+ end
44
+
45
+ def set_last_series(series)
46
+ @storage.set_last(series)
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,76 @@
1
+ require_relative 'config'
2
+
3
+ class Storage
4
+ def initialize
5
+ @config = Config.instance
6
+
7
+ if file_exist?
8
+ @store = File.readlines(@config.config["series_filename"])
9
+ else
10
+ @store = []
11
+ end
12
+ end
13
+
14
+ def store_valid?
15
+ if file_exist?
16
+ return !(@store.length < 1 )
17
+ else
18
+ return false
19
+ end
20
+ end
21
+
22
+ def file_exist?
23
+ File.exist? @config.config["series_filename"]
24
+ end
25
+
26
+ def check_store
27
+ if !store_valid?
28
+ puts "Storage data is invalid!"
29
+ exit
30
+ end
31
+ end
32
+
33
+ def get_last
34
+ if (!file_exist?)
35
+ init_file
36
+ end
37
+
38
+ check_store
39
+ @store[0].to_i
40
+ end
41
+
42
+ def set_last(series)
43
+ @store[0] = series.to_s
44
+ update_store()
45
+ end
46
+
47
+ def update_store()
48
+ File.open(@config.config["series_filename"], 'w') do |file|
49
+ @store.each do |item|
50
+ file.puts item
51
+ end
52
+ end
53
+ end
54
+
55
+ def get_regexp()
56
+ if (@store[1].nil?)
57
+ return nil
58
+ else
59
+ return @store[1][0..-2]
60
+ end
61
+ end
62
+
63
+ def set_regexp(regexp)
64
+ @store[1] = regexp
65
+ update_store()
66
+ end
67
+
68
+ def init_file()
69
+ if store_valid?
70
+ puts "Already initialized!"
71
+ else
72
+ set_last 0
73
+ puts "Successfully initialized."
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,3 @@
1
+ module SeriesReminder
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,5 @@
1
+ require "series_reminder/version"
2
+
3
+ module SeriesReminder
4
+ autoload :Series, 'series_reminder/series'
5
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "series_reminder/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "series_reminder"
8
+ spec.version = SeriesReminder::VERSION
9
+ spec.authors = ["relmay"]
10
+ spec.email = ["nightterror@protonmail.ch"]
11
+
12
+ spec.summary = "A simple app that remembers the number of your last viewed series and can play next series."
13
+ spec.description = spec.summary
14
+ spec.homepage = "https://github.com/relmay/series_reminder"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(bin)/})
19
+ end
20
+ spec.bindir = "bin"
21
+ spec.executables = "series"
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.15"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ end
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: series_reminder
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - relmay
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-12-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.15'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.15'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: A simple app that remembers the number of your last viewed series and
42
+ can play next series.
43
+ email:
44
+ - nightterror@protonmail.ch
45
+ executables:
46
+ - series
47
+ extensions: []
48
+ extra_rdoc_files: []
49
+ files:
50
+ - ".gitignore"
51
+ - ".rspec"
52
+ - ".travis.yml"
53
+ - CODE_OF_CONDUCT.md
54
+ - Gemfile
55
+ - LICENSE.txt
56
+ - README.md
57
+ - Rakefile
58
+ - bin/series
59
+ - lib/.series
60
+ - lib/series_reminder.rb
61
+ - lib/series_reminder/config.rb
62
+ - lib/series_reminder/helpers.rb
63
+ - lib/series_reminder/player.rb
64
+ - lib/series_reminder/series.rb
65
+ - lib/series_reminder/storage.rb
66
+ - lib/series_reminder/version.rb
67
+ - series_reminder.gemspec
68
+ homepage: https://github.com/relmay/series_reminder
69
+ licenses:
70
+ - MIT
71
+ metadata: {}
72
+ post_install_message:
73
+ rdoc_options: []
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ requirements: []
87
+ rubyforge_project:
88
+ rubygems_version: 2.6.13
89
+ signing_key:
90
+ specification_version: 4
91
+ summary: A simple app that remembers the number of your last viewed series and can
92
+ play next series.
93
+ test_files: []