css_sortor 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc ADDED
@@ -0,0 +1,6 @@
1
+ = css_sortor
2
+
3
+ CSS整理术
4
+
5
+ :include:css_sortor.rdoc
6
+
data/bin/css_sortor ADDED
@@ -0,0 +1,83 @@
1
+ #!/usr/bin/env ruby
2
+ require 'gli'
3
+ begin # XXX: Remove this begin/rescue before distributing your app
4
+ require 'css_sortor'
5
+ rescue LoadError
6
+ STDERR.puts "In development, you need to use `bundle exec bin/todo` to run your app"
7
+ STDERR.puts "At install-time, RubyGems will make sure lib, etc. are in the load path"
8
+ STDERR.puts "Feel free to remove this message from bin/css_sortor now"
9
+ exit 64
10
+ end
11
+
12
+ include GLI::App
13
+
14
+ program_desc 'Fantasy CSS Sort Out Method.'
15
+
16
+ version CssSortor::VERSION
17
+
18
+ desc 'hard-code check.'
19
+ switch [:d,:hardcode]
20
+
21
+ desc 'remove comments?'
22
+ switch [:c,:comment]
23
+
24
+ desc 'how properties sort by. abc: A - Z | group: system specified group'
25
+ default_value 'abc'
26
+ arg_name 'mode'
27
+ flag [:o,:order]
28
+
29
+ desc 'Generate new .css file from a targeted input.'
30
+ arg_name 'Describe arguments to generate here'
31
+ command [:g, :generate] do |c|
32
+ c.desc 'Describe a switch to generate'
33
+ c.switch :s
34
+
35
+ c.desc 'Describe a flag to generate'
36
+ c.default_value 'default'
37
+ c.flag :f
38
+ c.action do |global_options,options,args|
39
+
40
+ # Your command logic here
41
+
42
+ # If you have any errors, just raise them
43
+ # raise "that command made no sense"
44
+ options = {}
45
+ options[:order] = global_options[:order].gsub(/^=/, '')
46
+ options[:comment] = global_options[:comment]
47
+ options[:path] = args[0]
48
+ options[:target] = args[1]
49
+
50
+ CSSSortor.new(options)
51
+ end
52
+ end
53
+
54
+ desc 'Generate new package for all .css files in the specified path.'
55
+ arg_name 'Describe arguments to package here'
56
+ command [:p, :package] do |c|
57
+ c.action do |global_options,options,args|
58
+ puts "package command ran"
59
+ end
60
+ end
61
+
62
+ pre do |global,command,options,args|
63
+ # Pre logic here
64
+ # Return true to proceed; false to abourt and not call the
65
+ # chosen command
66
+ # Use skips_pre before a command to skip this block
67
+ # on that command only
68
+ true
69
+ end
70
+
71
+ post do |global,command,options,args|
72
+ # Post logic here
73
+ # Use skips_post before a command to skip this
74
+ # block on that command only
75
+ end
76
+
77
+ on_error do |exception|
78
+ # Error logic here
79
+ # return false to skip default error handling
80
+ true
81
+ end
82
+
83
+ exit run(ARGV)
data/css_sortor.rdoc ADDED
@@ -0,0 +1,5 @@
1
+ = css_sortor
2
+
3
+ Generate this with
4
+ css_sortor rdoc
5
+ After you have described your command line interface
@@ -0,0 +1,3 @@
1
+ module CssSortor
2
+ VERSION = '0.0.1'
3
+ end
data/lib/css_sortor.rb ADDED
@@ -0,0 +1,39 @@
1
+ require 'css_sortor/version.rb'
2
+ require 'css_sortor/css_parser.rb'
3
+ require 'debugger'
4
+
5
+ # Add requires for other files you add to your project here, so
6
+ # you just need to require this one file in your bin file
7
+
8
+ class CSSSortor
9
+
10
+ def initialize(options)
11
+ @parser = CssParser::Parser.new({:sort_mode => options[:order]})
12
+ @parser.load_file!(options[:path])
13
+ # output
14
+
15
+ file = File.expand_path(options[:path])
16
+ file_name = File.basename(file, ".css")
17
+ f_path = File.dirname(file)
18
+ target_name = options[:target] || file_name+'_output.css'
19
+
20
+ if check_exist(f_path + '/' +target_name) then
21
+ raise "#{target_name} is exist now, You can not cover this file."
22
+ return
23
+ end
24
+
25
+ create_file(f_path + '/' +target_name)
26
+ puts 'Generate has been successfully.'
27
+ end
28
+
29
+ def check_exist(path)
30
+ Dir.glob(path).length > 0
31
+ end
32
+
33
+ def create_file(path)
34
+ open(File.expand_path(path, __FILE__), 'w') { |f|
35
+ f.puts @parser.to_s
36
+ }
37
+ end
38
+
39
+ end
metadata ADDED
@@ -0,0 +1,154 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: css_sortor
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Kenshin
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-12-11 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
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
+ - !ruby/object:Gem::Dependency
31
+ name: rdoc
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: aruba
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: addressable
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: debugger
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: gli
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - '='
100
+ - !ruby/object:Gem::Version
101
+ version: 2.5.0
102
+ type: :runtime
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - '='
108
+ - !ruby/object:Gem::Version
109
+ version: 2.5.0
110
+ description:
111
+ email: tracy.xin.li@gmail.com
112
+ executables:
113
+ - css_sortor
114
+ extensions: []
115
+ extra_rdoc_files:
116
+ - README.rdoc
117
+ - css_sortor.rdoc
118
+ files:
119
+ - bin/css_sortor
120
+ - lib/css_sortor/version.rb
121
+ - lib/css_sortor.rb
122
+ - README.rdoc
123
+ - css_sortor.rdoc
124
+ homepage: http://www.decimage.com
125
+ licenses: []
126
+ post_install_message:
127
+ rdoc_options:
128
+ - --title
129
+ - css_sortor
130
+ - --main
131
+ - README.rdoc
132
+ - -ri
133
+ require_paths:
134
+ - lib
135
+ - lib
136
+ required_ruby_version: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ required_rubygems_version: !ruby/object:Gem::Requirement
143
+ none: false
144
+ requirements:
145
+ - - ! '>='
146
+ - !ruby/object:Gem::Version
147
+ version: '0'
148
+ requirements: []
149
+ rubyforge_project:
150
+ rubygems_version: 1.8.22
151
+ signing_key:
152
+ specification_version: 3
153
+ summary: Fantasy CSS Sort Out Method.
154
+ test_files: []