sharedcount 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: 1aa55830f7d51cc5fc0d7bbb7d7ced3fa5684347
4
+ data.tar.gz: d65c2e171d8d11dc2cc0fe9b66e83231713ec772
5
+ SHA512:
6
+ metadata.gz: 94edc4c6a349f7907937d8c4b1cd270d1e564c24a9e0cdf5d39dfc52c80f15adb4c43db52161464aa7a9fe6fc04b0d9987952d79c602e305e8feb46e46595b3b
7
+ data.tar.gz: a7868706901447f1cc938ce54defaa8017f7181df11c5933e8068ef8d63b800292426b150f0c64c05d6ad3db428fcb95696a89525181b7ca125037fef05f86a0
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/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.1
4
+ before_install: gem install bundler -v 1.10.5
@@ -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, ethnicity, 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 sharedcount.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Andrea Mostosi
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,75 @@
1
+ # SharedCount Ruby Gem
2
+
3
+ ## Installation
4
+
5
+ Add this line to your application's Gemfile:
6
+
7
+ ```ruby
8
+ gem 'sharedcount'
9
+ ```
10
+
11
+ And then execute:
12
+
13
+ ```bash
14
+ bundle install
15
+ ```
16
+
17
+ ## Setup
18
+
19
+ Setup configuration parameters
20
+
21
+ ```ruby
22
+ require "sharedcount"
23
+
24
+ Sharedcount.configure do |c|
25
+ c.apikey = "your-api-key"
26
+ c.endpoint = "http://free.sharedcount.com/"
27
+ end
28
+ ```
29
+
30
+ ## Usage
31
+
32
+ ```ruby
33
+ api = Sharedcount::API.new
34
+ response = api.fetch("http://www.example.com/some-page.html")
35
+
36
+ # Raw response from SharedCount
37
+ response.raw_data
38
+ => {"StumbleUpon"=>0,
39
+ "Reddit"=>0,
40
+ "Facebook"=>{
41
+ "commentsbox_count"=>0,
42
+ "click_count"=>0,
43
+ "total_count"=>35,
44
+ "comment_count"=>4,
45
+ "like_count"=>6,
46
+ "share_count"=>25},
47
+ "Delicious"=>0,
48
+ "GooglePlusOne"=>7,
49
+ "Buzz"=>0,
50
+ "Twitter"=>0,
51
+ "Diggs"=>0,
52
+ "Pinterest"=>0,
53
+ "LinkedIn"=>0}
54
+
55
+ # Sum of all social actions
56
+ response.total_actions
57
+ => 42
58
+
59
+ # Other methods
60
+ response.stumble_upon_shares
61
+ response.reddit_shares
62
+ response.delicious_shares
63
+ response.google_plus_one
64
+ response.google_buzzs
65
+ response.twitter_shares
66
+ response.digg_shares
67
+ response.pinterest_shares
68
+ response.linkedin_shares
69
+ response.facebook_commentsbox
70
+ response.facebook_clicks
71
+ response.facebook_total
72
+ response.facebook_comments
73
+ response.facebook_likes
74
+ response.facebook_shares
75
+ ```
data/Rakefile ADDED
@@ -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
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "sharedcount"
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
@@ -0,0 +1,19 @@
1
+ require "sharedcount/data"
2
+ require "sharedcount/api"
3
+ require "sharedcount/version"
4
+
5
+ module Sharedcount
6
+
7
+ def self.configure(&block)
8
+ yield @config ||= Configuration.new
9
+ end
10
+
11
+ def self.config
12
+ @config
13
+ end
14
+
15
+ class Configuration
16
+ attr_accessor :apikey, :endpoint
17
+ end
18
+
19
+ end
@@ -0,0 +1,25 @@
1
+ require "faraday"
2
+ require "json"
3
+
4
+ module Sharedcount
5
+ class API
6
+
7
+ attr_accessor :connection, :endpoint, :apikey
8
+
9
+ def initialize(endpoint = nil, apikey = nil)
10
+ self.endpoint = endpoint || Sharedcount.config.endpoint
11
+ self.apikey = apikey || Sharedcount.config.apikey
12
+ self.connection = Faraday.new(:url => self.endpoint) do |faraday|
13
+ faraday.request :url_encoded
14
+ faraday.adapter Faraday.default_adapter
15
+ end
16
+ end
17
+
18
+ def fetch(url)
19
+ response = self.connection.get "/?apikey=#{self.apikey}&url=#{url}"
20
+ raw_data = JSON.parse(response.body)
21
+ return Sharedcount::Data.new(raw_data)
22
+ end
23
+
24
+ end
25
+ end
@@ -0,0 +1,35 @@
1
+ module Sharedcount
2
+ class Data
3
+
4
+ attr_accessor :stumble_upon_shares, :reddit_shares, :facebook_commentsbox,
5
+ :facebook_clicks, :facebook_total, :facebook_comments, :facebook_likes,
6
+ :facebook_shares, :delicious_shares, :google_plus_one, :google_buzzs,
7
+ :twitter_shares, :pinterest_shares, :digg_shares, :linkedin_shares,
8
+ :total_actions, :raw_data
9
+
10
+ def initialize(data)
11
+
12
+ self.raw_data = data
13
+
14
+ self.stumble_upon_shares = (data["StumbleUpon"] || nil)
15
+ self.reddit_shares = (data["Reddit"] || nil)
16
+ self.delicious_shares = (data["Delicious"] || nil)
17
+ self.google_plus_one = (data["GooglePlusOne"] || nil)
18
+ self.google_buzzs = (data["Buzz"] || nil)
19
+ self.twitter_shares = (data["Twitter"] || nil)
20
+ self.digg_shares = (data["Diggs"] || nil)
21
+ self.pinterest_shares = (data["Pinterest"] || nil)
22
+ self.linkedin_shares = (data["LinkedIn"] || nil)
23
+ self.facebook_commentsbox = (data["Facebook"]["commentsbox_count"] || nil)
24
+ self.facebook_clicks = (data["Facebook"]["click_count"] || nil)
25
+ self.facebook_total = (data["Facebook"]["total_count"] || nil)
26
+ self.facebook_comments = (data["Facebook"]["comment_count"] || nil)
27
+ self.facebook_likes = (data["Facebook"]["like_count"] || nil)
28
+ self.facebook_shares = (data["Facebook"]["share_count"] || nil)
29
+
30
+ self.total_actions = self.stumble_upon_shares + self.reddit_shares + self.delicious_shares + self.google_plus_one + self.google_buzzs + self.twitter_shares + self.digg_shares + self.pinterest_shares + self.linkedin_shares + self.facebook_total
31
+
32
+ end
33
+
34
+ end
35
+ end
@@ -0,0 +1,3 @@
1
+ module Sharedcount
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'sharedcount/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "sharedcount"
8
+ spec.version = Sharedcount::VERSION
9
+ spec.authors = ["Andrea Mostosi"]
10
+ spec.email = ["andrea.mostosi@zenkay.net"]
11
+
12
+ spec.summary = %q{SharedCount API gem}
13
+ spec.description = %q{Connector for SharedCount API service}
14
+ spec.homepage = "https://github.com/zenkay/sharedcount-ruby"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_dependency "faraday", '~> 0.9', '>= 0.9.0'
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.10"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rspec"
27
+ end
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sharedcount
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Andrea Mostosi
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-09-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.9'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.9.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '0.9'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 0.9.0
33
+ - !ruby/object:Gem::Dependency
34
+ name: bundler
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.10'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '1.10'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '10.0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '10.0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rspec
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ description: Connector for SharedCount API service
76
+ email:
77
+ - andrea.mostosi@zenkay.net
78
+ executables: []
79
+ extensions: []
80
+ extra_rdoc_files: []
81
+ files:
82
+ - ".gitignore"
83
+ - ".rspec"
84
+ - ".travis.yml"
85
+ - CODE_OF_CONDUCT.md
86
+ - Gemfile
87
+ - LICENSE.txt
88
+ - README.md
89
+ - Rakefile
90
+ - bin/console
91
+ - bin/setup
92
+ - lib/sharedcount.rb
93
+ - lib/sharedcount/api.rb
94
+ - lib/sharedcount/data.rb
95
+ - lib/sharedcount/version.rb
96
+ - sharedcount.gemspec
97
+ homepage: https://github.com/zenkay/sharedcount-ruby
98
+ licenses:
99
+ - MIT
100
+ metadata: {}
101
+ post_install_message:
102
+ rdoc_options: []
103
+ require_paths:
104
+ - lib
105
+ required_ruby_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ required_rubygems_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ requirements: []
116
+ rubyforge_project:
117
+ rubygems_version: 2.4.6
118
+ signing_key:
119
+ specification_version: 4
120
+ summary: SharedCount API gem
121
+ test_files: []
122
+ has_rdoc: