fryfro 0.1.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: 9d555272b9b18003cce7e838bd1b201c98b3d6a0
4
+ data.tar.gz: 631db63c4c74d0fcb39fc259621e991278dddc82
5
+ SHA512:
6
+ metadata.gz: 3eaa7b22870fae1cc7c05d30d61e897b9b1d9c9515df34effab2376a50ea5a896848f3ef2874f84fda718c31c717d4e01884004acffc50d0418ed75622720ce6
7
+ data.tar.gz: 2cfcabd1ab720a7b7ec889913c07a89517ba0a995f1c2cc7f78182c496f43ac4ce5f388291df6213e4c589ac8ef67921b6cca59e101264c861a1672434bf45a7
data/.document ADDED
@@ -0,0 +1,3 @@
1
+ lib/**/*.rb
2
+ -
3
+ LICENSE.txt
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ !doc/fryfro.png
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --order random
2
+ --color
3
+ -f d
data/.travis.yml ADDED
@@ -0,0 +1,11 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - ruby-head
6
+ - jruby-19mode
7
+ - jruby-head
8
+ - rbx-19mode
9
+ matrix:
10
+ allow_failures:
11
+ - rvm: ruby-head
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Max Riveiro
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # Fryfro
2
+
3
+ Fryfro is a Flurry API client.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'fryfro'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install fryfro
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
30
+
31
+ ## Copyright
32
+
33
+ Copyright (c) 2013 Max Riveiro. See LICENSE.txt for further details.
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'yard'
4
+
5
+ YARD::Rake::YardocTask.new
6
+
7
+ RSpec::Core::RakeTask.new('spec')
8
+
9
+ task :default => :spec
data/fryfro.gemspec ADDED
@@ -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 'fryfro/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'fryfro'
8
+ spec.version = Fryfro::VERSION
9
+ spec.authors = ['Max Riveiro']
10
+ spec.email = ['kavu13@gmail.com']
11
+ spec.description = 'Fryfro provides an interface for the Flurry API.'
12
+ spec.summary = 'Fryfro is a Flurry API client.'
13
+ spec.homepage = 'https://github.com/kavu/fryfro'
14
+ spec.license = 'MIT'
15
+ spec.files = `git ls-files`.split($/)
16
+ spec.test_files = spec.files.grep(%r{^spec/})
17
+ spec.require_paths = ['lib']
18
+
19
+ spec.add_dependency 'httparty', '~> 0.11.0'
20
+
21
+ spec.add_development_dependency 'rake'
22
+ spec.add_development_dependency 'bundler', '~> 1.3'
23
+ spec.add_development_dependency 'rspec', '~> 2.13'
24
+ spec.add_development_dependency 'rspec-mocks', '~> 2.13'
25
+ spec.add_development_dependency 'yard', '~> 0.8.5'
26
+ end
data/lib/fryfro.rb ADDED
@@ -0,0 +1,27 @@
1
+ require 'fryfro/version'
2
+
3
+ require 'fryfro/endpoint'
4
+ require 'fryfro/app_info'
5
+ require 'fryfro/app_metrics'
6
+ require 'fryfro/events_metrics'
7
+ require 'fryfro/raw_data'
8
+
9
+ require 'fryfro/app'
10
+
11
+ module Fryfro
12
+ class << self
13
+ def all_applications_info_raw(opts = {})
14
+ AppInfo[:get_all_applications].(opts[:access_code])['applications']
15
+ end
16
+
17
+ def all_applications(opts = {})
18
+ raw = all_applications_info_raw(opts)['application']
19
+
20
+ raw.reduce([]) do |apps, app|
21
+ apps << App.new(key: app['apiKey'], access_code: opts[:access_code],
22
+ name: app['name'], platform: app['platform'],
23
+ created_at: app['createdDate'])
24
+ end
25
+ end
26
+ end
27
+ end
data/lib/fryfro/app.rb ADDED
@@ -0,0 +1,64 @@
1
+ module Fryfro
2
+ class App
3
+ attr_reader :key, :access_code, :name, :platform, :created_at
4
+
5
+ def initialize(opts = {})
6
+ # Mandatory
7
+ @access_code = opts[:access_code] or raise ArgumentError, 'Provide an apiAccessCode'
8
+ @key = opts[:key] or raise ArgumentError, 'Provide an apiKey'
9
+
10
+ # Optional
11
+ @name = opts[:name]
12
+ @platform = opts[:platform]
13
+ @created_at = opts[:created_at]
14
+ end
15
+
16
+ def info
17
+ AppInfo[:get_application].(@access_code, @key)['appInfo']
18
+ end
19
+
20
+ def metric(metric, opts = {})
21
+ raise ArgumentError, 'Provide an eventName' unless metric
22
+ check_required_dates(opts)
23
+ AppMetrics[metric].(@access_code, @key, opts)['appMetrics']
24
+ end
25
+
26
+ def events(opts = {})
27
+ check_required_dates(opts)
28
+ EventMetrics[:summary].(@access_code, @key, opts)['eventMetrics']
29
+ end
30
+
31
+ def event(opts = {})
32
+ raise ArgumentError, 'Provide an eventName' unless opts[:event_name] || opts['eventName']
33
+ check_required_dates(opts)
34
+ EventMetrics[:event].(@access_code, @key, opts)['eventMetrics']
35
+ end
36
+
37
+ def raw_data(opts = {})
38
+ check_params_overlap(opts)
39
+ time_params?(opts) ? check_required_times(opts) : check_required_dates(opts)
40
+ RawData[:events].(@access_code, @key, opts)
41
+ end
42
+
43
+ private
44
+ def check_required_dates(opts)
45
+ raise ArgumentError, 'Provide an startDate' unless opts[:start_date] || opts['startDate']
46
+ raise ArgumentError, 'Provide an endDate' unless opts[:end_date] || opts['endDate']
47
+ end
48
+
49
+ def check_required_times(opts)
50
+ raise ArgumentError, 'Provide an startTime' unless opts[:start_time] || opts['startTime']
51
+ raise ArgumentError, 'Provide an endTime' unless opts[:end_time] || opts['endTime']
52
+ end
53
+
54
+ def check_params_overlap(opts)
55
+ start_param = (opts[:start_date] || opts['startDate']) && (opts[:start_time] || opts['startTime'])
56
+ end_param = (opts[:end_date] || opts['endDate']) && (opts[:end_time] || opts['endTime'])
57
+ raise ArgumentError, 'Provide a startDate/endDate or a startTime/endTime only' if start_param || end_param
58
+ end
59
+
60
+ def time_params?(opts)
61
+ opts[:start_time] || opts['startTime'] || opts[:end_time] || opts['endTime']
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,10 @@
1
+ # http://support.flurry.com/index.php?title=API/Code/AppInfo
2
+ module Fryfro
3
+ class AppInfo < Endpoint
4
+ base_uri 'http://api.flurry.com/appInfo'
5
+
6
+ class << self
7
+ alias_method :camelize, :camelize_key
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,6 @@
1
+ # http://support.flurry.com/index.php?title=API/Code
2
+ module Fryfro
3
+ class AppMetrics < Endpoint
4
+ base_uri 'http://api.flurry.com/appMetrics'
5
+ end
6
+ end
@@ -0,0 +1,37 @@
1
+ require 'httparty'
2
+
3
+ module Fryfro
4
+ class Endpoint
5
+ include HTTParty
6
+
7
+ headers 'Accept' => 'application/xml'
8
+
9
+ debug_output $stdout if ENV['DEBUG']
10
+
11
+ class << self
12
+ def [](metric)
13
+ Proc.new do |code, key, opts = {}|
14
+ hash = { api_access_code: code }
15
+ hash[:api_key] = key if key
16
+ hash.merge!(opts)
17
+
18
+ get("/#{camelize(metric)}?#{queryize(hash)}")
19
+ end
20
+ end
21
+
22
+ def queryize(hash)
23
+ camelized_hash = Hash[hash.map { |k, v| [camelize_key(k), v] }]
24
+ URI.encode_www_form(camelized_hash)
25
+ end
26
+
27
+ def camelize(sym)
28
+ sym.to_s.split('_').map { |w| w.capitalize }.join
29
+ end
30
+
31
+ def camelize_key(sym)
32
+ parts = sym.to_s.split('_')
33
+ parts[0] + parts[1..-1].map { |w| w.capitalize }.join
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,6 @@
1
+ # http://support.flurry.com/index.php?title=API/Code/EventMetrics
2
+ module Fryfro
3
+ class EventMetrics < Endpoint
4
+ base_uri 'http://api.flurry.com/eventMetrics'
5
+ end
6
+ end
@@ -0,0 +1,11 @@
1
+ # http://support.flurry.com/index.php?title=API/Code/RawData
2
+ # The RawData API allows you to request a dump of raw session data for one of your applications over
3
+ # a specified time period. Note that this API requires special permissions so please contact flurry
4
+ # support (support@flurry.com) or talk to your Flurry Account Manager for more information.
5
+
6
+ # TODO: Implement the Request Report feature, and the publish
7
+ # module Fryfro
8
+ # class RawData < Endpoint
9
+ # base_uri 'http://api.flurry.com/rawData'
10
+ # end
11
+ # end
@@ -0,0 +1,3 @@
1
+ module Fryfro
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,11 @@
1
+ # encoding: utf-8
2
+
3
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
5
+
6
+ require 'rspec'
7
+ require 'rspec/mocks'
8
+ require 'fyrfro'
9
+
10
+ RSpec.configure do |config|
11
+ end
metadata ADDED
@@ -0,0 +1,149 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fryfro
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Max Riveiro
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-05-21 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.11.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.11.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
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: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '2.13'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '2.13'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec-mocks
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '2.13'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '2.13'
83
+ - !ruby/object:Gem::Dependency
84
+ name: yard
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: 0.8.5
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: 0.8.5
97
+ description: Fryfro provides an interface for the Flurry API.
98
+ email:
99
+ - kavu13@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - .document
105
+ - .gitignore
106
+ - .rspec
107
+ - .travis.yml
108
+ - Gemfile
109
+ - LICENSE.txt
110
+ - README.md
111
+ - Rakefile
112
+ - doc/fryfro.png
113
+ - fryfro.gemspec
114
+ - lib/fryfro.rb
115
+ - lib/fryfro/app.rb
116
+ - lib/fryfro/app_info.rb
117
+ - lib/fryfro/app_metrics.rb
118
+ - lib/fryfro/endpoint.rb
119
+ - lib/fryfro/events_metrics.rb
120
+ - lib/fryfro/raw_data.rb
121
+ - lib/fryfro/version.rb
122
+ - spec/spec_helper.rb
123
+ homepage: https://github.com/kavu/fryfro
124
+ licenses:
125
+ - MIT
126
+ metadata: {}
127
+ post_install_message:
128
+ rdoc_options: []
129
+ require_paths:
130
+ - lib
131
+ required_ruby_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - '>='
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ required_rubygems_version: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - '>='
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ requirements: []
142
+ rubyforge_project:
143
+ rubygems_version: 2.0.1
144
+ signing_key:
145
+ specification_version: 4
146
+ summary: Fryfro is a Flurry API client.
147
+ test_files:
148
+ - spec/spec_helper.rb
149
+ has_rdoc: