cinebase 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 023cf4aab3fe10a9d45a96cce9ed96af3ed0210e
4
+ data.tar.gz: 5fb85ad75a5e6ce2ae779a5c7fe2a64cc5d35825
5
+ SHA512:
6
+ metadata.gz: a1ace489691560df3eb7ad25b2f27b544986294ba26e889a283479518dcab1fd7dba13d0b86f6510791ce8eced603f4a176f83e37cba71c65248a47a5106bad0
7
+ data.tar.gz: e4ef4c8a87b3cf48f39381e7db54fecdaee8f0715c0f1eaaa6ba75df5084262454879738f4533f77431d6efdf7cd683f2059ccc652bcb1164375105c164fb801
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ before_install: gem install bundler --pre
2
+ language: ruby
3
+ rvm:
4
+ - 2.1.5
5
+ - 2.2.2
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cinebase.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Andy Croll
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,77 @@
1
+ # Cinebase
2
+
3
+ [![](https://img.shields.io/gem/v/cinebase.svg)](http://rubygems.org/gems/cinebase)
4
+ [![](https://img.shields.io/travis/andycroll/cinebase.svg)](https://travis-ci.org/andycroll/cinebase)
5
+ [![](https://img.shields.io/codeclimate/github/andycroll/cinebase.svg)](https://codeclimate.com/github/andycroll/cinebase)
6
+ [![](https://img.shields.io/codeclimate/coverage/github/andycroll/cinebase.svg)](https://codeclimate.com/github/andycroll/cinebase/coverage)
7
+ ![](https://img.shields.io/github/license/andycroll/cinebase.svg)
8
+
9
+ A basic interface for a series of cinema gems.
10
+
11
+ ## Installation
12
+
13
+ Add this line to the gem's gemspec:
14
+
15
+ ```ruby
16
+ gem.add_runtime_dependency 'cinebase'
17
+ ```
18
+
19
+ And then execute:
20
+
21
+ $ bundle
22
+
23
+ Or install it yourself as:
24
+
25
+ $ gem install cinebase
26
+
27
+ ## Usage
28
+
29
+ This gem is intended to act as a base for other cinema chain gems. Inherit the classes to get the correct method signatures.
30
+
31
+ ```ruby
32
+ module CinemaChainName
33
+ class Cinema < Cinebase::Cinema
34
+ def self.all(cinema_id)
35
+ # parse webpages or apis to get cinemas
36
+ end
37
+
38
+ def brand
39
+ # 'Brand Name'
40
+ end
41
+
42
+ # define address methods
43
+ end
44
+ end
45
+
46
+ module CinemaChainName
47
+ class Screening < Cinebase::Screening
48
+ def self.at(cinema_id)
49
+ # parse webpages or apis to get screenings for a cinema
50
+ end
51
+ end
52
+ end
53
+
54
+ module CinemaChainName
55
+ module Internal
56
+ class TitleSanitizer < Cinebase::TitleSanitizer
57
+ private
58
+
59
+ def remove
60
+ # []
61
+ end
62
+
63
+ def replace
64
+ # { core title regex => replacement text }
65
+ end
66
+ end
67
+ end
68
+ end
69
+ ```
70
+
71
+ ## Contributing
72
+
73
+ 1. [Fork it](https://github.com/andycroll/cinebase/fork)
74
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
75
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
76
+ 4. Push to the branch (`git push origin my-new-feature`)
77
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ require 'rake/testtask'
4
+ Rake::TestTask.new do |t|
5
+ t.libs << 'lib/cinebase'
6
+ t.pattern = 'test/lib/**/*_test.rb'
7
+ t.verbose = true
8
+ end
9
+
10
+ task default: :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'cinebase'
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
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/cinebase.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'cinebase/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'cinebase'
7
+ spec.version = Cinebase::VERSION
8
+ spec.authors = ['Andy Croll']
9
+ spec.email = ['andy@goodscary.com']
10
+
11
+ spec.summary = 'A base for cinema parsers to maintain a regular interface.'
12
+ spec.description = 'I maintain several gems for cinema times in the UK, this gem is the interface descriptor.'
13
+ spec.homepage = 'http://github.com/andycroll/cinebase'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = 'exe'
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_development_dependency 'bundler', '~> 1.9'
22
+ spec.add_development_dependency 'minitest-reporters'
23
+ spec.add_development_dependency 'rake', '~> 10.0'
24
+ spec.add_development_dependency 'codeclimate-test-reporter'
25
+ end
@@ -0,0 +1,40 @@
1
+ module Cinebase
2
+ # Cinema base class
3
+ class Cinema
4
+ attr_reader :id
5
+
6
+ def initialize(id)
7
+ @id = id
8
+ end
9
+
10
+ def self.all
11
+ fail NotImplementedError, "This #{self.class} cannot respond to: "
12
+ end
13
+
14
+ def adr
15
+ {
16
+ street_address: street_address,
17
+ extended_address: extended_address,
18
+ locality: locality,
19
+ postal_code: postal_code,
20
+ country_name: country_name
21
+ }.reject { |_, v| v.nil? }
22
+ end
23
+ alias_method :address, :adr
24
+
25
+ [:brand, :country_name, :extended_address, :locality, :name, :postal_code,
26
+ :street_address, :url].each do |method|
27
+ define_method(method) do
28
+ fail NotImplementedError, "This #{self.class} cannot respond to: "
29
+ end
30
+ end
31
+
32
+ def full_name
33
+ @full_name ||= "#{brand} #{name}"
34
+ end
35
+
36
+ def slug
37
+ @slug ||= full_name.downcase.gsub(/[^0-9a-z ]/, '').gsub(/\s+/, '-')
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,35 @@
1
+ module Cinebase
2
+ # Screening base class
3
+ class Screening
4
+ attr_reader :booking_url
5
+ attr_reader :dimension
6
+ attr_reader :cinema_id
7
+ attr_reader :cinema_name
8
+ attr_reader :film_name
9
+ attr_reader :showing_at
10
+
11
+ def initialize(options)
12
+ @booking_url = options.fetch(:booking_url, nil)
13
+ @cinema_name = options.fetch(:cinema_name)
14
+ @cinema_id = options.fetch(:cinema_id)
15
+ @dimension = options.fetch(:dimension, '2d')
16
+ @film_name = options.fetch(:film_name)
17
+ @showing_at = options.fetch(:time)
18
+ @variant = options.fetch(:variant, [])
19
+ end
20
+
21
+ # Implement to deliver an Array of Screening objects
22
+ def self.at(cinema_id)
23
+ fail NotImplementedError, "This #{self.class} cannot respond to: "
24
+ end
25
+
26
+ def showing_on
27
+ @showing_at.to_date
28
+ end
29
+
30
+ def variant
31
+ @variant = @variant.split(' ') if @variant.is_a?(String)
32
+ @variant.map(&:downcase).sort.uniq
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,27 @@
1
+ module Cinebase
2
+ # Sabitize titles base class
3
+ class TitleSanitizer < Struct.new(:title)
4
+ def sanitized
5
+ @sanitized ||= begin
6
+ sanitized = title
7
+ remove.each do |pattern|
8
+ sanitized.gsub! pattern, ''
9
+ end
10
+ replace.each do |pattern, prefix|
11
+ sanitized.gsub!(pattern) { |_| prefix + $1 }
12
+ end
13
+ sanitized.squeeze(' ').strip
14
+ end
15
+ end
16
+
17
+ private
18
+
19
+ def remove
20
+ fail NotImplementedError, "This #{self.class} cannot respond to: "
21
+ end
22
+
23
+ def replace
24
+ fail NotImplementedError, "This #{self.class} cannot respond to: "
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,4 @@
1
+ # Cinebase version
2
+ module Cinebase
3
+ VERSION = '1.0.0'
4
+ end
data/lib/cinebase.rb ADDED
@@ -0,0 +1,5 @@
1
+ require 'cinebase/version'
2
+
3
+ require 'cinebase/cinema'
4
+ require 'cinebase/screening'
5
+ require 'cinebase/title_sanitizer'
metadata ADDED
@@ -0,0 +1,117 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cinebase
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Andy Croll
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-05-30 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.9'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: minitest-reporters
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: codeclimate-test-reporter
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: I maintain several gems for cinema times in the UK, this gem is the interface
70
+ descriptor.
71
+ email:
72
+ - andy@goodscary.com
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".travis.yml"
79
+ - CODE_OF_CONDUCT.md
80
+ - Gemfile
81
+ - LICENSE.txt
82
+ - README.md
83
+ - Rakefile
84
+ - bin/console
85
+ - bin/setup
86
+ - cinebase.gemspec
87
+ - lib/cinebase.rb
88
+ - lib/cinebase/cinema.rb
89
+ - lib/cinebase/screening.rb
90
+ - lib/cinebase/title_sanitizer.rb
91
+ - lib/cinebase/version.rb
92
+ homepage: http://github.com/andycroll/cinebase
93
+ licenses:
94
+ - MIT
95
+ metadata: {}
96
+ post_install_message:
97
+ rdoc_options: []
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ requirements: []
111
+ rubyforge_project:
112
+ rubygems_version: 2.2.2
113
+ signing_key:
114
+ specification_version: 4
115
+ summary: A base for cinema parsers to maintain a regular interface.
116
+ test_files: []
117
+ has_rdoc: