spiffing 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
1
  .DS_Store
2
2
  css/
3
- pkg/
3
+ pkg/
4
+ .rvmrc
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- spiffing (0.0.1)
4
+ spiffing (0.0.2)
5
5
  commander
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
- # Spiffing gem
1
+ # Spiffing
2
2
 
3
- Write CSS using proper English in ruby with Spiffing gem. Spiffing gem is a ruby gem version of [Spiffing CSS](http://spiffingcss.com/) by [@idiot](https://twitter.com/idiot), a CSS preprocessor for British developers in the wild.
3
+ Write CSS using proper English in ruby apps with Spiffing.
4
+
5
+ Spiffing is a ruby gem version of [Spiffing CSS](http://spiffingcss.com/) by [@idiot](https://twitter.com/idiot), a CSS preprocessor for British developers, or developers who prefer to write proper English.
4
6
 
5
7
  ## Installation
6
8
 
@@ -26,4 +28,40 @@ To convert multiple well-spelt CSS files
26
28
 
27
29
  spiffing convert stylesheets/hownice.css stylesheets/reset.css stylesheets/style.css
28
30
 
29
- Your well-spelt CSS files would be converted and written into the same directory with `-converted` following the original file name, i.e. by running the command `spiffing convert /stylesheets/hownice.css`, a `/stylesheets/hownice-converted.css` will be created.
31
+ Your well-spelt CSS files would be converted and written into the same directory with `-converted` following the original file name.
32
+
33
+ ## Example
34
+
35
+ /* Your well-spelt CSS */
36
+
37
+ body {
38
+ background-colour: grey !please;
39
+ transparency: 0.5;
40
+ text-align: centre;
41
+ font-weight: plump;
42
+ text-transform: capitalise;
43
+ }
44
+
45
+ .frame {
46
+ background-photograph: url('/queen.png') !please;
47
+ }
48
+
49
+ becomes
50
+
51
+ /* Output CSS */
52
+
53
+ body {
54
+ background-color: gray !important;
55
+ opacity: 0.5;
56
+ text-align: center;
57
+ font-weight: bold;
58
+ text-transform: capitalize;
59
+ }
60
+
61
+ .frame {
62
+ background-image: url('/queen.png') !important;
63
+ }
64
+
65
+ ## Disclaimer
66
+
67
+ content: "Have some humour" !please;
data/bin/spiffing CHANGED
@@ -14,9 +14,13 @@ command :convert do |c|
14
14
  c.example 'Convert multiple well-spelt CSS files', 'spiffing convert stylesheets/hownice.css stylesheets/reset.css stylesheets/style.css'
15
15
 
16
16
  c.action do |args, options|
17
- args.each do |file|
18
- css = Spiffing::CSS.new(file)
19
- css.mugglified
17
+ args.each do |filepath|
18
+ begin
19
+ spiff = Spiffing::CSSConverter.new filepath
20
+ spiff.mugglify
21
+ rescue Errno::ENOENT
22
+ puts "- We cannot find your file."
23
+ end
20
24
  end
21
25
  end
22
26
 
@@ -1,3 +1,3 @@
1
1
  module Spiffing
2
- VERSION = "0.0.2"
3
- end
2
+ VERSION = "0.0.3"
3
+ end
data/lib/spiffing.rb CHANGED
@@ -1,64 +1,41 @@
1
1
  require "spiffing/version"
2
2
 
3
3
  module Spiffing
4
- class CSS
5
-
6
- def initialize file
7
-
8
- begin
9
- @file = file
10
- @css = File.read file
11
- rescue Errno::ENOENT => e
12
- @notfound = true
13
- puts "- Good day. We cannot find your file, unfortunately."
14
- end
15
-
16
- @mugglifications = {
17
- 'colour' => 'color',
18
- 'grey' => 'gray',
19
- '!please' => '!important',
20
- 'transparency' => 'opacity',
21
- 'centre' => 'center',
22
- 'plump' => 'bold',
23
- '-photograph' => '-image',
24
- 'capitalise' => 'capitalize'
25
- }
26
4
 
5
+ class CSSConverter
6
+
7
+ MUGGLIFICATIONS = {
8
+ 'colour' => 'color',
9
+ 'grey' => 'gray',
10
+ '!please' => '!important',
11
+ 'transparency' => 'opacity',
12
+ 'centre' => 'center',
13
+ 'plump' => 'bold',
14
+ '-photograph' => '-image',
15
+ 'capitalise' => 'capitalize'
16
+ }
17
+
18
+ def initialize spiffing_css_path
19
+ @spiffing_filepath = spiffing_css_path
20
+ @spiffing_css = File.read spiffing_css_path
27
21
  end
28
22
 
29
- def mugglified
30
-
31
- begin
32
- @mugglifications.each do |proper_english, some_other_english|
33
- @css = @css.gsub(proper_english, some_other_english)
34
- end
35
- create_new_css
36
-
37
- rescue => e
38
- unless @notfound
39
- puts "- Good lord, something went wrong and we don't know what. We are terribly sorry, sir."
40
- end
41
-
23
+ def mugglify
24
+ MUGGLIFICATIONS.each do |proper_english, some_other_english|
25
+ @normal_css = @spiffing_css.gsub(proper_english, some_other_english)
42
26
  end
43
27
 
44
- end
45
-
46
- def create_new_css
28
+ new_filename = File.basename( @spiffing_filepath ,'.*') + "-converted.css"
29
+ normal_css_file = File.new File.dirname(@spiffing_filepath) + "/" + new_filename, "w"
30
+ normal_css_file.write @normal_css
31
+ normal_css_file.close
47
32
 
48
- begin
49
- new_filename = File.basename( @file ,'.*') + "-converted.css"
50
- new_css = File.new File.dirname(@file) + "/" + new_filename, "w"
51
- new_css.write @css
52
- new_css.close
53
-
54
- puts "- Brilliant. Your file '#{@file}' has been converted. New file name '#{new_filename}'."
55
-
56
- rescue => e
57
- puts "- Good lord, something went wrong and we don't know what. We are terribly sorry, sir."
58
-
59
- end
33
+ puts "- Brilliant. Your file '#{@spiffing_filepath}' has been converted. New file name '#{new_filename}'."
60
34
 
35
+ rescue
36
+ puts "- Something went wrong and we don't know what. We are terribly sorry."
61
37
  end
62
38
 
63
39
  end
40
+
64
41
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spiffing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
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-03-29 00:00:00.000000000 Z
12
+ date: 2013-03-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: commander