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 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.
@@ -17,4 +17,5 @@ Gem::Specification.new do |gem|
17
17
 
18
18
  gem.add_dependency 'tilt'
19
19
  gem.add_dependency 'sprockets'
20
+ gem.add_dependency 'sass'
20
21
  end
@@ -1,3 +1,4 @@
1
1
  require "bullseye/version"
2
2
  require 'bullseye/engine' if defined?(Rails::Engine)
3
3
  require 'bullseye/tilt/bullseye_template'
4
+ require 'bullseye/sass/bullseye_functions'
@@ -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 'sprockets'
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
- parts = scope.logical_path.split('/')
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() {
@@ -0,0 +1,18 @@
1
+ module Bullseye
2
+ module Tilt
3
+ module FindParts
4
+ def action
5
+ parts.last
6
+ end
7
+
8
+ def controller
9
+ parts[0..-2].join('/')
10
+ end
11
+
12
+ def parts
13
+ @scope.logical_path.split('/')[1..-1]
14
+ end
15
+ end
16
+ end
17
+ end
18
+
@@ -1,3 +1,3 @@
1
1
  module Bullseye
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
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.1
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: []