mcnamara 0.1 → 0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. data/Change.log +11 -0
  2. data/LICENSE +19 -0
  3. data/README +18 -16
  4. data/Rakefile +1 -1
  5. data/lib/mcnamara.rb +30 -6
  6. metadata +2 -2
data/Change.log CHANGED
@@ -0,0 +1,11 @@
1
+ -- Nov. 25th, 2009
2
+
3
+ * added some file name functionality to support a request:
4
+ "Would be nice to be able to name CSS files that cover multiple versions of a specific folder, e.g.:
5
+ style-msie-lte-6.css (less than or equal to IE 6.0)
6
+ style-msie-gt-6.css (greater than)
7
+ style-msie-7-to-8.css OR style-msie-8-to-7.css (reversed)"
8
+
9
+ -- Nov. 24th, 2009
10
+
11
+ * coded initial version of McNamara
data/LICENSE CHANGED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2009 Kristan 'Krispy' Uccello <krispy@soldierofcode.com> - Soldier Of Code
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ 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 IN
19
+ THE SOFTWARE.
data/README CHANGED
@@ -2,21 +2,18 @@
2
2
 
3
3
  STILL A WORK IN PROGRESS
4
4
 
5
- After working on Spy vs Spy (http://github.com/kuccello/spy-vs-spy) I wanted to build a system that would allow me to
6
- serve up css specific to various browsers if I needed to. How many times have you fixed a css design in one browser only
7
- to have it break in another. Then you fix the other and it break the first one! McNamara attempts to solve this issue
8
- by allowing you to have css browser/platform overrides that will be served up in place of your default one.
5
+ After working on Spy vs Spy (http://github.com/kuccello/spy-vs-spy) I wanted to build a system that would allow me to serve up css specific to various browsers if I needed to. How many times have you fixed a css design in one browser only to have it break in another. Then you fix the other and it break the first one! McNamara attempts to solve this issue by allowing you to have css browser/platform overrides that will be served up in place of your default one.
9
6
 
10
7
  Here's how it works:
11
8
 
12
- Say you have a web application that serves up css from the directory "/home/kuccello/myapp/public/css" and you have a
13
- css file called "style.css" in that directory. Now, you have a special case for Internet Explorer 6.0 and another case
14
- for Safari. What you would do is create another file in your css directory (can even be a sub directory deeply nested!)
15
- called "style-msie-6-0.css" and you put your full css into that (that is all the contents of style with the changes needed
16
- for internet explorer. As well you would create a file called "style-safari.css" where you would put all of the contents
17
- of "style.css" with the changes specific for Safari. Then you put the McNamara middleware upstream of what ever is serving
18
- your css and voila! when the browser is Safari the "style-safari.css" is served and when the browser is IE6.0 then the
19
- "style-msie-6-0.css" is served and all you need to reference in your html is "style.css"!!
9
+ Say you have a web application that serves up css from the directory "/home/kuccello/myapp/public/css" and you have a css file called "style.css" in that directory. Now, you have a special case for Internet Explorer 6.0 and another case for Safari. What you would do is create another file in your css directory (can even be a sub directory deeply nested!) called "style-msie-6-0.css" and you put your full css into that (that is all the contents of style with the changes needed for internet explorer. As well you would create a file called "style-safari.css" where you would put all of the contents of "style.css" with the changes specific for Safari. Then you put the McNamara middleware upstream of what ever is serving your css and voila! when the browser is Safari the "style-safari.css" is served and when the browser is IE6.0 then the "style-msie-6-0.css" is served and all you need to reference in your html is "style.css"!!
10
+
11
+ Now there is more, you can also use comment style overrides in your file names too.
12
+
13
+ >> style-msie-lte-6.css (less than or equal to IE 6.0)
14
+ >> style-msie-gt-6.css (greater than)
15
+ >> style-msie-7-to-8.css OR style-msie-8-to-7.css (reversed)
16
+ >> style-msie-6-to-8.css OR style-msie-8-to-6.css TWO VERSION DIFFERENCE
20
17
 
21
18
  = usage:
22
19
 
@@ -24,17 +21,22 @@ require 'mcnamara'
24
21
 
25
22
  use SOC::McNamara, "/usr/local/some_css_dir"
26
23
 
27
-
28
24
  All you need to do is have browser overrides for the css you want.
29
25
  stylename-<browser lowercase>-<version.major>-<version.minor>-<version.sub>.css
30
26
  stylename-<browser lowercase>-<version.major>-<version.minor>.css
27
+ stylename-<browser lowercase>-<version.major>-to-<version.major-1>.css
28
+ stylename-<browser lowercase>-<version.major>-to-<version.major-2>.css
29
+ stylename-<browser lowercase>-<version.major-1>-to-<version.major>.css
30
+ stylename-<browser lowercase>-<version.major-2>-to-<version.major>.css
31
+ stylename-<browser lowercase>-lte-<version.major>.css
32
+ stylename-<browser lowercase>-gte-<version.major>.css
33
+ stylename-<browser lowercase>-gt-<version.major>.css
34
+ stylename-<browser lowercase>-lt-<version.major>.css
31
35
  stylename-<browser lowercase>-<version.major>.css
32
- stylename-<platform lowercase spaces replaced with _>-<mobile>.css
33
- stylename-<platform lowercase spaces replaced with _>.css
34
36
  stylename-<browser lowercase>.css
35
37
 
36
38
  = notes:
37
39
 
38
- you can have spy-vs-spy upstream of this middleware
40
+ you can have spy-vs-spy upstream of this middleware but it is not a requirement - McNamara will create its own Spy vs Spy instance as needed and put it into the rack env
39
41
 
40
42
  if you use this middleware then you don't need spy-vs-spy downstream
data/Rakefile CHANGED
@@ -9,7 +9,7 @@ begin
9
9
  s.homepage = "http://github.com/kuccello/Mcnamara"
10
10
  s.authors = ['Kristan "Krispy" Uccello']
11
11
  s.files = FileList["[A-Z]*", "{lib,test}/**/*"]
12
- s.version = "0.1"
12
+ s.version = "0.2"
13
13
  end
14
14
  Jeweler::GemcutterTasks.new
15
15
  rescue LoadError
data/lib/mcnamara.rb CHANGED
@@ -41,6 +41,35 @@ module SoldierOfCode
41
41
  @css_dir = css_dir
42
42
  end
43
43
 
44
+ def build_possible_overrides(spy_vs_spy)
45
+
46
+ possible_overrides = []
47
+
48
+ possible_overrides << "-#{spy_vs_spy.browser}-#{spy_vs_spy.version.major}-#{spy_vs_spy.version.minor}-#{spy_vs_spy.version.sub}.css" if spy_vs_spy.version.major && spy_vs_spy.version.minor && spy_vs_spy.version.sub
49
+
50
+ possible_overrides << "-#{spy_vs_spy.browser}-#{spy_vs_spy.version.major}-#{spy_vs_spy.version.minor}.css" if spy_vs_spy.version.major && spy_vs_spy.version.minor
51
+
52
+ # trickier conditionals
53
+ possible_overrides << "-#{spy_vs_spy.browser}-#{spy_vs_spy.version.major}-to-#{spy_vs_spy.version.major.to_i-1}.css" if spy_vs_spy.version.major && (spy_vs_spy.version.major.to_i - 1 > 0)
54
+ possible_overrides << "-#{spy_vs_spy.browser}-#{spy_vs_spy.version.major.to_i-1}-to-#{spy_vs_spy.version.major}.css" if spy_vs_spy.version.major && (spy_vs_spy.version.major.to_i - 1 > 0)
55
+
56
+ possible_overrides << "-#{spy_vs_spy.browser}-#{spy_vs_spy.version.major}-to-#{spy_vs_spy.version.major.to_i-2}.css" if spy_vs_spy.version.major && (spy_vs_spy.version.major.to_i - 2 > 0)
57
+ possible_overrides << "-#{spy_vs_spy.browser}-#{spy_vs_spy.version.major.to_i-2}-to-#{spy_vs_spy.version.major}.css" if spy_vs_spy.version.major && (spy_vs_spy.version.major.to_i - 2 > 0)
58
+
59
+ # multi version coverage
60
+ possible_overrides << "-#{spy_vs_spy.browser}-gte-#{spy_vs_spy.version.major}.css" if spy_vs_spy.version.major
61
+ possible_overrides << "-#{spy_vs_spy.browser}-lte-#{spy_vs_spy.version.major}.css" if spy_vs_spy.version.major
62
+ possible_overrides << "-#{spy_vs_spy.browser}-gt-#{spy_vs_spy.version.major}.css" if spy_vs_spy.version.major
63
+ possible_overrides << "-#{spy_vs_spy.browser}-lt-#{spy_vs_spy.version.major}.css" if spy_vs_spy.version.major
64
+
65
+ possible_overrides << "-#{spy_vs_spy.browser}-#{spy_vs_spy.version.major}.css" if spy_vs_spy.version.major
66
+
67
+ possible_overrides << "-#{spy_vs_spy.browser}.css"
68
+
69
+ return possible_overrides
70
+
71
+ end
72
+
44
73
  def call(env)
45
74
 
46
75
  begin
@@ -59,12 +88,7 @@ module SoldierOfCode
59
88
 
60
89
  # need a base directory to scann...
61
90
  # TODO -- ripe for a cache
62
- possible_overrides = []
63
- possible_overrides << "-#{spy_vs_spy.browser}-#{spy_vs_spy.version.major}-#{spy_vs_spy.version.minor}-#{spy_vs_spy.version.sub}.css" if spy_vs_spy.version.major && spy_vs_spy.version.minor && spy_vs_spy.version.sub
64
- possible_overrides << "-#{spy_vs_spy.browser}-#{spy_vs_spy.version.major}-#{spy_vs_spy.version.minor}.css" if spy_vs_spy.version.major && spy_vs_spy.version.minor
65
- possible_overrides << "-#{spy_vs_spy.browser}-#{spy_vs_spy.version.major}.css" if spy_vs_spy.version.major
66
-
67
- possible_overrides << "-#{spy_vs_spy.browser}.css"
91
+ possible_overrides = build_possible_overrides(spy_vs_spy)
68
92
 
69
93
  Dir["#{@css_dir}/**/*.css"].each do |css_file|
70
94
  possible_overrides.each do |override|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mcnamara
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.1"
4
+ version: "0.2"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kristan "Krispy" Uccello
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-24 00:00:00 -05:00
12
+ date: 2009-11-25 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies: []
15
15