bullseye 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +10 -2
- data/bullseye.gemspec +1 -0
- data/lib/bullseye.rb +1 -0
- data/lib/bullseye/sass/bullseye_functions.rb +14 -0
- data/lib/bullseye/tilt/bullseye_template.rb +4 -4
- data/lib/bullseye/tilt/find_parts.rb +18 -0
- data/lib/bullseye/version.rb +1 -1
- metadata +19 -1
data/README.md
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
# Bullseye!
|
2
2
|
|
3
3
|
An *extremely quickly written* shoot-from-the-hip implementation of [so-called Garber-Irish DOM-ready execution](http://viget.com/inspire/extending-paul-irishs-comprehensive-dom-ready-execution)
|
4
|
-
for the Rails asset pipeline. Could work with other Sprockets stuff down the road, too. But for now, it's
|
4
|
+
for the Rails asset pipeline. Even provides functionalty for Sass to target those pages! Could work with other Sprockets stuff down the road, too. But for now, it's
|
5
5
|
pretty married to Rails. Also, needs tests for the exactly four things that it does. Anyone wanna add exactly four Cucumber features?
|
6
6
|
|
7
7
|
## Why?
|
8
8
|
|
9
9
|
I got sick of on-page JavaScript. Also I like using the Asset Pipeline for what it's actually intended for,
|
10
|
-
reducing the number of HTTP requests.
|
10
|
+
reducing the number of HTTP requests. Finally, targeting pages in Sass should be easy.
|
11
11
|
|
12
12
|
## How?
|
13
13
|
|
@@ -51,4 +51,12 @@ alert("I am showing a site");
|
|
51
51
|
alert "I am also showing a site"
|
52
52
|
```
|
53
53
|
|
54
|
+
Want to target that page in your Sass? Use a little string interpolation and a function that generates a selector:
|
55
|
+
|
56
|
+
``` sass
|
57
|
+
#{bullseye('sites/show')} {
|
58
|
+
background-color: green;
|
59
|
+
}
|
60
|
+
```
|
61
|
+
|
54
62
|
Piece of cake.
|
data/bullseye.gemspec
CHANGED
data/lib/bullseye.rb
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'sass'
|
2
|
+
|
3
|
+
module Sass::Script::Functions
|
4
|
+
def bullseye(target)
|
5
|
+
assert_type target, :String
|
6
|
+
|
7
|
+
parts = target.value.split('/')
|
8
|
+
action = parts.pop
|
9
|
+
controller = parts.join('/')
|
10
|
+
|
11
|
+
Sass::Script::String.new("body[data-action='#{action}'][data-controller='#{controller}']")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
@@ -1,9 +1,11 @@
|
|
1
1
|
require 'tilt'
|
2
|
-
require '
|
2
|
+
require 'bullseye/tilt/find_parts'
|
3
3
|
|
4
4
|
module Bullseye
|
5
5
|
module Tilt
|
6
6
|
class BullseyeTemplate < ::Tilt::Template
|
7
|
+
include Bullseye::Tilt::FindParts
|
8
|
+
|
7
9
|
def self.default_mime_type
|
8
10
|
'application/javascript'
|
9
11
|
end
|
@@ -12,9 +14,7 @@ module Bullseye
|
|
12
14
|
end
|
13
15
|
|
14
16
|
def evaluate(scope, locals, &block)
|
15
|
-
|
16
|
-
action = parts.pop
|
17
|
-
controller = parts[1..-1].join('/')
|
17
|
+
@scope = scope
|
18
18
|
|
19
19
|
<<-JS
|
20
20
|
Bullseye.target('#{controller}', '#{action}', function() {
|
data/lib/bullseye/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bullseye
|
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:
|
@@ -43,6 +43,22 @@ dependencies:
|
|
43
43
|
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: sass
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
46
62
|
description: Implement DOM-ready execution in Rails using the Asset Pipeline.
|
47
63
|
email:
|
48
64
|
- john@coswellproductions.com
|
@@ -60,7 +76,9 @@ files:
|
|
60
76
|
- lib/bullseye.rb
|
61
77
|
- lib/bullseye/engine.rb
|
62
78
|
- lib/bullseye/helpers/bullseye_helper.rb
|
79
|
+
- lib/bullseye/sass/bullseye_functions.rb
|
63
80
|
- lib/bullseye/tilt/bullseye_template.rb
|
81
|
+
- lib/bullseye/tilt/find_parts.rb
|
64
82
|
- lib/bullseye/version.rb
|
65
83
|
homepage: ''
|
66
84
|
licenses: []
|