spiffing 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ .DS_Store
2
+ css/
3
+ pkg/
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,18 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ spiffing (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ commander (4.1.3)
10
+ highline (~> 1.6.11)
11
+ highline (1.6.16)
12
+
13
+ PLATFORMS
14
+ ruby
15
+
16
+ DEPENDENCIES
17
+ commander
18
+ spiffing!
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Mu-An Chiou
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Spiffing gem
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.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'spiffing'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install spiffing
18
+
19
+ ## Usage
20
+
21
+ To convert a well-spelt CSS file
22
+
23
+ spiffing convert stylesheets/style.css
24
+
25
+ To convert multiple well-spelt CSS files
26
+
27
+ spiffing convert stylesheets/hownice.css stylesheets/reset.css stylesheets/style.css
28
+
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.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/spiffing ADDED
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'spiffing'
4
+ require 'rubygems'
5
+ require 'commander/import'
6
+
7
+ program :version, Spiffing::VERSION
8
+ program :description, 'Write CSS using proper English'
9
+
10
+ command :convert do |c|
11
+ c.syntax = 'spiffing convert [filenames] [options]'
12
+ c.description = "Converting css files"
13
+ c.example 'Convert a well-spelt CSS file', 'spiffing convert stylesheets/style.css'
14
+ c.example 'Convert multiple well-spelt CSS files', 'spiffing convert stylesheets/hownice.css stylesheets/reset.css stylesheets/style.css'
15
+
16
+ c.action do |args, options|
17
+ args.each do |file|
18
+ css = Spiffing::CSS.new(file)
19
+ css.mugglified
20
+ end
21
+ end
22
+
23
+ end
24
+
25
+
@@ -0,0 +1,3 @@
1
+ module Spiffing
2
+ VERSION = "0.0.1"
3
+ end
data/lib/spiffing.rb ADDED
@@ -0,0 +1,64 @@
1
+ require "spiffing/version"
2
+
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
+
27
+ end
28
+
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
+
42
+ end
43
+
44
+ end
45
+
46
+ def create_new_css
47
+
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
60
+
61
+ end
62
+
63
+ end
64
+ end
data/spiffing.gemspec ADDED
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'spiffing/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "spiffing"
8
+ gem.version = Spiffing::VERSION
9
+ gem.authors = ["Mu-An Chiou"]
10
+ gem.email = ["me@muanchiou.com"]
11
+ gem.description = "Write CSS using proper English"
12
+ gem.summary = "We take your well-spelt CSS files and covert them into, well illy-spelt CSS files."
13
+ gem.homepage = "http://muan.co"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = ["spiffing"]
17
+ gem.require_paths = ["lib"]
18
+ gem.add_development_dependency("commander")
19
+ end
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: spiffing
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Mu-An Chiou
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-03-29 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: commander
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ description: Write CSS using proper English
31
+ email:
32
+ - me@muanchiou.com
33
+ executables:
34
+ - spiffing
35
+ extensions: []
36
+ extra_rdoc_files: []
37
+ files:
38
+ - .gitignore
39
+ - Gemfile
40
+ - Gemfile.lock
41
+ - LICENSE
42
+ - README.md
43
+ - Rakefile
44
+ - bin/spiffing
45
+ - lib/spiffing.rb
46
+ - lib/spiffing/version.rb
47
+ - spiffing.gemspec
48
+ homepage: http://muan.co
49
+ licenses: []
50
+ post_install_message:
51
+ rdoc_options: []
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ! '>='
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ requirements: []
67
+ rubyforge_project:
68
+ rubygems_version: 1.8.24
69
+ signing_key:
70
+ specification_version: 3
71
+ summary: We take your well-spelt CSS files and covert them into, well illy-spelt CSS
72
+ files.
73
+ test_files: []