yashare 0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4ca068e99dd62b4586fe3b5b73c184588aff24a4
4
+ data.tar.gz: e35390cf154918c50887fa138c00e85a6a9b5a8d
5
+ SHA512:
6
+ metadata.gz: b75ad2383c5249f94446525a83cfcea562e35f9e721b237ddddfe0b92af73150fe7e2c9d97424f20813e802a001ed20b9ae50f24a6db8abe76cf8a81575e952c
7
+ data.tar.gz: c708455cf0c2853c3deba162e715faa8a42b7ad9644ad9f286d1dfd8267ce326f84bf12d221d7266e5820f82210976f5b2f8b6c5a599b70b272e39d76112fa19
data/.cane ADDED
@@ -0,0 +1 @@
1
+ --no-doc
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,4 @@
1
+ --order random
2
+ --colour
3
+ --backtrace
4
+ --format progress
data/.rubocop.yml ADDED
@@ -0,0 +1,2 @@
1
+ Documentation:
2
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ rvm:
2
+ - 2.2.0
3
+ - 2.1.0
4
+ - 2.0.0
5
+ - 1.9.3
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+ gem 'rake'
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Andrew Gridnev
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,29 @@
1
+ # YaShare
2
+
3
+ ## Installation
4
+
5
+ Add this line to your application's Gemfile:
6
+
7
+ gem 'yashare'
8
+
9
+ And then execute:
10
+
11
+ $ bundle
12
+
13
+ Or install it yourself as:
14
+
15
+ $ gem install yashare
16
+
17
+ ## Usage
18
+
19
+ TODO
20
+
21
+ ## Contributing
22
+
23
+ Your contribution is welcome.
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 'Added some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 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/yashare.rb ADDED
@@ -0,0 +1,8 @@
1
+ require 'active_support'
2
+ require 'yashare/version'
3
+ require 'yashare/helpers'
4
+ require 'yashare/widget'
5
+
6
+ ActiveSupport.on_load(:action_view) do
7
+ include Yashare::Helpers
8
+ end
@@ -0,0 +1,18 @@
1
+ module Yashare
2
+ module Helpers
3
+ extend ActiveSupport::Concern
4
+
5
+ def yashare(opts={})
6
+ script = content_tag(:script, nil,
7
+ charset: 'utf-8',
8
+ type: 'text/javascript',
9
+ src: '//yastatic.net/share/share.js'
10
+ )
11
+
12
+ div = content_tag(:div)
13
+
14
+ html = [script, Yashare::Widget.new(self, opts)].join("\n")
15
+ self.raw(html)
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,4 @@
1
+ module Yashare
2
+ # Gem version
3
+ VERSION = '0.1'
4
+ end
@@ -0,0 +1,37 @@
1
+ module Yashare
2
+ class Widget
3
+ def initialize(view, opts={})
4
+ @view = view
5
+
6
+ @services = opts.fetch(:services, ['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
+ attrs = {
14
+ class: 'yashare-auto-init',
15
+ data: {
16
+ yashareL10n: lang,
17
+ yashareType: type,
18
+ yashareQuickServices: services.join(',')
19
+ }
20
+ }
21
+
22
+ if type == 'small'
23
+ attrs[:data][:yashareTheme] = 'counter'
24
+ end
25
+
26
+ if image.present?
27
+ attrs[:data][:yashareImage] = image
28
+ end
29
+
30
+ view.content_tag(:div, nil, attrs)
31
+ end
32
+
33
+ private
34
+
35
+ attr_reader :view, :type, :services, :image, :lang
36
+ end
37
+ end
@@ -0,0 +1 @@
1
+ require 'yashare'
data/yashare.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ require File.expand_path('../lib/yashare/version', __FILE__)
2
+
3
+ Gem::Specification.new do |gem|
4
+ gem.authors = ['Andrei Gridnev']
5
+ gem.email = ['andrew.gridnev@gmail.com']
6
+ gem.summary = 'Yandex Share buttons for your Rails app'
7
+ gem.description = 'Add and customize Yandex Share buttons to your Rails app'
8
+ gem.homepage = 'https://github.com/andrewgr/yashare/'
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 = 'yashare'
15
+ gem.require_paths = ['lib']
16
+ gem.version = Yashare::VERSION
17
+
18
+ gem.add_runtime_dependency 'activesupport', '~> 4'
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
+ end
metadata ADDED
@@ -0,0 +1,136 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yashare
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ platform: ruby
6
+ authors:
7
+ - Andrei Gridnev
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-05-10 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'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4'
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
+ description: Add and customize Yandex Share buttons to your Rails app
90
+ email:
91
+ - andrew.gridnev@gmail.com
92
+ executables: []
93
+ extensions: []
94
+ extra_rdoc_files: []
95
+ files:
96
+ - ".cane"
97
+ - ".gitignore"
98
+ - ".rspec"
99
+ - ".rubocop.yml"
100
+ - ".travis.yml"
101
+ - Gemfile
102
+ - LICENSE
103
+ - README.md
104
+ - Rakefile
105
+ - lib/yashare.rb
106
+ - lib/yashare/helpers.rb
107
+ - lib/yashare/version.rb
108
+ - lib/yashare/widget.rb
109
+ - spec/spec_helper.rb
110
+ - yashare.gemspec
111
+ homepage: https://github.com/andrewgr/yashare/
112
+ licenses:
113
+ - MIT
114
+ metadata: {}
115
+ post_install_message:
116
+ rdoc_options: []
117
+ require_paths:
118
+ - lib
119
+ required_ruby_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ required_rubygems_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ requirements: []
130
+ rubyforge_project:
131
+ rubygems_version: 2.2.2
132
+ signing_key:
133
+ specification_version: 4
134
+ summary: Yandex Share buttons for your Rails app
135
+ test_files:
136
+ - spec/spec_helper.rb