mobvious-rails 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -2,5 +2,6 @@
2
2
  /.yardoc
3
3
  /doc
4
4
  /Gemfile.lock
5
+ /pkg
5
6
  /tmp
6
7
  /vendor/ruby
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (C) 2012 Jiri Stransky
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the "Software"),
5
+ to deal in the Software without restriction, including without limitation
6
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
7
+ and/or sell copies of the Software, and to permit persons to whom the Software
8
+ is furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19
+ IN THE SOFTWARE.
@@ -0,0 +1,52 @@
1
+ # Mobvious-Rails
2
+
3
+ Mobvious extensions for Rails views, controllers and CoffeeScript
4
+
5
+ ## Key Features
6
+
7
+ * **Access detected device type easily from controllers and views.** Just write `device_type`.
8
+
9
+ * **Execute code for given device types only.** Both in controllers and views.
10
+
11
+ <%= for_device_type :mobile do %>
12
+ <%= stylesheet_link_tag 'mobile_styles' %>
13
+ <% end %>
14
+
15
+ * **Do the above stuff also in your CoffeeScript.**
16
+
17
+ alert 'You are using a ' + Mobvious.device_type + ' device.'
18
+
19
+ Mobvious.for_device_type 'mobile', ->
20
+ alert 'You are using a mobile device.'
21
+
22
+ ## Get Started
23
+
24
+ 1. **Include the gem in your Gemfile.**
25
+ For Bundler >= 1.1: `gem 'mobvious-rails'`
26
+ For Bundler < 1.1: `gem 'mobvious-rails', require: 'mobvious/rails'`
27
+
28
+ 2. **Include modules to your controllers and helpers.** No sneaky monkey patching in Mobvious!
29
+
30
+ Put this into your ApplicationController:
31
+
32
+ include Mobvious::Rails::Controller
33
+
34
+ And this into your ApplicationHelper:
35
+
36
+ include Mobvious::Rails::Helper
37
+
38
+ 3. **Optionally, include also CoffeeScript helpers.**
39
+
40
+ Put this into your layouts/application.html.erb:
41
+
42
+ <head>
43
+ <%= mobvious_javascript %>
44
+ <!-- other code here -->
45
+ </head>
46
+
47
+ And this into your application.js:
48
+
49
+ //= require mobvious-rails
50
+
51
+ **That's it! You can now use all the stuff.** See the
52
+ [documentation](http://rdoc.info/github/jistr/mobvious-rails/frames) if necessary.
data/Rakefile CHANGED
@@ -1,10 +1,17 @@
1
1
  require "bundler/gem_tasks"
2
+ require 'rake/testtask'
3
+
4
+ task :default => [:test, :'jasmine:ci']
5
+
6
+ Rake::TestTask.new do |t|
7
+ t.pattern = "spec/**/*_spec.rb"
8
+ end
2
9
 
3
10
  begin
4
11
  require 'jasmine'
5
12
  load 'jasmine/tasks/jasmine.rake'
6
13
  rescue LoadError
7
14
  task :jasmine do
8
- abort "Jasmine is not available. In order to run jasmine, you must: (sudo) gem install jasmine"
15
+ abort "Jasmine is not available. In order to run jasmine, you must: gem install jasmine"
9
16
  end
10
17
  end
@@ -1,8 +1,13 @@
1
1
  module Mobvious
2
2
  module Rails
3
- # Definition of this class makes it a Rails engine, enabling this library
4
- # to provide assets can be used in the application.
3
+ # Definition of this class makes this gem a Rails engine, enabling
4
+ # providing assets that can be used in the application.
5
5
  class Engine < ::Rails::Engine
6
+ if ::Rails.version >= '3.1'
7
+ initializer 'mobvious-rails.assets' do |config|
8
+ ::Rails.application.config.assets.precompile += %w( mobvious-rails.js )
9
+ end
10
+ end
6
11
  end
7
12
  end
8
13
  end
@@ -1,5 +1,5 @@
1
1
  module Mobvious
2
2
  module Rails
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
@@ -32,3 +32,12 @@ describe 'Mobvious', ->
32
32
  'multiple_retval'
33
33
  expect(multiple_block_executed).toEqual true
34
34
  expect(multiple_retval).toEqual 'multiple_retval'
35
+
36
+ it 'should only run once', ->
37
+ block_executed_times = 0
38
+
39
+ multiple_retval = Mobvious.for_device_type 'desktop', 'mobile', ->
40
+ block_executed_times += 1
41
+ 'multiple_retval'
42
+ expect(block_executed_times).toEqual 1
43
+ expect(multiple_retval).toEqual 'multiple_retval'
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require_relative '../../spec_helper'
2
2
  require 'mobvious/rails/controller'
3
3
 
4
4
  module Mobvious
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require_relative '../../spec_helper'
2
2
  require 'mobvious/rails/helper'
3
3
 
4
4
  module Mobvious
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mobvious-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-24 00:00:00.000000000 Z
12
+ date: 2012-04-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mobvious
16
- requirement: &7091660 !ruby/object:Gem::Requirement
16
+ requirement: &5224960 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *7091660
24
+ version_requirements: *5224960
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: activesupport
27
- requirement: &7088280 !ruby/object:Gem::Requirement
27
+ requirement: &5224160 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *7088280
35
+ version_requirements: *5224160
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: pry
38
- requirement: &7115160 !ruby/object:Gem::Requirement
38
+ requirement: &5222980 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *7115160
46
+ version_requirements: *5222980
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: minitest
49
- requirement: &7114700 !ruby/object:Gem::Requirement
49
+ requirement: &5221440 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *7114700
57
+ version_requirements: *5221440
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: mocha
60
- requirement: &7114180 !ruby/object:Gem::Requirement
60
+ requirement: &5220700 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *7114180
68
+ version_requirements: *5220700
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: therubyracer
71
- requirement: &7113560 !ruby/object:Gem::Requirement
71
+ requirement: &5236320 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *7113560
79
+ version_requirements: *5236320
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: jasmine
82
- requirement: &7112840 !ruby/object:Gem::Requirement
82
+ requirement: &5235660 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *7112840
90
+ version_requirements: *5235660
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: guard
93
- requirement: &7111080 !ruby/object:Gem::Requirement
93
+ requirement: &5234980 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *7111080
101
+ version_requirements: *5234980
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: guard-minitest
104
- requirement: &7109940 !ruby/object:Gem::Requirement
104
+ requirement: &5234280 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: '0'
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *7109940
112
+ version_requirements: *5234280
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: guard-coffeescript
115
- requirement: &7109200 !ruby/object:Gem::Requirement
115
+ requirement: &5233780 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ! '>='
@@ -120,10 +120,10 @@ dependencies:
120
120
  version: '0'
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *7109200
123
+ version_requirements: *5233780
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: rb-inotify
126
- requirement: &7124820 !ruby/object:Gem::Requirement
126
+ requirement: &5233020 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
129
  - - ! '>='
@@ -131,10 +131,10 @@ dependencies:
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
- version_requirements: *7124820
134
+ version_requirements: *5233020
135
135
  - !ruby/object:Gem::Dependency
136
136
  name: libnotify
137
- requirement: &7123860 !ruby/object:Gem::Requirement
137
+ requirement: &5232360 !ruby/object:Gem::Requirement
138
138
  none: false
139
139
  requirements:
140
140
  - - ! '>='
@@ -142,10 +142,10 @@ dependencies:
142
142
  version: '0'
143
143
  type: :development
144
144
  prerelease: false
145
- version_requirements: *7123860
145
+ version_requirements: *5232360
146
146
  - !ruby/object:Gem::Dependency
147
147
  name: turn
148
- requirement: &7123000 !ruby/object:Gem::Requirement
148
+ requirement: &5231600 !ruby/object:Gem::Requirement
149
149
  none: false
150
150
  requirements:
151
151
  - - ! '>='
@@ -153,7 +153,7 @@ dependencies:
153
153
  version: '0'
154
154
  type: :development
155
155
  prerelease: false
156
- version_requirements: *7123000
156
+ version_requirements: *5231600
157
157
  description: Rails enhancements for rendering different content for different device
158
158
  types
159
159
  email:
@@ -166,6 +166,8 @@ files:
166
166
  - .yardopts
167
167
  - Gemfile
168
168
  - Guardfile
169
+ - LICENSE
170
+ - README.md
169
171
  - Rakefile
170
172
  - app/assets/javascripts/mobvious-rails.js.coffee
171
173
  - lib/mobvious/rails.rb
@@ -195,7 +197,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
195
197
  version: '0'
196
198
  segments:
197
199
  - 0
198
- hash: 2203145114535676296
200
+ hash: -877050541795272233
199
201
  required_rubygems_version: !ruby/object:Gem::Requirement
200
202
  none: false
201
203
  requirements:
@@ -204,7 +206,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
204
206
  version: '0'
205
207
  segments:
206
208
  - 0
207
- hash: 2203145114535676296
209
+ hash: -877050541795272233
208
210
  requirements: []
209
211
  rubyforge_project:
210
212
  rubygems_version: 1.8.11