sociyal 1.0.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.
- checksums.yaml +7 -0
- data/.cane +1 -0
- data/.gitignore +17 -0
- data/.rspec +4 -0
- data/.rubocop.yml +2 -0
- data/.travis.yml +8 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +52 -0
- data/Rakefile +14 -0
- data/lib/sociyal.rb +8 -0
- data/lib/sociyal/helpers.rb +19 -0
- data/lib/sociyal/version.rb +4 -0
- data/lib/sociyal/widget.rb +35 -0
- data/sociyal.gemspec +25 -0
- data/spec/sociyal/helpers_spec.rb +23 -0
- data/spec/sociyal/widget_spec.rb +93 -0
- data/spec/spec_helper.rb +5 -0
- data/spec/support/default.html +2 -0
- data/spec/support/with_services.html +2 -0
- metadata +158 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7997697ee6cb468b876c48b96ac9016730595cc7
|
4
|
+
data.tar.gz: 9e90282acfca5fcb6531c6d539c3eb9b0aac346e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c38307f7ddd52a101423f3658f68bb2846735df9a7d999c16e7edab5378dcea3194e6dd75f74c1d9276407fc53eabf7873efc39285385facfee99c80566b2551
|
7
|
+
data.tar.gz: ba4c59d72d95ecbfe1bf641a3cc56e461dd9d1835bceac9f6af449c19ba23946c1040460a7b853119a5ec96bb60b32b666005281d924b978f85c870700e473ad
|
data/.cane
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--no-doc
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2016 Alec Norman
|
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,52 @@
|
|
1
|
+
# Sociyal
|
2
|
+
|
3
|
+
Yandex social buttons
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'sociyal'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install sociyal
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Insert this block to view
|
22
|
+
|
23
|
+
<%= sociyal %>
|
24
|
+
|
25
|
+
Optionaly you may use: `:services`, `:lang`, `:image`, `:type`.
|
26
|
+
|
27
|
+
Use `:services` option to specify buttons for which services should be displayed. The default services are: `:vkontakte`, `:facebook`, `:twitter`, `:lj`. Supported services: `:blogger`, `:delicious`, `:diary`, `:digg`, `:evernote`, `:facebook`, `:friendfeed`, `:gplus`, `:juick`, `:liveinternet`, `:linkedin`, `:lj`, `:moikrug`, `:moimir`, `:myspace`, `:odnoklassniki`, `:pinterest`, `:surfingbird`, `:tutby`, `:twitter`, `:vkontakte`, `:yazakladki`.
|
28
|
+
|
29
|
+
<%= sociyal(services: [:twitter, :facebook]) %>
|
30
|
+
|
31
|
+
Use `:lang` option to specify the language for the buttons. The default value is `ru`. Supported values: `:az`,
|
32
|
+
`:be`, `:en`, `:hy`, `:ka`, `:kk`, `:ro`, `:ru`, `:tr`, `:tt`, `:uk`.
|
33
|
+
|
34
|
+
<%= sociyal(lang: :ru) %>
|
35
|
+
|
36
|
+
Use `:image` option to specify the image for sharing on Pinterest. This option is useful only when `:services` option includes `:pinterest`.
|
37
|
+
|
38
|
+
<%= sociyal(image: 'http://example.com/i/photo.jpg') %>
|
39
|
+
|
40
|
+
Use `:type` option to specify the appearance of the buttons. Default value is `:button`. Supported values: `:small`, `:button`, `:link`, `:icon`, `:none`.
|
41
|
+
|
42
|
+
<%= sociyal(type: :small) %>
|
43
|
+
|
44
|
+
## Contributing
|
45
|
+
|
46
|
+
Your contribution is welcome.
|
47
|
+
|
48
|
+
1. Fork it
|
49
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
50
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
51
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
52
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
require 'bundler/gem_tasks'
|
3
|
+
require 'cane/rake_task'
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
|
6
|
+
RSpec::Core::RakeTask.new('spec')
|
7
|
+
|
8
|
+
task default: :spec
|
9
|
+
|
10
|
+
desc 'Run cane to check quality metrics'
|
11
|
+
Cane::RakeTask.new(:quality) do |cane|
|
12
|
+
cane.abc_max = 10
|
13
|
+
cane.no_style = true
|
14
|
+
end
|
data/lib/sociyal.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
module Sociyal
|
2
|
+
module Helpers
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
def yashare(opts = {})
|
6
|
+
attrs = {
|
7
|
+
charset: 'utf-8',
|
8
|
+
type: 'text/javascript',
|
9
|
+
src: '//yastatic.net/share/share.js'
|
10
|
+
}
|
11
|
+
|
12
|
+
script = content_tag(:script, nil, attrs)
|
13
|
+
widget = Sociyal::Widget.new(self, opts)
|
14
|
+
html = [script, widget].join("\n")
|
15
|
+
|
16
|
+
raw(html)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Sociyal
|
2
|
+
class Widget
|
3
|
+
def initialize(view, opts = {})
|
4
|
+
@view = view
|
5
|
+
|
6
|
+
@services = opts.fetch(:services, %w(vkontakte facebook twitter lj))
|
7
|
+
@image = opts.fetch(:image, nil)
|
8
|
+
@type = opts.fetch(:type, 'button')
|
9
|
+
@lang = opts.fetch(:lang, 'ru')
|
10
|
+
end
|
11
|
+
|
12
|
+
def to_s
|
13
|
+
@html ||= render
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def render
|
19
|
+
view.content_tag(:div, nil, class: 'yashare-auto-init', data: data_attrs)
|
20
|
+
end
|
21
|
+
|
22
|
+
def data_attrs
|
23
|
+
{
|
24
|
+
yashareQuickServices: Array(services).join(','),
|
25
|
+
yashareL10n: lang,
|
26
|
+
yashareType: type
|
27
|
+
}.tap do |data|
|
28
|
+
data[:yashareTheme] = 'counter' if type.to_s == 'small'
|
29
|
+
data[:yashareImage] = image if image.present?
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
attr_reader :view, :type, :services, :image, :lang
|
34
|
+
end
|
35
|
+
end
|
data/sociyal.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.expand_path('../lib/sociyal/version', __FILE__)
|
2
|
+
|
3
|
+
Gem::Specification.new do |gem|
|
4
|
+
gem.authors = ['Alec Norman']
|
5
|
+
gem.email = ['']
|
6
|
+
gem.summary = 'Sociyal'
|
7
|
+
gem.description = 'Sociyal'
|
8
|
+
gem.homepage = 'https://github.com/astorre88/sociyal/'
|
9
|
+
gem.license = 'MIT'
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($ORS)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^spec/})
|
14
|
+
gem.name = 'sociyal'
|
15
|
+
gem.require_paths = ['lib']
|
16
|
+
gem.version = Sociyal::VERSION
|
17
|
+
|
18
|
+
gem.add_runtime_dependency 'activesupport', '>= 4.2.6'
|
19
|
+
|
20
|
+
gem.add_development_dependency 'rspec', '~> 3'
|
21
|
+
gem.add_development_dependency 'actionpack', '~> 4'
|
22
|
+
gem.add_development_dependency 'rubocop', '~> 0.30'
|
23
|
+
gem.add_development_dependency 'cane', '~> 2.6', '>= 2.6.1'
|
24
|
+
gem.add_development_dependency 'codeclimate-test-reporter', '~> 0.4'
|
25
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Sociyal::Helpers do
|
4
|
+
describe '#yashare' do
|
5
|
+
let(:view) { ActionView::Base.new }
|
6
|
+
|
7
|
+
context 'no options specified' do
|
8
|
+
subject { view.yashare }
|
9
|
+
|
10
|
+
let(:expected) { File.read('./spec/support/default.html').strip }
|
11
|
+
|
12
|
+
it { is_expected.to eq(expected) }
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'services specified' do
|
16
|
+
subject { view.yashare(services: :facebook) }
|
17
|
+
|
18
|
+
let(:expected) { File.read('./spec/support/with_services.html').strip }
|
19
|
+
|
20
|
+
it { is_expected.to eq(expected) }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Sociyal::Widget do
|
4
|
+
let(:view) { ActionView::Base.new }
|
5
|
+
|
6
|
+
describe '#to_s' do
|
7
|
+
context 'no options specified' do
|
8
|
+
subject { described_class.new(view).to_s }
|
9
|
+
|
10
|
+
let(:expected) do
|
11
|
+
'<div
|
12
|
+
class="yashare-auto-init"
|
13
|
+
data-yashareQuickServices="vkontakte,facebook,twitter,lj"
|
14
|
+
data-yashareL10n="ru"
|
15
|
+
data-yashareType="button"></div>'.gsub(/\s+/, ' ')
|
16
|
+
end
|
17
|
+
|
18
|
+
it { is_expected.to eq(expected) }
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'one service specified' do
|
22
|
+
subject { described_class.new(view, services: 'vkontakte').to_s }
|
23
|
+
|
24
|
+
let(:expected) do
|
25
|
+
'<div
|
26
|
+
class="yashare-auto-init"
|
27
|
+
data-yashareQuickServices="vkontakte"
|
28
|
+
data-yashareL10n="ru"
|
29
|
+
data-yashareType="button"></div>'.gsub(/\s+/, ' ')
|
30
|
+
end
|
31
|
+
|
32
|
+
it { is_expected.to eq(expected) }
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'services specified' do
|
36
|
+
subject { described_class.new(view, services: ['vkontakte', 'lj']).to_s }
|
37
|
+
|
38
|
+
let(:expected) do
|
39
|
+
'<div
|
40
|
+
class="yashare-auto-init"
|
41
|
+
data-yashareQuickServices="vkontakte,lj"
|
42
|
+
data-yashareL10n="ru"
|
43
|
+
data-yashareType="button"></div>'.gsub(/\s+/, ' ')
|
44
|
+
end
|
45
|
+
|
46
|
+
it { is_expected.to eq(expected) }
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'language specified' do
|
50
|
+
subject { described_class.new(view, lang: 'en').to_s }
|
51
|
+
|
52
|
+
let(:expected) do
|
53
|
+
'<div
|
54
|
+
class="yashare-auto-init"
|
55
|
+
data-yashareQuickServices="vkontakte,facebook,twitter,lj"
|
56
|
+
data-yashareL10n="en"
|
57
|
+
data-yashareType="button"></div>'.gsub(/\s+/, ' ')
|
58
|
+
end
|
59
|
+
|
60
|
+
it { is_expected.to eq(expected) }
|
61
|
+
end
|
62
|
+
|
63
|
+
context 'image specified' do
|
64
|
+
subject { described_class.new(view, image: '/img.png').to_s }
|
65
|
+
|
66
|
+
let(:expected) do
|
67
|
+
'<div
|
68
|
+
class="yashare-auto-init"
|
69
|
+
data-yashareQuickServices="vkontakte,facebook,twitter,lj"
|
70
|
+
data-yashareL10n="ru"
|
71
|
+
data-yashareType="button"
|
72
|
+
data-yashareImage="/img.png"></div>'.gsub(/\s+/, ' ')
|
73
|
+
end
|
74
|
+
|
75
|
+
it { is_expected.to eq(expected) }
|
76
|
+
end
|
77
|
+
|
78
|
+
context 'image specified' do
|
79
|
+
subject { described_class.new(view, type: 'small').to_s }
|
80
|
+
|
81
|
+
let(:expected) do
|
82
|
+
'<div
|
83
|
+
class="yashare-auto-init"
|
84
|
+
data-yashareQuickServices="vkontakte,facebook,twitter,lj"
|
85
|
+
data-yashareL10n="ru"
|
86
|
+
data-yashareType="small"
|
87
|
+
data-yashareTheme="counter"></div>'.gsub(/\s+/, ' ')
|
88
|
+
end
|
89
|
+
|
90
|
+
it { is_expected.to eq(expected) }
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,158 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sociyal
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alec Norman
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-07-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 4.2.6
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 4.2.6
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: actionpack
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '4'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '4'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.30'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.30'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: cane
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '2.6'
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 2.6.1
|
79
|
+
type: :development
|
80
|
+
prerelease: false
|
81
|
+
version_requirements: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - "~>"
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '2.6'
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 2.6.1
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: codeclimate-test-reporter
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - "~>"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0.4'
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - "~>"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0.4'
|
103
|
+
description: Sociyal
|
104
|
+
email:
|
105
|
+
- ''
|
106
|
+
executables: []
|
107
|
+
extensions: []
|
108
|
+
extra_rdoc_files: []
|
109
|
+
files:
|
110
|
+
- ".cane"
|
111
|
+
- ".gitignore"
|
112
|
+
- ".rspec"
|
113
|
+
- ".rubocop.yml"
|
114
|
+
- ".travis.yml"
|
115
|
+
- Gemfile
|
116
|
+
- LICENSE
|
117
|
+
- README.md
|
118
|
+
- Rakefile
|
119
|
+
- lib/sociyal.rb
|
120
|
+
- lib/sociyal/helpers.rb
|
121
|
+
- lib/sociyal/version.rb
|
122
|
+
- lib/sociyal/widget.rb
|
123
|
+
- sociyal.gemspec
|
124
|
+
- spec/sociyal/helpers_spec.rb
|
125
|
+
- spec/sociyal/widget_spec.rb
|
126
|
+
- spec/spec_helper.rb
|
127
|
+
- spec/support/default.html
|
128
|
+
- spec/support/with_services.html
|
129
|
+
homepage: https://github.com/astorre88/sociyal/
|
130
|
+
licenses:
|
131
|
+
- MIT
|
132
|
+
metadata: {}
|
133
|
+
post_install_message:
|
134
|
+
rdoc_options: []
|
135
|
+
require_paths:
|
136
|
+
- lib
|
137
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - ">="
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
requirements: []
|
148
|
+
rubyforge_project:
|
149
|
+
rubygems_version: 2.5.1
|
150
|
+
signing_key:
|
151
|
+
specification_version: 4
|
152
|
+
summary: Sociyal
|
153
|
+
test_files:
|
154
|
+
- spec/sociyal/helpers_spec.rb
|
155
|
+
- spec/sociyal/widget_spec.rb
|
156
|
+
- spec/spec_helper.rb
|
157
|
+
- spec/support/default.html
|
158
|
+
- spec/support/with_services.html
|