social-url 1.1.0 → 1.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: d011ff092db1bcb067cf63d00f8a35fdf86f1e1d
4
- data.tar.gz: b025ef99deda02e311090322bd760145a5dd8b4d
2
+ SHA256:
3
+ metadata.gz: d2c6aa71b7cdf9b1f24a01a7145c3ef172a5503d6e7eca715b2cc7df1427740d
4
+ data.tar.gz: 654f25781cc60e76bafaeb4b5020052ffc8b38841f152915c3646ba3499a46bb
5
5
  SHA512:
6
- metadata.gz: 887b9b1c38a8b8cc65e3f44112435a753bd646ded8671b53734addc91f4d197c6eecbbc94f025770e0f5ce3d815c065d9e7f5fc0b66ab88791153659067314ec
7
- data.tar.gz: 884439c80675cd43bd6e6e7e44c08670f3ff12c161064ecbef43e03745cb8e42cf6cf0d8356134ff91537d0b410575bdb277337d347c373bacef3cfbe2a7071e
6
+ metadata.gz: d0e4b062aa4797a7143ddf75f3838073cc9a1899574531de34e44e1062433b437410f79298fdb90b545c1d25f01f6de9b28c63927e505467295d34df2830e9af
7
+ data.tar.gz: 3e0f5026ab62c48ac6ed78b9da15eeb8b108e5c6386ee5769b006cc7a27e49908dbcdd097a33e9f9b70445efbefbf2525c279337de996910fe573a16b1f018be
@@ -0,0 +1,11 @@
1
+ version: "2"
2
+ plugins:
3
+ fixme:
4
+ enabled: true
5
+ reek:
6
+ enabled: true
7
+ rubocop:
8
+ enabled: true
9
+ channel: rubocop-0-60
10
+ exclude_patterns:
11
+ - test/**/*
data/.gitignore CHANGED
@@ -1,2 +1,3 @@
1
1
  coverage
2
- tmp
2
+ Gemfile.lock
3
+ tmp
@@ -0,0 +1,227 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.2
3
+ # RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
4
+ # to ignore them, so only the ones explicitly set in this file are enabled.
5
+ DisabledByDefault: true
6
+ Exclude:
7
+ - '**/templates/**/*'
8
+ - '**/vendor/**/*'
9
+ - 'actionpack/lib/action_dispatch/journey/parser.rb'
10
+ - 'railties/test/fixtures/tmp/**/*'
11
+ - 'node_modules/**/*'
12
+ # rubocop default exclude
13
+ - '.git/**/*'
14
+ # Additional exclude files by rubocop-rails_config
15
+ - 'bin/**/*'
16
+ - 'config/**/*'
17
+ - 'db/**/*'
18
+
19
+ Performance:
20
+ Exclude:
21
+ - '**/test/**/*'
22
+
23
+ Rails:
24
+ Enabled: true
25
+
26
+ # Prefer assert_not over assert !
27
+ Rails/AssertNot:
28
+ Include:
29
+ - '**/test/**/*'
30
+
31
+ # Prefer assert_not_x over refute_x
32
+ Rails/RefuteMethods:
33
+ Include:
34
+ - '**/test/**/*'
35
+
36
+ # Prefer &&/|| over and/or.
37
+ Style/AndOr:
38
+ Enabled: true
39
+
40
+ # Do not use braces for hash literals when they are the last argument of a
41
+ # method call.
42
+ Style/BracesAroundHashParameters:
43
+ Enabled: true
44
+ EnforcedStyle: context_dependent
45
+
46
+ # Align `when` with `case`.
47
+ Layout/CaseIndentation:
48
+ Enabled: true
49
+
50
+ # Align comments with method definitions.
51
+ Layout/CommentIndentation:
52
+ Enabled: true
53
+
54
+ Layout/ElseAlignment:
55
+ Enabled: true
56
+
57
+ # Align `end` with the matching keyword or starting expression except for
58
+ # assignments, where it should be aligned with the LHS.
59
+ Layout/EndAlignment:
60
+ Enabled: true
61
+ EnforcedStyleAlignWith: variable
62
+ AutoCorrect: true
63
+
64
+ Layout/EmptyLineAfterMagicComment:
65
+ Enabled: true
66
+
67
+ Layout/EmptyLinesAroundBlockBody:
68
+ Enabled: true
69
+
70
+ # In a regular class definition, no empty lines around the body.
71
+ Layout/EmptyLinesAroundClassBody:
72
+ Enabled: true
73
+
74
+ # In a regular method definition, no empty lines around the body.
75
+ Layout/EmptyLinesAroundMethodBody:
76
+ Enabled: true
77
+
78
+ # In a regular module definition, no empty lines around the body.
79
+ Layout/EmptyLinesAroundModuleBody:
80
+ Enabled: true
81
+
82
+ Layout/FirstParameterIndentation:
83
+ Enabled: true
84
+
85
+ # Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
86
+ Style/HashSyntax:
87
+ Enabled: true
88
+
89
+ # Method definitions after `private` or `protected` isolated calls need one
90
+ # extra level of indentation.
91
+ Layout/IndentationConsistency:
92
+ Enabled: true
93
+ EnforcedStyle: rails
94
+
95
+ # Two spaces, no tabs (for indentation).
96
+ Layout/IndentationWidth:
97
+ Enabled: true
98
+
99
+ Layout/LeadingCommentSpace:
100
+ Enabled: true
101
+
102
+ Layout/SpaceAfterColon:
103
+ Enabled: true
104
+
105
+ Layout/SpaceAfterComma:
106
+ Enabled: true
107
+
108
+ Layout/SpaceAroundEqualsInParameterDefault:
109
+ Enabled: true
110
+
111
+ Layout/SpaceAroundKeyword:
112
+ Enabled: true
113
+
114
+ Layout/SpaceAroundOperators:
115
+ Enabled: true
116
+
117
+ Layout/SpaceBeforeComma:
118
+ Enabled: true
119
+
120
+ Layout/SpaceBeforeFirstArg:
121
+ Enabled: true
122
+
123
+ Style/DefWithParentheses:
124
+ Enabled: true
125
+
126
+ # Defining a method with parameters needs parentheses.
127
+ Style/MethodDefParentheses:
128
+ Enabled: true
129
+
130
+ Style/FrozenStringLiteralComment:
131
+ Enabled: true
132
+ EnforcedStyle: always
133
+ Exclude:
134
+ - 'actionview/test/**/*.builder'
135
+ - 'actionview/test/**/*.ruby'
136
+ - 'actionpack/test/**/*.builder'
137
+ - 'actionpack/test/**/*.ruby'
138
+ - 'activestorage/db/migrate/**/*.rb'
139
+
140
+ Style/RedundantFreeze:
141
+ Enabled: true
142
+ Exclude:
143
+ - 'actionpack/lib/action_dispatch/journey/router/utils.rb'
144
+ - 'activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb'
145
+
146
+ # Use `foo {}` not `foo{}`.
147
+ Layout/SpaceBeforeBlockBraces:
148
+ Enabled: true
149
+
150
+ # Use `foo { bar }` not `foo {bar}`.
151
+ Layout/SpaceInsideBlockBraces:
152
+ Enabled: true
153
+ EnforcedStyleForEmptyBraces: space
154
+
155
+ # Use `{ a: 1 }` not `{a:1}`.
156
+ Layout/SpaceInsideHashLiteralBraces:
157
+ Enabled: true
158
+
159
+ Layout/SpaceInsideParens:
160
+ Enabled: true
161
+
162
+ # Check quotes usage according to lint rule below.
163
+ Style/StringLiterals:
164
+ Enabled: true
165
+ EnforcedStyle: double_quotes
166
+
167
+ # Detect hard tabs, no hard tabs.
168
+ Layout/Tab:
169
+ Enabled: true
170
+
171
+ # Blank lines should not have any spaces.
172
+ Layout/TrailingBlankLines:
173
+ Enabled: true
174
+
175
+ # No trailing whitespace.
176
+ Layout/TrailingWhitespace:
177
+ Enabled: true
178
+
179
+ # Use quotes for string literals when they are enough.
180
+ Style/UnneededPercentQ:
181
+ Enabled: true
182
+
183
+ # Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
184
+ Lint/RequireParentheses:
185
+ Enabled: true
186
+
187
+ Lint/StringConversionInInterpolation:
188
+ Enabled: true
189
+
190
+ Lint/UriEscapeUnescape:
191
+ Enabled: true
192
+
193
+ Style/ParenthesesAroundCondition:
194
+ Enabled: true
195
+
196
+ Style/RedundantReturn:
197
+ Enabled: true
198
+ AllowMultipleReturnValues: true
199
+
200
+ Style/Semicolon:
201
+ Enabled: true
202
+ AllowAsExpressionSeparator: true
203
+
204
+ # Prefer Foo.method over Foo::method
205
+ Style/ColonMethodCall:
206
+ Enabled: true
207
+
208
+ Style/TrivialAccessors:
209
+ Enabled: true
210
+
211
+ Performance/FlatMap:
212
+ Enabled: true
213
+
214
+ Performance/RedundantMerge:
215
+ Enabled: true
216
+
217
+ Performance/StartWith:
218
+ Enabled: true
219
+
220
+ Performance/EndWith:
221
+ Enabled: true
222
+
223
+ Performance/RegexpMatch:
224
+ Enabled: true
225
+
226
+ Performance/UnfreezeString:
227
+ Enabled: true
@@ -0,0 +1 @@
1
+ 2.5.3
@@ -1,11 +1,21 @@
1
+ env:
2
+ global:
3
+ - CC_TEST_REPORTER_ID=e45cb4cbea2601c1f2c94402aac0be86b2a79b993fe669c06f53dd0069f23cfd
4
+
1
5
  language: ruby
2
6
 
7
+ cache: bundler
8
+
3
9
  rvm:
4
- - 1.9.3
5
- - 2.0
6
- - 2.1
7
- - 2.2.1
8
-
9
- addons:
10
- code_climate:
11
- repo_token: e45cb4cbea2601c1f2c94402aac0be86b2a79b993fe669c06f53dd0069f23cfd
10
+ - 2.3.8
11
+ - 2.4.5
12
+ - 2.5.3
13
+
14
+ before_script:
15
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
16
+ - chmod +x ./cc-test-reporter
17
+ - ./cc-test-reporter before-build
18
+ script:
19
+ - bundle exec rake
20
+ after_script:
21
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
data/Gemfile CHANGED
@@ -1,2 +1,5 @@
1
- source 'https://rubygems.org'
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
2
5
  gemspec
data/Guardfile CHANGED
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  clearing :on
2
4
 
3
5
  guard :minitest do
4
6
  watch(%r{^lib/(.+)\.rb$}) { |m| "test/lib/#{m[1]}_test.rb" }
5
7
  watch(%r{^test/.+_test\.rb$})
6
- watch(%r{^test/test_helper\.rb$}) { 'test' }
8
+ watch(%r{^test/test_helper\.rb$}) { "test" }
7
9
  end
data/README.md CHANGED
@@ -2,11 +2,10 @@
2
2
 
3
3
  A simple gem to generate social media sharing URLs.
4
4
 
5
- [![Gem](https://img.shields.io/gem/v/social-url.svg?style=flat-square)](http://rubygems.org/gems/social-url)
6
- [![Build Status](https://img.shields.io/travis/richardvenneman/social-url/master.svg?style=flat-square)](https://travis-ci.org/richardvenneman/social-url)
7
- [![Gemnasium](https://img.shields.io/gemnasium/richardvenneman/social-url.svg?style=flat-square)](https://gemnasium.com/richardvenneman/social-url)
8
- [![Code Climate](https://img.shields.io/codeclimate/github/richardvenneman/social-url.svg?style=flat-square)](https://codeclimate.com/github/richardvenneman/social-url)
9
- [![Test Coverage](https://img.shields.io/codeclimate/coverage/github/richardvenneman/social-url.svg?style=flat-square)](https://codeclimate.com/github/richardvenneman/social-url/coverage)
5
+ [![Build Status](https://travis-ci.org/richardvenneman/social-url.svg?branch=master)](https://travis-ci.org/richardvenneman/social-url)
6
+ [![Gem Version](https://badge.fury.io/rb/social-url.svg)](https://badge.fury.io/rb/social-url)
7
+ [![Maintainability](https://api.codeclimate.com/v1/badges/18b840bd059f4e83442c/maintainability)](https://codeclimate.com/github/richardvenneman/social-url/maintainability)
8
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/18b840bd059f4e83442c/test_coverage)](https://codeclimate.com/github/richardvenneman/social-url/test_coverage)
10
9
 
11
10
  Supported networks: Google+, Facebook, Pinterest, Twitter.
12
11
 
@@ -20,13 +19,15 @@ Read more about [Responsible Social Share Links](https://jonsuh.com/blog/social-
20
19
 
21
20
  ## Installation
22
21
 
22
+ This library is test with the following Rubies: 2.3.8, 2.4.5, 2.5.3.
23
+
23
24
  Add it to your Gemfile with:
24
25
 
25
26
  ```ruby
26
27
  gem 'social_url'
27
28
  ```
28
29
 
29
- Run the `bundle install` in your terminal command to install it.
30
+ Run the `bundle install` command in your terminal to install it.
30
31
 
31
32
  ## Usage
32
33
 
data/Rakefile CHANGED
@@ -1,9 +1,11 @@
1
- require 'rake/testtask'
1
+ # frozen_string_literal: true
2
+
3
+ require "rake/testtask"
2
4
 
3
5
  Rake::TestTask.new(:test) do |t|
4
- t.libs << 'lib'
5
- t.libs << 'test'
6
- t.pattern = 'test/**/*_test.rb'
6
+ t.libs << "lib"
7
+ t.libs << "test"
8
+ t.pattern = "test/**/*_test.rb"
7
9
  t.verbose = false
8
10
  end
9
11
 
@@ -1 +1,3 @@
1
- require 'social_url'
1
+ # frozen_string_literal: true
2
+
3
+ require "social_url"
@@ -1,13 +1,15 @@
1
- require 'erb'
1
+ # frozen_string_literal: true
2
2
 
3
- require 'social_url/errors'
4
- require 'social_url/version'
3
+ require "erb"
5
4
 
6
- require 'social_url/message'
7
- require 'social_url/facebook'
8
- require 'social_url/google'
9
- require 'social_url/pinterest'
10
- require 'social_url/twitter'
5
+ require "social_url/errors"
6
+ require "social_url/version"
7
+
8
+ require "social_url/message"
9
+ require "social_url/facebook"
10
+ require "social_url/google"
11
+ require "social_url/pinterest"
12
+ require "social_url/twitter"
11
13
 
12
14
  module SocialUrl
13
15
  include ERB::Util
@@ -55,8 +57,8 @@ module SocialUrl
55
57
 
56
58
  def normalize_hashtags(array)
57
59
  array.collect do |value|
58
- value.delete(' ')
59
- end.join(',')
60
+ value.delete(" ")
61
+ end.join(",")
60
62
  end
61
63
 
62
64
  def normalize_string(string)
@@ -66,14 +68,14 @@ module SocialUrl
66
68
  def normalize_array(array)
67
69
  array.collect do |value|
68
70
  ERB::Util.url_encode(value)
69
- end.join(',')
71
+ end.join(",")
70
72
  end
71
73
 
72
74
  def filtered_params(options, params)
73
75
  params.collect do |param|
74
76
  next unless options[param]
75
77
  "#{param}=#{options[param]}"
76
- end.compact.join('&')
78
+ end.compact.join("&")
77
79
  end
78
80
  end
79
81
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SocialUrl
2
4
  class UnsupportedNetworkError < StandardError
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SocialUrl
2
4
  class Facebook
3
5
  PARAMS = [:u]
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SocialUrl
2
4
  class Google
3
5
  PARAMS = [:url]
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SocialUrl
2
4
  class Message
3
5
  def initialize(options)
@@ -10,20 +12,19 @@ module SocialUrl
10
12
  network = /(.+)_url/.match(method)
11
13
  return unless network
12
14
 
13
- networks = SocialUrl.networks.join(',')
15
+ networks = SocialUrl.networks.join(",")
14
16
  raise UnsupportedNetworkError,
15
17
  "Unsupported network '#{network[1]}'. Choose from: #{networks}."
16
18
  end
17
19
 
18
20
  private
19
-
20
- def init_networks
21
- SocialUrl.networks.each do |network|
22
- self.class.send(:define_method, "#{network}_url") do
23
- klass = network.to_s.capitalize
24
- SocialUrl.const_get(klass).new(@options).url
21
+ def init_networks
22
+ SocialUrl.networks.each do |network|
23
+ self.class.send(:define_method, "#{network}_url") do
24
+ klass = network.to_s.capitalize
25
+ SocialUrl.const_get(klass).new(@options).url
26
+ end
25
27
  end
26
28
  end
27
- end
28
29
  end
29
30
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SocialUrl
2
4
  class Pinterest
3
5
  PARAMS = [:url, :media, :description]
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SocialUrl
2
4
  class Twitter
3
5
  PARAMS = [:text, :url, :hashtags, :via, :related]
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SocialUrl
2
- VERSION = '1.1.0'
4
+ VERSION = "1.1.1"
3
5
  end
@@ -1,24 +1,25 @@
1
- require './lib/social_url/version'
1
+ # frozen_string_literal: true
2
+
3
+ require "./lib/social_url/version"
2
4
 
3
5
  Gem::Specification.new do |s|
4
- s.name = 'social-url'
6
+ s.name = "social-url"
5
7
  s.version = SocialUrl::VERSION
8
+ s.license = "MIT"
6
9
  s.authors = ["Richard Venneman"]
7
- s.email = 'richardvenneman@me.com'
8
- s.homepage = 'https://github.com/richardvenneman/social-url'
9
- s.summary = 'Generates social media sharing links'
10
+ s.email = "richardvenneman@me.com"
11
+ s.homepage = "https://github.com/richardvenneman/social-url"
12
+ s.summary = "Generates social media sharing links"
10
13
  s.description = 'A simple gem to generate social sharing links for your
11
14
  messages. Supports multiple social platforms trough a plugin
12
15
  architecture.'
13
16
 
14
- s.license = 'MIT'
15
- s.require_path = 'lib'
16
17
  s.files = `git ls-files`.split("\n")
17
- s.test_files = Dir['test/**/*']
18
+ s.require_path = "lib"
19
+ s.test_files = Dir["test/**/*"]
18
20
 
19
- s.add_development_dependency 'rake', '~> 10.4'
20
- s.add_development_dependency 'guard', '~> 2'
21
- s.add_development_dependency 'guard-minitest', '~> 2.4'
22
- s.add_development_dependency 'simplecov', '~> 0.9'
23
- s.add_development_dependency 'codeclimate-test-reporter', '~> 0.4'
21
+ s.add_development_dependency "rake", "~> 12"
22
+ s.add_development_dependency "guard", "~> 2.14"
23
+ s.add_development_dependency "guard-minitest", "~> 2.4"
24
+ s.add_development_dependency "simplecov", "~> 0.16"
24
25
  end
@@ -1,14 +1,16 @@
1
- require 'test_helper'
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
2
4
 
3
5
  module SocialUrl
4
6
  class FacebookTest < Minitest::Test
5
7
  def setup
6
- @options = { url: 'http://example.com' }
8
+ @options = { url: "http://example.com" }
7
9
  end
8
10
 
9
11
  def test_url
10
12
  opts = SocialUrl.normalize(@options)
11
- url = 'https://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Fexample.com'
13
+ url = "https://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Fexample.com"
12
14
 
13
15
  assert_equal url, Facebook.new(opts).url
14
16
  end
@@ -1,17 +1,19 @@
1
- require 'test_helper'
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
2
4
 
3
5
  module SocialUrl
4
6
  class GoogleTest < Minitest::Test
5
7
  def setup
6
8
  @options = {
7
- text: 'Hello World',
8
- url: 'http://example.com'
9
+ text: "Hello World",
10
+ url: "http://example.com"
9
11
  }
10
12
  end
11
13
 
12
14
  def test_url
13
15
  opts = SocialUrl.normalize(@options)
14
- url = 'https://plus.google.com/share?url=http%3A%2F%2Fexample.com'
16
+ url = "https://plus.google.com/share?url=http%3A%2F%2Fexample.com"
15
17
 
16
18
  assert_equal url, Google.new(opts).url
17
19
  end
@@ -1,16 +1,18 @@
1
- require 'test_helper'
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
2
4
 
3
5
  module SocialUrl
4
6
  class MessageTest < Minitest::Test
5
7
  def setup
6
8
  @message = Message.new({})
7
- @complete_message = Message.new({
8
- text: 'Hello World',
9
- url: 'http://example.com',
9
+ @complete_message = Message.new(
10
+ text: "Hello World",
11
+ url: "http://example.com",
10
12
  hashtags: %w(nature sunset),
11
- via: 'twitterdev',
12
- related: ['twitter:Twitter News', 'twitterapi:Twitter API News']
13
- })
13
+ via: "twitterdev",
14
+ related: ["twitter:Twitter News", "twitterapi:Twitter API News"]
15
+ )
14
16
  end
15
17
 
16
18
  def teardown
@@ -32,11 +34,11 @@ module SocialUrl
32
34
  end
33
35
 
34
36
  def test_network_url
35
- url = ['https://twitter.com/intent/tweet/?text=Hello%20World',
36
- '&url=http%3A%2F%2Fexample.com',
37
- '&hashtags=nature,sunset',
38
- '&via=twitterdev',
39
- '&related=twitter%3ATwitter%20News,twitterapi%3ATwitter%20API%20News'].join
37
+ url = ["https://twitter.com/intent/tweet/?text=Hello%20World",
38
+ "&url=http%3A%2F%2Fexample.com",
39
+ "&hashtags=nature,sunset",
40
+ "&via=twitterdev",
41
+ "&related=twitter%3ATwitter%20News,twitterapi%3ATwitter%20API%20News"].join
40
42
 
41
43
  assert_equal url, @complete_message.twitter_url
42
44
  end
@@ -1,21 +1,23 @@
1
- require 'test_helper'
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
2
4
 
3
5
  module SocialUrl
4
6
  class PinterestTest < Minitest::Test
5
7
  def setup
6
8
  @options = {
7
- url: 'http://www.flickr.com/photos/kentbrew/6851755809/',
8
- media: 'http://farm8.staticflickr.com/7027/6851755809_df5b2051c9_z.jpg',
9
- description: 'Next stop: Pinterest'
9
+ url: "http://www.flickr.com/photos/kentbrew/6851755809/",
10
+ media: "http://farm8.staticflickr.com/7027/6851755809_df5b2051c9_z.jpg",
11
+ description: "Next stop: Pinterest"
10
12
  }
11
13
  end
12
14
 
13
15
  def test_url
14
16
  opts = SocialUrl.normalize(@options)
15
- url = ['https://www.pinterest.com/pin/create/button/',
16
- '?url=http%3A%2F%2Fwww.flickr.com%2Fphotos%2Fkentbrew%2F6851755809%2F',
17
- '&media=http%3A%2F%2Ffarm8.staticflickr.com%2F7027%2F6851755809_df5b2051c9_z.jpg',
18
- '&description=Next%20stop%3A%20Pinterest'].join
17
+ url = ["https://www.pinterest.com/pin/create/button/",
18
+ "?url=http%3A%2F%2Fwww.flickr.com%2Fphotos%2Fkentbrew%2F6851755809%2F",
19
+ "&media=http%3A%2F%2Ffarm8.staticflickr.com%2F7027%2F6851755809_df5b2051c9_z.jpg",
20
+ "&description=Next%20stop%3A%20Pinterest"].join
19
21
 
20
22
  assert_equal url, Pinterest.new(opts).url
21
23
  end
@@ -1,24 +1,26 @@
1
- require 'test_helper'
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
2
4
 
3
5
  module SocialUrl
4
6
  class TwitterTest < Minitest::Test
5
7
  def setup
6
8
  @options = {
7
- text: 'Hello World',
8
- url: 'http://example.com',
9
- hashtags: ['nature', 'sunset', 'Multi Word HashTag'],
10
- via: 'twitterdev',
11
- related: ['twitter:Twitter News', 'twitterapi:Twitter API News']
9
+ text: "Hello World",
10
+ url: "http://example.com",
11
+ hashtags: ["nature", "sunset", "Multi Word HashTag"],
12
+ via: "twitterdev",
13
+ related: ["twitter:Twitter News", "twitterapi:Twitter API News"]
12
14
  }
13
15
  end
14
16
 
15
17
  def test_url
16
18
  opts = SocialUrl.normalize(@options)
17
- url = ['https://twitter.com/intent/tweet/?text=Hello%20World',
18
- '&url=http%3A%2F%2Fexample.com',
19
- '&hashtags=nature,sunset,MultiWordHashTag',
20
- '&via=twitterdev',
21
- '&related=twitter%3ATwitter%20News,twitterapi%3ATwitter%20API%20News'].join
19
+ url = ["https://twitter.com/intent/tweet/?text=Hello%20World",
20
+ "&url=http%3A%2F%2Fexample.com",
21
+ "&hashtags=nature,sunset,MultiWordHashTag",
22
+ "&via=twitterdev",
23
+ "&related=twitter%3ATwitter%20News,twitterapi%3ATwitter%20API%20News"].join
22
24
 
23
25
  assert_equal url, Twitter.new(opts).url
24
26
  end
@@ -1,23 +1,25 @@
1
- require 'test_helper'
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
2
4
 
3
5
  class SocialUrlTest < Minitest::Test
4
6
  def setup
5
7
  @options = {
6
- text: 'Hello World',
7
- url: 'http://example.com/',
8
+ text: "Hello World",
9
+ url: "http://example.com/",
8
10
  hashtags: %w(nature sunset),
9
- via: 'twitterdev',
10
- related: ['twitter:Twitter News', 'twitterapi:Twitter API News']
11
+ via: "twitterdev",
12
+ related: ["twitter:Twitter News", "twitterapi:Twitter API News"]
11
13
  }
12
14
 
13
15
  @normalized_options = {
14
- text: 'Hello%20World',
15
- description: 'Hello%20World',
16
- u: 'http%3A%2F%2Fexample.com%2F',
17
- url: 'http%3A%2F%2Fexample.com%2F',
18
- hashtags: 'nature,sunset',
19
- via: 'twitterdev',
20
- related: 'twitter%3ATwitter%20News,twitterapi%3ATwitter%20API%20News'
16
+ text: "Hello%20World",
17
+ description: "Hello%20World",
18
+ u: "http%3A%2F%2Fexample.com%2F",
19
+ url: "http%3A%2F%2Fexample.com%2F",
20
+ hashtags: "nature,sunset",
21
+ via: "twitterdev",
22
+ related: "twitter%3ATwitter%20News,twitterapi%3ATwitter%20API%20News"
21
23
  }
22
24
  end
23
25
 
@@ -27,24 +29,24 @@ class SocialUrlTest < Minitest::Test
27
29
  end
28
30
 
29
31
  def test_string_normalization
30
- text = 'Hello%20World'
32
+ text = "Hello%20World"
31
33
 
32
- assert_equal text, SocialUrl.normalize_string('Hello World')
34
+ assert_equal text, SocialUrl.normalize_string("Hello World")
33
35
  end
34
36
 
35
37
  def test_array_normalization
36
38
  array = %w(nature sunset)
37
- text = 'nature,sunset'
38
- complex_array = ['twitter:Twitter News', 'twitterapi:Twitter API News']
39
- complex_text = 'twitter%3ATwitter%20News,twitterapi%3ATwitter%20API%20News'
39
+ text = "nature,sunset"
40
+ complex_array = ["twitter:Twitter News", "twitterapi:Twitter API News"]
41
+ complex_text = "twitter%3ATwitter%20News,twitterapi%3ATwitter%20API%20News"
40
42
 
41
43
  assert_equal text, SocialUrl.normalize_array(array)
42
44
  assert_equal complex_text, SocialUrl.normalize_array(complex_array)
43
45
  end
44
46
 
45
47
  def test_hashtag_normalization
46
- array = ['Multi Word HashTag', 'nature']
47
- text = 'MultiWordHashTag,nature'
48
+ array = ["Multi Word HashTag", "nature"]
49
+ text = "MultiWordHashTag,nature"
48
50
 
49
51
  assert_equal text, SocialUrl.normalize_hashtags(array)
50
52
  end
@@ -54,7 +56,7 @@ class SocialUrlTest < Minitest::Test
54
56
  end
55
57
 
56
58
  def test_filtered_params
57
- filtered_params = 'text=Hello%20World&url=http%3A%2F%2Fexample.com%2F'
59
+ filtered_params = "text=Hello%20World&url=http%3A%2F%2Fexample.com%2F"
58
60
  params = [:text, :url, :derp]
59
61
 
60
62
  assert_equal filtered_params, SocialUrl.filtered_params(@normalized_options, params)
@@ -1,17 +1,12 @@
1
- # Coverage
2
- if ENV['CODECLIMATE_REPO_TOKEN']
3
- require 'codeclimate-test-reporter'
4
- CodeClimate::TestReporter.start
5
- elsif ENV['COVERAGE']
6
- require 'simplecov'
7
- SimpleCov.start do
8
- add_group 'Libraries', 'lib'
9
- end
1
+ # frozen_string_literal: true
2
+
3
+ require "simplecov"
4
+ SimpleCov.start do
5
+ add_group "Libraries", "lib"
10
6
  end
11
7
 
12
8
  # Source files
13
- require './lib/social_url'
9
+ require "./lib/social_url"
14
10
 
15
- # Support
16
- require 'minitest/autorun'
17
- require 'minitest/pride'
11
+ # Framework
12
+ require "minitest/autorun"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: social-url
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Venneman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-27 00:00:00.000000000 Z
11
+ date: 2018-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '10.4'
19
+ version: '12'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '10.4'
26
+ version: '12'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: guard
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '2'
33
+ version: '2.14'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '2'
40
+ version: '2.14'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: guard-minitest
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -58,28 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0.9'
61
+ version: '0.16'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0.9'
69
- - !ruby/object:Gem::Dependency
70
- name: codeclimate-test-reporter
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '0.4'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '0.4'
68
+ version: '0.16'
83
69
  description: |-
84
70
  A simple gem to generate social sharing links for your
85
71
  messages. Supports multiple social platforms trough a plugin
@@ -89,10 +75,12 @@ executables: []
89
75
  extensions: []
90
76
  extra_rdoc_files: []
91
77
  files:
78
+ - ".codeclimate.yml"
92
79
  - ".gitignore"
80
+ - ".rubocop.yml"
81
+ - ".ruby-version"
93
82
  - ".travis.yml"
94
83
  - Gemfile
95
- - Gemfile.lock
96
84
  - Guardfile
97
85
  - README.md
98
86
  - Rakefile
@@ -133,15 +121,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
121
  version: '0'
134
122
  requirements: []
135
123
  rubyforge_project:
136
- rubygems_version: 2.4.8
124
+ rubygems_version: 2.7.6
137
125
  signing_key:
138
126
  specification_version: 4
139
127
  summary: Generates social media sharing links
140
128
  test_files:
141
- - test/lib/social_url/facebook_test.rb
129
+ - test/lib/social_url/pinterest_test.rb
142
130
  - test/lib/social_url/google_test.rb
143
131
  - test/lib/social_url/message_test.rb
144
- - test/lib/social_url/pinterest_test.rb
132
+ - test/lib/social_url/facebook_test.rb
145
133
  - test/lib/social_url/twitter_test.rb
146
134
  - test/lib/social_url_test.rb
147
135
  - test/test_helper.rb
@@ -1,68 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- social-url (1.1.0)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- codeclimate-test-reporter (0.4.7)
10
- simplecov (>= 0.7.1, < 1.0.0)
11
- coderay (1.1.0)
12
- docile (1.1.5)
13
- ffi (1.9.10)
14
- formatador (0.2.5)
15
- guard (2.13.0)
16
- formatador (>= 0.2.4)
17
- listen (>= 2.7, <= 4.0)
18
- lumberjack (~> 1.0)
19
- nenv (~> 0.1)
20
- notiffany (~> 0.0)
21
- pry (>= 0.9.12)
22
- shellany (~> 0.0)
23
- thor (>= 0.18.1)
24
- guard-compat (1.2.1)
25
- guard-minitest (2.4.4)
26
- guard-compat (~> 1.2)
27
- minitest (>= 3.0)
28
- json (1.8.3)
29
- listen (3.0.3)
30
- rb-fsevent (>= 0.9.3)
31
- rb-inotify (>= 0.9)
32
- lumberjack (1.0.9)
33
- method_source (0.8.2)
34
- minitest (5.7.0)
35
- nenv (0.2.0)
36
- notiffany (0.0.7)
37
- nenv (~> 0.1)
38
- shellany (~> 0.0)
39
- pry (0.10.1)
40
- coderay (~> 1.1.0)
41
- method_source (~> 0.8.1)
42
- slop (~> 3.4)
43
- rake (10.4.2)
44
- rb-fsevent (0.9.5)
45
- rb-inotify (0.9.5)
46
- ffi (>= 0.5.0)
47
- shellany (0.0.1)
48
- simplecov (0.10.0)
49
- docile (~> 1.1.0)
50
- json (~> 1.8)
51
- simplecov-html (~> 0.10.0)
52
- simplecov-html (0.10.0)
53
- slop (3.6.0)
54
- thor (0.19.1)
55
-
56
- PLATFORMS
57
- ruby
58
-
59
- DEPENDENCIES
60
- codeclimate-test-reporter (~> 0.4)
61
- guard (~> 2)
62
- guard-minitest (~> 2.4)
63
- rake (~> 10.4)
64
- simplecov (~> 0.9)
65
- social-url!
66
-
67
- BUNDLED WITH
68
- 1.10.5