socialite_js 0.0.1.pre.1 → 0.0.1.pre.2

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.
data/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ # Changelog
2
+
3
+ ## 0.0.1.pre.2
4
+ - has a rails engine with a initializer hook called `socialite_js.javascript_helper`
5
+ it provides helper methods `socialite_javascript_tag` and methods for
6
+ socialite extensions like `socialite_github_javascript_tag`
7
+ Also `socialite_javascript_tag` is customized based on Rails
8
+ environment, on production the minimized version is used.
data/Rakefile CHANGED
@@ -2,9 +2,10 @@ require "bundler/gem_tasks"
2
2
  require 'rake/testtask'
3
3
 
4
4
  Rake::TestTask.new do |t|
5
- t.libs.push "lib"
6
- t.test_files = FileList['test/*/*_test.rb']
5
+ t.libs.push "lib", "test"
6
+ t.test_files = FileList['test/**/*_test.rb']
7
7
  t.verbose = true
8
+ t.ruby_opts << "-rdebugger"
8
9
  end
9
10
 
10
11
  task :default => :test
@@ -0,0 +1,13 @@
1
+ require 'rails'
2
+ require 'active_support'
3
+
4
+ module SocialiteJs
5
+ class Engine < ::Rails::Engine
6
+ initializer 'socialite_js.javascript_helper' do
7
+ ActiveSupport.on_load(:action_controller) do
8
+ require 'socialite_js/on_load_action_controller'
9
+ helper SocialiteJs::JavascriptHelper
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,44 @@
1
+ require 'socialite_js/source'
2
+ require 'rails'
3
+
4
+ module SocialiteJs
5
+ module JavascriptHelper
6
+ def socialite_javascript_tag
7
+ js_path = if Rails.env.production?
8
+ Source.bundled_minimized_path
9
+ else
10
+ Source.bundled_path
11
+ end
12
+ render :partial => js_path
13
+ end
14
+
15
+ def respond_to?(method_sym, include_private = false)
16
+ if respond_to_socialite_extension? method_sym.to_s
17
+ true
18
+ else
19
+ super
20
+ end
21
+ end
22
+
23
+ def method_missing(method_sym, *args, &block)
24
+ if match = respond_to_socialite_extension?(method_sym.to_s)
25
+ SocialiteJs::Source.send("#{match['extension_name']}_extension_path")
26
+ else
27
+ super
28
+ end
29
+ end
30
+
31
+ protected
32
+ def respond_to_socialite_extension? method_str
33
+ # NOTE: not checking if the file actually exists. but checking
34
+ # from a master list of supported extensions
35
+ if (match = method_str.match(/\Asocialite_(?<extension_name>(.)+)_javascript_tag\z/)) &&
36
+ SocialiteJs::Source.supported_extensions.include?(match['extension_name'])
37
+ match
38
+ else
39
+ false
40
+ end
41
+ end
42
+
43
+ end
44
+ end
@@ -0,0 +1 @@
1
+ require "socialite_js/javascript_helper"
@@ -0,0 +1 @@
1
+ require "socialite_js/engine"
@@ -1,3 +1,3 @@
1
1
  module SocialiteJs
2
- VERSION = "0.0.1.pre.1"
2
+ VERSION = "0.0.1.pre.2"
3
3
  end
data/lib/socialite_js.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  require "socialite_js/version"
2
2
 
3
3
  module SocialiteJs
4
- # Your code goes here...
5
4
  end
data/socialite_js.gemspec CHANGED
@@ -18,8 +18,8 @@ Gem::Specification.new do |gem|
18
18
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
19
  gem.require_paths = ["lib"]
20
20
 
21
- gem.add_dependency "socialite_js-source", "= 0.0.1"
22
-
23
- gem.add_development_dependency "debugger", "~> 1.5.0"
21
+ gem.add_runtime_dependency "socialite_js-source", "= 0.0.2"
22
+ gem.add_runtime_dependency "rails", "~> 3.2.11"
24
23
 
24
+ gem.add_development_dependency "debugger", "~> 1.5.0"
25
25
  end
@@ -0,0 +1,63 @@
1
+ require 'test_helper'
2
+ require 'minitest/mock'
3
+ require 'socialite_js/javascript_helper'
4
+
5
+ class App
6
+ include SocialiteJs::JavascriptHelper
7
+
8
+ # stub render to return path to check
9
+ def render options
10
+ options[:partial]
11
+ end
12
+ end
13
+
14
+ def stub_rails_production
15
+ class << Rails.env
16
+ def production?; true; end
17
+ end
18
+ end
19
+
20
+ def stub_rails_development
21
+ class << Rails.env
22
+ def production?; false; end
23
+ end
24
+ end
25
+
26
+ module SocialiteJs::JavascriptHelper
27
+ describe "#socialite_javascript_tag" do
28
+
29
+ before do
30
+ @subject = App.new
31
+ end
32
+
33
+ it "responds to socialite_javascript_tag" do
34
+ @subject.respond_to?(:socialite_javascript_tag).must_equal true
35
+ end
36
+
37
+ it "returns the minimized js path for Rails production env" do
38
+ stub_rails_production
39
+ @subject.socialite_javascript_tag.must_match /(socialite\.min\.js)\z/
40
+ end
41
+
42
+ it "returns the js path for non-production Rails env" do
43
+ stub_rails_development
44
+ @subject.socialite_javascript_tag.must_match /(socialite\.js)\z/
45
+ end
46
+ end
47
+
48
+ describe "#socialite_extension_javascript_tag" do
49
+ before do
50
+ @subject = App.new
51
+ end
52
+
53
+ it "returns the js path for an extension" do
54
+ @subject.socialite_github_javascript_tag.must_match /(socialite\.github\.js)\z/
55
+ end
56
+
57
+ it "responds to an extension supported extension type" do
58
+ @subject.respond_to?(:socialite_github_javascript_tag).must_equal true
59
+ @subject.respond_to?(:socialite_foo_javascript_tag).must_equal false
60
+ end
61
+ end
62
+
63
+ end
data/test/test_helper.rb CHANGED
@@ -1,3 +1,4 @@
1
1
  require 'minitest/spec'
2
2
  require 'minitest/pride'
3
3
  require 'minitest/autorun'
4
+ require 'pp' # pretty print for one-off debugging in tests
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: socialite_js
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.pre.1
4
+ version: 0.0.1.pre.2
5
5
  prerelease: 6
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-10 00:00:00.000000000 Z
12
+ date: 2013-05-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: socialite_js-source
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - '='
20
20
  - !ruby/object:Gem::Version
21
- version: 0.0.1
21
+ version: 0.0.2
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +26,23 @@ dependencies:
26
26
  requirements:
27
27
  - - '='
28
28
  - !ruby/object:Gem::Version
29
- version: 0.0.1
29
+ version: 0.0.2
30
+ - !ruby/object:Gem::Dependency
31
+ name: rails
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 3.2.11
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 3.2.11
30
46
  - !ruby/object:Gem::Dependency
31
47
  name: debugger
32
48
  requirement: !ruby/object:Gem::Requirement
@@ -51,13 +67,19 @@ extensions: []
51
67
  extra_rdoc_files: []
52
68
  files:
53
69
  - .gitignore
70
+ - CHANGELOG.md
54
71
  - Gemfile
55
72
  - LICENSE.txt
56
73
  - README.md
57
74
  - Rakefile
58
75
  - lib/socialite_js.rb
76
+ - lib/socialite_js/engine.rb
77
+ - lib/socialite_js/javascript_helper.rb
78
+ - lib/socialite_js/on_load_action_controller.rb
79
+ - lib/socialite_js/rails.rb
59
80
  - lib/socialite_js/version.rb
60
81
  - socialite_js.gemspec
82
+ - test/socialite_js/javascript_helper_test.rb
61
83
  - test/test_helper.rb
62
84
  homepage: https://github.com/deepak/socialite_js
63
85
  licenses: []
@@ -71,6 +93,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
71
93
  - - ! '>='
72
94
  - !ruby/object:Gem::Version
73
95
  version: '0'
96
+ segments:
97
+ - 0
98
+ hash: -1688312706558713205
74
99
  required_rubygems_version: !ruby/object:Gem::Requirement
75
100
  none: false
76
101
  requirements:
@@ -84,4 +109,5 @@ signing_key:
84
109
  specification_version: 3
85
110
  summary: Integrate socialite.js into Ruby on Rails
86
111
  test_files:
112
+ - test/socialite_js/javascript_helper_test.rb
87
113
  - test/test_helper.rb