socialite_js-source 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +13 -0
- data/README.md +14 -9
- data/lib/socialite_js/source.rb +25 -6
- data/lib/socialite_js/source/version.rb +1 -1
- data/test/socialite_js/source_test.rb +5 -0
- metadata +3 -2
data/CHANGELOG.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## 0.0.2
|
4
|
+
- js paths for extensions are built using method_missing
|
5
|
+
Add a respond_to? method which reflects if the method will be resolved
|
6
|
+
by method_missing. It is a best-practice to modify `respond_to?`
|
7
|
+
when `method_missing` is added
|
8
|
+
|
9
|
+
## 0.0.1
|
10
|
+
- initial commit. javascript files are vendored inside the
|
11
|
+
vendor/assets/javascript folder.
|
12
|
+
- Socialite::Source.supported_extensions lists the extensions provided by
|
13
|
+
the javascript library
|
data/README.md
CHANGED
@@ -5,10 +5,14 @@ socialite.js is a library to display social sharing buttons.
|
|
5
5
|
|
6
6
|
check http://socialitejs.com/ and https://github.com/dbushell/Socialite
|
7
7
|
|
8
|
-
This rubygem is a shell over the socialite.js
|
8
|
+
This rubygem is a shell over the `socialite.js`
|
9
9
|
Its version will be the same as socialite.js and was created to:
|
10
|
-
1. make it easier to bundle socialite.js in Rails apps
|
11
|
-
|
10
|
+
1. make it easier to bundle socialite.js in Rails apps. one step over manually copy-pasting js files
|
11
|
+
can upgrade the gem to get a newer version of the js files.
|
12
|
+
2. release management. version and specify a specific version of socialite.js in your Rails apps.
|
13
|
+
3. other gems like `socialite_js` will integrate `socialite.js` in Ruby on Rails
|
14
|
+
but can use the `socialite_js-source` gem seperately, if you only want the js files
|
15
|
+
and want to integrate manually into your framework
|
12
16
|
|
13
17
|
#### Why does the gem name have dashes ?
|
14
18
|
|
@@ -20,15 +24,16 @@ see http://guides.rubygems.org/patterns/#consistent-naming under the "Use dashes
|
|
20
24
|
## TODO
|
21
25
|
Seems like the socialite.js library does not follow any specific versioning
|
22
26
|
|
23
|
-
And btw hate the name of the gem.
|
27
|
+
And btw hate the name of the gem.
|
28
|
+
|
24
29
|
@gnufied said it best on the #ruby-lang irc channel
|
25
|
-
the name `socialite_js-source` is `ugg`
|
30
|
+
the name `socialite_js-source` is `ugg` :-)
|
26
31
|
|
27
|
-
> dkannan: me too but the name socialite is taken
|
28
|
-
> dkannan: how about socialite_js-source
|
29
|
-
> gnufied: ugg
|
32
|
+
> dkannan: me too but the name socialite is taken
|
33
|
+
> dkannan: how about socialite_js-source
|
34
|
+
> gnufied: ugg
|
30
35
|
|
31
|
-
Any other suggestions :-)
|
36
|
+
Any other suggestions ? :-)
|
32
37
|
|
33
38
|
## Installation
|
34
39
|
|
data/lib/socialite_js/source.rb
CHANGED
@@ -29,16 +29,35 @@ module SocialiteJs
|
|
29
29
|
weibo
|
30
30
|
icefy]
|
31
31
|
end
|
32
|
-
|
33
|
-
def self.
|
34
|
-
if
|
35
|
-
|
36
|
-
|
37
|
-
|
32
|
+
|
33
|
+
def self.respond_to?(method_sym, include_private = false)
|
34
|
+
if respond_to_socialite_extension? method_sym.to_s
|
35
|
+
true
|
36
|
+
else
|
37
|
+
super
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.method_missing(method_sym, *args, &block)
|
42
|
+
if match = respond_to_socialite_extension?(method_sym.to_s)
|
38
43
|
"#{vendor_path}/extensions/socialite.#{match['extension_name']}.js"
|
39
44
|
else
|
40
45
|
super
|
41
46
|
end
|
42
47
|
end
|
48
|
+
|
49
|
+
protected
|
50
|
+
class << self
|
51
|
+
def respond_to_socialite_extension? method_str
|
52
|
+
# NOTE: not checking if the file actually exists. but checking
|
53
|
+
# from a master list of supported extensions
|
54
|
+
if (match = method_str.match(/\A(?<extension_name>(.)+)_extension_path\z/)) &&
|
55
|
+
supported_extensions.include?(match['extension_name'])
|
56
|
+
match
|
57
|
+
else
|
58
|
+
false
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
43
62
|
end
|
44
63
|
end
|
@@ -33,6 +33,11 @@ module SocialiteJs
|
|
33
33
|
it "does not have an attribute for a unsupported extension type" do
|
34
34
|
lambda { @subject.foobar_extension_path }.must_raise(NoMethodError)
|
35
35
|
end
|
36
|
+
|
37
|
+
it "responds to a supported extension type" do
|
38
|
+
@subject.respond_to?(:github_extension_path).must_equal true
|
39
|
+
@subject.respond_to?(:foo_extension_path).must_equal false
|
40
|
+
end
|
36
41
|
end
|
37
42
|
end
|
38
43
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: socialite_js-source
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: debugger
|
@@ -36,6 +36,7 @@ extensions: []
|
|
36
36
|
extra_rdoc_files: []
|
37
37
|
files:
|
38
38
|
- .gitignore
|
39
|
+
- CHANGELOG.md
|
39
40
|
- Gemfile
|
40
41
|
- LICENSE.txt
|
41
42
|
- README.md
|