web_optimizer 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -33,6 +33,12 @@ dir_path = "/Users/tamvo/code/rails/minesweeper/config/locales"
33
33
  WebStuff::YamlTranslations.translations_locale_dir(dir_path, "en", "it")
34
34
  ```
35
35
 
36
+ Convert Less to Scss
37
+ ```
38
+ require "web_stuff"
39
+ WebStuff::LessToScss.convert("less_path")
40
+ ```
41
+
36
42
  ## Contributing
37
43
 
38
44
  1. Fork it
@@ -1,3 +1,3 @@
1
1
  module WebOptimizer
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -0,0 +1,19 @@
1
+ module WebStuff
2
+ module LessToScss
3
+ def self.convert(path)
4
+ raise "Invalid less file" unless File.extname(path) == ".less"
5
+
6
+ content = File.read(path)
7
+ content.gsub!(/@/, "$").gsub!(/\.([\w\-]*)\s*\((.*)\)\s*\{/, "@mixin \1\(\2\)\n{")
8
+ content.gsub!(/\.([\w\-]*\(.*\)\s*;)/, "@include \1").gsub!(/~"(.*)"/, "\#{\"\1\"}")
9
+ content.gsub!("$import", "@import")
10
+ content.gsub!("$media", "@media")
11
+ content.gsub!("$keyframes", "@-moz-")
12
+ content.gsub!("$-o-", "@-o-")
13
+ content.gsub!("$-webkit-", "@-webkit-")
14
+
15
+ Common::Util.write_file(File.join(File.dirname(path), File.basename(path, ".*") + ".scss"), content)
16
+ end
17
+ end
18
+ end
19
+
@@ -34,7 +34,7 @@ module WebStuff
34
34
  elsif value.is_a?(String)
35
35
  translation = Common::GoogleTranslator.translate(value, from_locale, to_locale)
36
36
  translation = translation.gsub(/\n/, "").gsub(/% s/, "%s").gsub(/ /, " ").
37
- gsub(/<(\/?) (\w+) >/, '<\1\2>').gsub(/ ([\.,!?])( |$)/, '\1')
37
+ gsub(/< ?(\/?) (\w+) >/, '<\1\2>').gsub(/ ([\.,!?])( |$)/, '\1')
38
38
 
39
39
  translation_data = translation.scan(/{ ?{.*?} ?}/)
40
40
  value_data = value.scan(/{{.*?}}/)
data/lib/web_stuff.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require "common/util"
2
2
  require "common/google_translator"
3
3
  require "web_stuff/yaml_translations"
4
+ require "web_stuff/less_to_scss"
4
5
 
5
6
  module WebStuff
6
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: web_optimizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,14 +9,14 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-01-31 00:00:00.000000000 Z
12
+ date: 2014-02-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: active_support
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - '>='
19
+ - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
21
  version: '0'
22
22
  type: :runtime
@@ -24,7 +24,7 @@ dependencies:
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
- - - '>='
27
+ - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
29
  version: '0'
30
30
  - !ruby/object:Gem::Dependency
@@ -32,7 +32,7 @@ dependencies:
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
35
- - - '>='
35
+ - - ! '>='
36
36
  - !ruby/object:Gem::Version
37
37
  version: '0'
38
38
  type: :runtime
@@ -40,7 +40,7 @@ dependencies:
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
- - - '>='
43
+ - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
46
  description: Compress all css file in specified dir with yuicompressor
@@ -70,6 +70,7 @@ files:
70
70
  - lib/web_optimizer/optimize_images.rb
71
71
  - lib/web_optimizer/version.rb
72
72
  - lib/web_stuff.rb
73
+ - lib/web_stuff/less_to_scss.rb
73
74
  - lib/web_stuff/yaml_translations.rb
74
75
  - tmp.rb
75
76
  - web_optimizer.gemspec
@@ -83,13 +84,13 @@ require_paths:
83
84
  required_ruby_version: !ruby/object:Gem::Requirement
84
85
  none: false
85
86
  requirements:
86
- - - '>='
87
+ - - ! '>='
87
88
  - !ruby/object:Gem::Version
88
89
  version: '0'
89
90
  required_rubygems_version: !ruby/object:Gem::Requirement
90
91
  none: false
91
92
  requirements:
92
- - - '>='
93
+ - - ! '>='
93
94
  - !ruby/object:Gem::Version
94
95
  version: '0'
95
96
  requirements: []