obecon-client 0.0.1

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: 6820da68a75fac8154c2311e1ecee4cdf0cdc7b7
4
+ data.tar.gz: b5813ecf7bb177020fee8b077157479020d1d4a6
5
+ SHA512:
6
+ metadata.gz: 9d49d215fdb201e8ca957716e79905ceb448a372501e79416e89f805c381e63422b91b1bf831c96a26e5a4e9bd0bf47de9d9618b2bf15f61daa6c99eeb644122
7
+ data.tar.gz: ed02c1bf4135654cd72aecf7f3fe9d96667d58bfc34d10965771dc86033ab20afea343aa59dac0d85e64bd0e0db7208504d221cfc5a391f0bab448c5ca8ff841
data/README.md ADDED
@@ -0,0 +1,4 @@
1
+ obecon-client
2
+ =============
3
+
4
+ Simple wrapper to receive assets from oberbaum-concept asset servers
@@ -0,0 +1,4 @@
1
+ module Obecon
2
+ class Asset < Hashie::Mash
3
+ end
4
+ end
@@ -0,0 +1,54 @@
1
+ module Obecon
2
+ class Client
3
+ include HTTParty
4
+ USER_AGENT = "ASK HELMUT Oberbaum Concept Client #{VERSION}"
5
+ MOVIE_PARAM_NAME = "CMFilm-Id"
6
+ DEFAULT_OPTIONS = {
7
+ site: "webs.sn.obecon.net"
8
+ }
9
+
10
+ attr_accessor :options
11
+ headers({"User-Agent" => USER_AGENT})
12
+
13
+ def initialize(options = {})
14
+ store_options(options)
15
+ raise ArgumentError, "A domain name must be present" if domain_name.nil?
16
+ end
17
+
18
+ def movie(movie_id)
19
+ handle_response {
20
+ self.class.get(*construct_query_arguments(MOVIE_PARAM_NAME, movie_id))
21
+ }
22
+ end
23
+
24
+ # accessors for options
25
+ def site
26
+ @options[:site]
27
+ end
28
+ def domain_name
29
+ @options[:domain_name]
30
+ end
31
+
32
+ def api_url
33
+ [site, domain_name].join("/")
34
+ end
35
+
36
+ private
37
+ def handle_response(&block)
38
+ response = block.call
39
+ ResponseWrapper.new(response)
40
+ end
41
+
42
+ def store_options(options={})
43
+ @options ||= DEFAULT_OPTIONS.dup
44
+ @options.merge!(options)
45
+ end
46
+
47
+ def construct_query_arguments(detail_name, identifier)
48
+ scheme = "http"
49
+ [
50
+ "#{scheme}://#{api_url}/#{detail_name}/#{identifier}"
51
+ ]
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,75 @@
1
+ module Obecon
2
+ class ResponseWrapper
3
+
4
+ RESULT = "result"
5
+ ASSET = "asset"
6
+ # SLOTS
7
+ # Fotostrecke
8
+ # Szenenbilder
9
+ # BB*=459x400, jpg, rgb
10
+ GALLERY = "fotostrecke"
11
+
12
+ # Filmplakat
13
+ # Filmplakat
14
+ # BB*=400x10000, jpg, rgb
15
+ POSTER = "filmplakat"
16
+
17
+ # Filmbild
18
+ # teaser Image klein
19
+ # BB*=180x10000, jpg, rgb
20
+ TEASER_SMALL = "filmbild"
21
+
22
+ # Splash
23
+ # teaser Image groß
24
+ # BB*=456x340, jpg, rgb
25
+ TEASER_LARGE = "splash"
26
+
27
+ # webcontainer
28
+ # Event Content
29
+ # BB*=456x340, jpg, rgb
30
+ WEBCONTAINER = "webcontainer"
31
+
32
+ # *(_hq)
33
+ # Flash-Video
34
+ # 456x340, 480kbit Video, flv
35
+ VIDEO_HQ = "video_hq"
36
+
37
+ # *(_small_hq)
38
+ # Flash-Video
39
+ # 180x132, 192kBit Video, flv
40
+ VIDEO_SMALL_HQ = "video_small_hq"
41
+
42
+ # *(_small_lq)
43
+ # Flash-Video
44
+ # 180x132, 64kBit Video, flv
45
+ VIDEO_SMALL_LQ = "video_small_lq"
46
+
47
+ # mp4
48
+ # H264 Video
49
+ # BB*=640x512, 830kBit Video, h264
50
+ VIDEO_MP4 = "video_mp4"
51
+
52
+ attr_reader :response
53
+ def initialize(response = nil)
54
+ assets = JSON.parse(response)[RESULT][ASSET]
55
+ @slot_map = map_by_slots(assets)
56
+ end
57
+
58
+ def method_missing(method_name, *args, &block)
59
+ mapped_slot = ResponseWrapper.const_get method_name.upcase
60
+ result = @slot_map[mapped_slot.to_sym]
61
+ result.size == 1 ? result.first : result
62
+ end
63
+
64
+ private
65
+ def map_by_slots(array)
66
+ result = {}
67
+ array.each do |entry|
68
+ key = entry["slot"].to_sym
69
+ result[key] = [] unless result.key?(key)
70
+ result[key] << Obecon::Asset.new(entry)
71
+ end
72
+ result
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,3 @@
1
+ module Obecon
2
+ VERSION = '0.0.1'
3
+ end
data/lib/obecon.rb ADDED
@@ -0,0 +1,17 @@
1
+ require "hashie"
2
+ require "httparty"
3
+ require "uri"
4
+
5
+ require "obecon/client"
6
+ require "obecon/response_wrapper"
7
+ require "obecon/asset"
8
+ require "obecon/version"
9
+
10
+ module Obecon
11
+
12
+ def new(options = {})
13
+ Client.new(options)
14
+ end
15
+ module_function :new
16
+
17
+ end
metadata ADDED
@@ -0,0 +1,120 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: obecon-client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Niels Hoffmann
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-11-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 0.12.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 0.12.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: hashie
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: guard
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '1.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rb-fsevent
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '0.9'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '0.9'
83
+ description: Simple wrapper to receive assets from oberbaum-concept asset servers.
84
+ email:
85
+ - niels@askhelmut.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - lib/obecon/asset.rb
91
+ - lib/obecon/client.rb
92
+ - lib/obecon/response_wrapper.rb
93
+ - lib/obecon/version.rb
94
+ - lib/obecon.rb
95
+ - README.md
96
+ homepage: https://askhelmut.com
97
+ licenses:
98
+ - MIT
99
+ metadata: {}
100
+ post_install_message:
101
+ rdoc_options: []
102
+ require_paths:
103
+ - lib
104
+ required_ruby_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - '>='
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ required_rubygems_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - '>='
112
+ - !ruby/object:Gem::Version
113
+ version: 1.3.5
114
+ requirements: []
115
+ rubyforge_project:
116
+ rubygems_version: 2.1.9
117
+ signing_key:
118
+ specification_version: 4
119
+ summary: A wrapper for the Oberbaum Concept asset server.
120
+ test_files: []