quintly 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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e1a62919d53c364cddeee0a1f4a7f33c4d5577ee
4
+ data.tar.gz: 10990df37bf2078235700dd1a327eab2373d2561
5
+ SHA512:
6
+ metadata.gz: 8b9bd2094c51e6c1f153044bc6f658932b8baaa9e28250dee83f1bf0881567c5a7b2db287a54f152b72bba29e5ebcd12fab98a414380793029265cd2cfe184a0
7
+ data.tar.gz: 3b1d4255e6dab9765063228b0e5d7755ce18ad3ae4134b7105d24a004f182c865e59934a04a48ceaa8ea6211fe8c32251af95717c6b3d848fa44a045f9d59587
@@ -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/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.1
4
+ before_install: gem install bundler -v 1.10.3
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in quintly.gemspec
4
+ gemspec
@@ -0,0 +1,58 @@
1
+ # Quintly
2
+
3
+ This is a sample gem to wrap Quintly API https://api.quintly.com
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'quintly'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install quintly
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ require 'quintly'
25
+
26
+ configuration = Quintly::Configuration.new do |conf|
27
+ start_time: '2013-08-01',
28
+ end_time: '2013-08-15',
29
+ interval: 'daily', #(daily, weekly, monthly, yearly, total)
30
+ profile_ids: 1111,
31
+ username: 'your username',
32
+ password: 'your password'
33
+ end
34
+
35
+ # get fanCount info with predefined metric
36
+ result = Quintly::QQL.metric('fanCount').first
37
+ #=> {"dim1"=>1111, "dim2"=>"2013-08-01 00:00:00", "fans"=>1340103}
38
+
39
+ # get fanCount info with QQL
40
+ result = Quintly::QQL.query('SELECT profileId, time, fans FROM facebook').first
41
+ #=> {"profileId"=>1111, "time"=>"2013-08-01 00:00:00", "fans"=>1340103}
42
+
43
+
44
+ ```
45
+
46
+ ## Development
47
+
48
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
49
+
50
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
51
+
52
+ ## Contributing
53
+
54
+ Bug reports and pull requests are welcome on GitHub at https://github.com/chorally/quintly.
55
+
56
+
57
+ ## License
58
+ The restcountry GEM is released under the MIT License.
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "quintly"
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
@@ -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
@@ -0,0 +1,7 @@
1
+ require 'quintly/version'
2
+ require 'quintly/configuration'
3
+ require 'quintly/qql'
4
+
5
+ module Quintly
6
+
7
+ end
@@ -0,0 +1,21 @@
1
+ module Quintly
2
+ class Configuration
3
+ ATTRIBUTES = [
4
+ :username,
5
+ :password
6
+ ]
7
+
8
+ ATTRIBUTES.each { |attribute| attr_accessor attribute }
9
+
10
+ def initialize
11
+ yield self if block_given?
12
+ end
13
+
14
+ def valid?
15
+ ATTRIBUTES.each do |attribute|
16
+ return false if self.send(attribute).nil? || self.send(attribute).empty?
17
+ end
18
+ true
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,41 @@
1
+ require 'faraday'
2
+ require 'json'
3
+ require 'uri'
4
+
5
+ module Quintly
6
+ class QQL < Struct.new(:configuration)
7
+ SERVICE_URL = 'https://api.quintly.com'
8
+ API_VERSION = 'v0.9'
9
+
10
+ def metric(metric)
11
+ call('metric', metric)
12
+ end
13
+
14
+ def query(qql_query)
15
+ call('qqlQuery', qql_query)
16
+ end
17
+
18
+ private
19
+
20
+ def api_client
21
+ connection = Faraday.new(SERVICE_URL)
22
+ connection.basic_auth(
23
+ configuration.username, configuration.password
24
+ )
25
+ connection
26
+ end
27
+
28
+ def call(api, action)
29
+ url = URI.parse(URI.encode(
30
+ "/#{API_VERSION}/qql?#{api}=#{action}&" +
31
+ "startTime=#{configuration.start_time}&" +
32
+ "endTime=#{configuration.end_time}&" +
33
+ "interval=#{configuration.interval}&" +
34
+ "profileIds=#{configuration.profile_ids}")
35
+ )
36
+ response = api_client.get(url)
37
+ puts JSON.parse(response.body)['data']
38
+ response.success? ? JSON.parse(response.body)['data'] : []
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,3 @@
1
+ module Quintly
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,40 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'quintly/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "quintly"
8
+ spec.version = Quintly::VERSION
9
+ spec.authors = ["Davide Santangelo"]
10
+ spec.email = ["davide@chorally.com"]
11
+
12
+ spec.summary = %q{Gem to wrap Quintly API}
13
+ spec.description = %q{Basic API implementation for Quintly API https://api.quintly.com}
14
+ spec.homepage = "https://github.com/chorally/quintly"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency "bundler", "~> 1.10"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+ spec.add_development_dependency 'rspec'
33
+ spec.add_development_dependency "vcr"
34
+ spec.add_development_dependency "typhoeus"
35
+
36
+ spec.required_ruby_version = ">= 1.9.3"
37
+
38
+ spec.add_dependency "faraday"
39
+ spec.add_dependency "json"
40
+ end
metadata ADDED
@@ -0,0 +1,156 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: quintly
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Davide Santangelo
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-10-07 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.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
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
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: vcr
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
+ - !ruby/object:Gem::Dependency
70
+ name: typhoeus
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: faraday
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: json
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: Basic API implementation for Quintly API https://api.quintly.com
112
+ email:
113
+ - davide@chorally.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - ".rspec"
120
+ - ".travis.yml"
121
+ - Gemfile
122
+ - README.md
123
+ - Rakefile
124
+ - bin/console
125
+ - bin/setup
126
+ - lib/quintly.rb
127
+ - lib/quintly/configuration.rb
128
+ - lib/quintly/qql.rb
129
+ - lib/quintly/version.rb
130
+ - quintly.gemspec
131
+ homepage: https://github.com/chorally/quintly
132
+ licenses:
133
+ - MIT
134
+ metadata:
135
+ allowed_push_host: https://rubygems.org
136
+ post_install_message:
137
+ rdoc_options: []
138
+ require_paths:
139
+ - lib
140
+ required_ruby_version: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: 1.9.3
145
+ required_rubygems_version: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - ">="
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ requirements: []
151
+ rubyforge_project:
152
+ rubygems_version: 2.4.8
153
+ signing_key:
154
+ specification_version: 4
155
+ summary: Gem to wrap Quintly API
156
+ test_files: []