kinata 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/License ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Dimitar Kostov
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ 'Software'), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,69 @@
1
+ # Kinata
2
+
3
+ Kinata is simple gem for getting information about cinemas and movies in Sofia
4
+
5
+ # Installation
6
+
7
+ $ gem install kinata
8
+
9
+ # Usage
10
+
11
+ ## Cinemas
12
+
13
+ Available cinemas:
14
+
15
+ * :arena_zapad
16
+ * :arena_mall
17
+ * :arena_mladost
18
+ * :mtel_imax
19
+ * :cinema_city
20
+ * :euro_cinema
21
+ * :vlaikova
22
+ * :dom_na_kinoto
23
+
24
+
25
+ ```` ruby
26
+ cinema = Kinata::Cinema.new :arena_zapad
27
+
28
+ cinema.name # Арена Запад
29
+
30
+ cinema.address # София, ж.к. Илинден, бул. Тодор Александров 64, до метростанция Вардар
31
+
32
+ cinema.phone # "028127700"
33
+
34
+ cinema.coordinates # ["23290334", "42705008"]
35
+
36
+ cinema.movies # [{"name"=>"Весели крачета 2", "id"=>"69921", "dates"=> ["2012-01-30 11:40:00", "2012-01-30 13:40:00", "2012-01-30 15:40:00"]}
37
+
38
+ ````
39
+ ## Movies
40
+
41
+ ```` ruby
42
+ movie = Kinata::Movie.new c.movies.first['id']
43
+
44
+ movie.name # "Весели крачета 2"
45
+
46
+ movie.genre # "анимация"
47
+ ````
48
+
49
+ ### Methods on movie
50
+
51
+ * name
52
+ * image
53
+ * language
54
+ * translation
55
+ * genre
56
+ * trailer
57
+ * original_title
58
+ * features
59
+ * comment
60
+ * lead
61
+ * description
62
+ * cinemas
63
+
64
+ # Author
65
+
66
+ * Name - Mitko Kostov
67
+ * Email - mitko.kostov@gmail.com
68
+ * Blog - <http://fireinside.me>
69
+ * Twitter - [mytrile]("https://twitter.com/mytrile")
@@ -0,0 +1,13 @@
1
+ $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
2
+
3
+ begin
4
+ require 'bundler'
5
+ Bundler::GemHelper.install_tasks
6
+ rescue LoadError => e
7
+ $stderr.puts e
8
+ end
9
+
10
+ desc "run specs"
11
+ task(:spec) { ruby '-S rspec spec' }
12
+ task :default => :spec
13
+ task :test => :spec
@@ -0,0 +1,26 @@
1
+ require File.expand_path('../lib/kinata/version', __FILE__)
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = "kinata"
5
+ s.version = Kinata::VERSION::STRING
6
+ s.description = "Kinata is simple gem for getting info about cinemas in Sofia"
7
+ s.homepage = "http://github.com/mytrile/kinata"
8
+ s.summary = s.description
9
+ s.require_paths = ['lib']
10
+ s.author = "Mitko Kostov"
11
+ s.email = "mitko.kostov@gmail.com"
12
+ s.files = [
13
+ "License",
14
+ "README.md",
15
+ "Rakefile",
16
+ "kinata.gemspec",
17
+ "lib/kinata.rb",
18
+ "lib/kinata/cinema.rb",
19
+ "lib/kinata/movie.rb",
20
+ "lib/kinata/version.rb",
21
+ "spec/kinata_spec.rb"
22
+ ]
23
+ s.add_runtime_dependency "httparty", "~> 0.8.1"
24
+ s.add_runtime_dependency "json", "~> 1.6.5"
25
+ s.add_development_dependency "rspec", "~> 2.0"
26
+ end
@@ -0,0 +1,10 @@
1
+ $:.unshift File.dirname(__FILE__)
2
+
3
+ require 'httparty'
4
+ require 'json'
5
+
6
+ require 'kinata/cinema'
7
+ require 'kinata/movie'
8
+
9
+ module Kinata
10
+ end
@@ -0,0 +1,62 @@
1
+ module Kinata
2
+ class Cinema
3
+
4
+ CINEMAS = {
5
+ :arena_zapad => 877,
6
+ :arena_mall => 5981,
7
+ :arena_mladost => 2540,
8
+ :cinema_city => 3664,
9
+ :euro_cinema => 6088,
10
+ :mtel_imax => 3663,
11
+ :vlaikova => 3,
12
+ :dom_na_kinoto => 29,
13
+ }
14
+
15
+ attr_accessor :cinema
16
+
17
+ def initialize(name)
18
+ @cinema = get_cinema(name)
19
+ end
20
+
21
+ def name
22
+ @cinema["name"]
23
+ end
24
+
25
+ def address
26
+ @cinema["address"]
27
+ end
28
+
29
+ def phone
30
+ @cinema["phone"]
31
+ end
32
+
33
+ def description
34
+ @cinema["description"]
35
+ end
36
+
37
+ def coordinates
38
+ [@cinema["lng"], @cinema["lat"]]
39
+ end
40
+
41
+ def id
42
+ @cinema["id"]
43
+ end
44
+
45
+ def movies
46
+ @cinema["events"]
47
+ end
48
+
49
+ def list_cinemas
50
+ CINEMAS.keys
51
+ end
52
+
53
+ private
54
+
55
+ def get_cinema(name)
56
+ cinema_id = CINEMAS[name]
57
+ url = "http://programata.bg/json/?request=placeDetails&id=#{cinema_id}&category%5Fid=31&l=1"
58
+ data = ::JSON.parse(::HTTParty.get(url))
59
+ data["place"]
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,72 @@
1
+ module Kinata
2
+ class Movie
3
+
4
+ def initialize(id)
5
+ @movie = get_movie(id)
6
+ end
7
+
8
+ def name
9
+ @movie['name']
10
+ end
11
+
12
+ def images
13
+ @movie['images']
14
+ end
15
+
16
+ def image
17
+ @movie['image']
18
+ end
19
+
20
+ def language
21
+ @movie['language']
22
+ end
23
+
24
+ def translation
25
+ @movie['translation']
26
+ end
27
+
28
+ def genre
29
+ @movie['genre']
30
+ end
31
+
32
+ def trailer
33
+ @cinema['trailer']
34
+ end
35
+
36
+ def original_title
37
+ @movie['originalTitle']
38
+ end
39
+
40
+ def features
41
+ @movie['features']
42
+ end
43
+
44
+ def comment
45
+ @movie['comment']
46
+ end
47
+
48
+ def lead
49
+ @movie['lead']
50
+ end
51
+
52
+ def description
53
+ @movie['description']
54
+ end
55
+
56
+ def cinemas
57
+ @movie['places']
58
+ end
59
+
60
+ def id
61
+ @movie['id']
62
+ end
63
+
64
+ private
65
+
66
+ def get_movie(id)
67
+ url = "http://programata.bg/json/?request=eventDetails&city=1&id=#{id}&category%5Fid=0&l=1"
68
+ data = ::JSON.parse(::HTTParty.get(url))
69
+ data['event']
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,11 @@
1
+ module Kinata
2
+
3
+ module VERSION #:nodoc:
4
+ MAJOR = 0
5
+ MINOR = 1
6
+ PATCH = 0
7
+ PRE = nil
8
+ STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.')
9
+ end
10
+
11
+ end
@@ -0,0 +1,4 @@
1
+ require 'kinata'
2
+
3
+ describe Kinata do
4
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kinata
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Mitko Kostov
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-01-30 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: httparty
16
+ requirement: &77747510 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.8.1
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *77747510
25
+ - !ruby/object:Gem::Dependency
26
+ name: json
27
+ requirement: &77747130 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 1.6.5
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *77747130
36
+ - !ruby/object:Gem::Dependency
37
+ name: rspec
38
+ requirement: &77746590 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: '2.0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *77746590
47
+ description: Kinata is simple gem for getting info about cinemas in Sofia
48
+ email: mitko.kostov@gmail.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - License
54
+ - README.md
55
+ - Rakefile
56
+ - kinata.gemspec
57
+ - lib/kinata.rb
58
+ - lib/kinata/cinema.rb
59
+ - lib/kinata/movie.rb
60
+ - lib/kinata/version.rb
61
+ - spec/kinata_spec.rb
62
+ homepage: http://github.com/mytrile/kinata
63
+ licenses: []
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ! '>='
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ! '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubyforge_project:
82
+ rubygems_version: 1.8.10
83
+ signing_key:
84
+ specification_version: 3
85
+ summary: Kinata is simple gem for getting info about cinemas in Sofia
86
+ test_files: []