kaizen-cli 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 103744ec517294c254285376049e9f363261f691
4
+ data.tar.gz: 3861fd70c8e9ba37d8186bb7fe389c8a34114bf9
5
+ SHA512:
6
+ metadata.gz: 375bb8a2c4e2049958a5b9bb7a3c917c078c0a54060c6d3e3a3d7952c1793c21282497f1899a7f67bc38e3575e1b6d7fc5cbf958c00ab8ad1e5393a05e2ac243
7
+ data.tar.gz: c9d86ff903e92022ba354d9d9783f569734800b48467a24b3b8211e668d551bf10afbd4c407123aab4dce5434f8ef7685dd8ad8f87521806b9264b5a287d24d0
data/.gitignore ADDED
@@ -0,0 +1,40 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ ## Specific to RubyMotion:
14
+ .dat*
15
+ .repl_history
16
+ build/
17
+
18
+ ## Documentation cache and generated files:
19
+ /.yardoc/
20
+ /_yardoc/
21
+ /doc/
22
+ /rdoc/
23
+
24
+ ## Environment normalization:
25
+ /.bundle/
26
+ /vendor/bundle
27
+ /lib/bundler/man/
28
+
29
+ # for a library or gem, you might want to ignore these files since the code is
30
+ # intended to run in multiple environments; otherwise, check them in:
31
+ # Gemfile.lock
32
+ # .ruby-version
33
+ # .ruby-gemset
34
+
35
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
36
+ .rvmrc
37
+ .DS_Store
38
+ Gemfile.lock
39
+ .sass-cache/
40
+ .sass-cache/*
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.3.0
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Wixel Development Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,2 @@
1
+ # Kaizen-CLI
2
+ A Ruby Gem for the Kaizen front end framework
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require 'bundler'
2
+ require 'rake/testtask'
3
+ require 'bundler/gem_tasks'
4
+
5
+ Rake::TestTask.new do |t|
6
+ t.libs << 'test'
7
+ end
8
+
9
+ desc 'Run tests'
10
+ task default: :test
data/bin/kzn ADDED
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+ require 'kaizen'
5
+ require 'date'
6
+
7
+ begin
8
+ options = {
9
+ watch: false,
10
+ overwrite: false,
11
+ verbose: false
12
+ }
13
+
14
+ OptionParser.new do |opts|
15
+ opts.banner = 'Usage: kzn [optional path] [options]'
16
+
17
+ opts.on('-s', '--start', 'Start the pre-processors for the static assets') do |v|
18
+ options[:watch] = v
19
+ end
20
+
21
+ opts.on('-f', '--force', 'Overwrite files that already exist in the target directory') do |v|
22
+ options[:overwrite] = v
23
+ end
24
+
25
+ opts.on('-v', '--verbose', 'Turn on the verbose setting for the Kaizen CLI') do |v|
26
+ options[:verbose] = v
27
+ end
28
+ end.parse!
29
+
30
+ year = Date.today.strftime("%Y")
31
+
32
+ kanji = "改善"
33
+
34
+ Kaizen::CLI.pout(:default, "============================================")
35
+ Kaizen::CLI.pout(:default, "+ #{Paint[kanji, :cyan]} Kaizen Framework ")
36
+ Kaizen::CLI.pout(:default, "+ Copyright © #{year} Wixel Software Solutions ")
37
+ Kaizen::CLI.pout(:default, "+ https://github.com/Wixel/Kaizen ")
38
+ Kaizen::CLI.pout(:default, "============================================")
39
+
40
+ if options[:watch]
41
+ path = Dir.pwd
42
+
43
+ if !ARGV.empty?
44
+ path = ARGV[0]
45
+ end
46
+
47
+ Kaizen::CLI.watch(path)
48
+ end
49
+
50
+ if !options[:watch]
51
+ if ARGV.empty?
52
+ Kaizen::CLI.pout(:default, '> kzn [optional path] [options]')
53
+ Kaizen::CLI.pout(:default, '> kzn --help')
54
+ else
55
+ Kaizen::CLI.new(ARGV[0], options[:overwrite], options[:verbose])
56
+ end
57
+ end
58
+ rescue SignalException => e
59
+ Kaizen::CLI.pout(:debug, "お疲れ様でした (おつかれさまでした, otsukaresama deshita!")
60
+ end
data/install.sh ADDED
@@ -0,0 +1,10 @@
1
+ #!/bin/sh
2
+
3
+ echo "+ Uninstalling Gem:"
4
+ gem uninstall kaizen
5
+
6
+ echo "+ Building Gemspec"
7
+ rake build --trace
8
+
9
+ echo "+ Installing Gem"
10
+ rake install --trace
@@ -0,0 +1,25 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'kaizen-cli'
3
+ s.version = '0.0.9'
4
+ s.date = '2016-06-06'
5
+ s.summary = 'Kaizen CLI is the command line tool for the Kaizen framework'
6
+ s.description = 'Kaizen is a simple-as-possible responsive Sass framework.'
7
+ s.authors = ['Nico Van Zyl', 'Sean Nieuwoudt']
8
+ s.email = 'team@wixelhq.com'
9
+ s.files = `git ls-files -z`.split("\x0")
10
+ s.license = 'MIT'
11
+ s.homepage = 'https://wixelhq.com'
12
+ s.executables << 'kzn'
13
+ s.require_paths = ['lib']
14
+
15
+ s.add_runtime_dependency 'minitest', '~> 5.7', '>= 5.7.0'
16
+ s.add_runtime_dependency 'rake', '~> 10.4', '>= 10.4.2'
17
+ s.add_runtime_dependency 'bundler', '~> 1.7'
18
+ s.add_runtime_dependency 'zip-zip', '~> 0.3'
19
+ s.add_runtime_dependency 'rubyzip', '~> 1.2', '>= 1.2.0'
20
+ s.add_runtime_dependency 'paint', '~> 1.0', '>= 1.0.1'
21
+ s.add_runtime_dependency 'sass', '~> 3.4', '>= 3.4.22'
22
+ s.add_runtime_dependency 'bourbon', '~> 4.2', '>= 4.2.7'
23
+ s.add_development_dependency 'rubocop', '~> 0.40', '>= 0.40.0'
24
+
25
+ end
data/lib/kaizen.rb ADDED
@@ -0,0 +1,233 @@
1
+ require 'yaml'
2
+ require 'tmpdir'
3
+ require 'net/http'
4
+ require 'uri'
5
+ require 'tempfile'
6
+ require 'zip'
7
+ require 'paint'
8
+ require 'bourbon'
9
+ require 'thread'
10
+
11
+ module Kaizen
12
+ class CLI
13
+ attr_reader :directory
14
+ attr_reader :overwrite
15
+ attr_reader :verbose
16
+
17
+ ##
18
+ # Initializer
19
+ #
20
+ def initialize(directory, overwrite = false, verbose = false)
21
+ @directory = File.expand_path(directory)
22
+ @overwrite = overwrite
23
+ @verbose = verbose
24
+
25
+ if !File.directory? @directory
26
+ Kaizen::CLI.pout(:error, "The directory does not exist: #{@directory}")
27
+ else
28
+ Kaizen::CLI.pout(:info, "Installing to: #{@directory}")
29
+
30
+ start!
31
+ end
32
+ end
33
+
34
+ private
35
+
36
+ def verbose(m)
37
+ Kaizen::CLI.pout(:debug, m) if @verbose
38
+ end
39
+
40
+ ##
41
+ # Invoke the fetch and unzip process
42
+ #
43
+ def start!
44
+ verbose('Starting...')
45
+
46
+ process_kaizen_archive(
47
+ save_to_tempfile('https://codeload.github.com/Wixel/Kaizen/zip/master')
48
+ )
49
+
50
+ process_normalize_archive(
51
+ save_to_tempfile('https://codeload.github.com/necolas/normalize.css/zip/master')
52
+ )
53
+
54
+ install_bourbon!
55
+ end
56
+
57
+ ##
58
+ # Install the bourbon items
59
+ #
60
+ def install_bourbon!
61
+ verbose("Installing Bourbon")
62
+
63
+ path = "#{@directory}/scss/vendor/"
64
+
65
+ Kaizen::CLI.pout(:info, "Running: bourbon install --path #{path}")
66
+
67
+ `bourbon install --path #{path}`
68
+ end
69
+
70
+ ##
71
+ # Unzip the Kaizen zip file to the specified destination
72
+ #
73
+ def process_kaizen_archive(archive)
74
+
75
+ verbose("Processing Kaizen archive: #{archive.path}")
76
+
77
+ Zip::File.open(archive.path) do |zip_file|
78
+ manifest = zip_file.glob('Kaizen-master/*.yml').first
79
+
80
+ if manifest.nil?
81
+ Kaizen::CLI.pout(:error, "Manifest file 'cli.yml' not found")
82
+ next
83
+ end
84
+
85
+ allowed = YAML.load(manifest.get_input_stream.read)
86
+
87
+ zip_file.each do |f|
88
+ sanitized = f.name.gsub('Kaizen-master', '')
89
+
90
+ next if sanitized == '/'
91
+
92
+ path = File.join(@directory, sanitized)
93
+
94
+ if !allowed.include?(sanitized)
95
+ Kaizen::CLI.pout(:warn, "Excluded: #{path}")
96
+ next
97
+ end
98
+
99
+ if !File.exist?(path)
100
+ zip_file.extract(f, path)
101
+ else
102
+ if @overwrite
103
+ zip_file.extract(f, path) { true }
104
+ else
105
+ Kaizen::CLI.pout(:error, "File already exists: #{path}")
106
+ end
107
+ end
108
+ end
109
+ end
110
+ end
111
+
112
+ ##
113
+ # Download and install the normalize.css archive
114
+ #
115
+ def process_normalize_archive(archive)
116
+
117
+ verbose("Processing normalize.css archive #{archive.path}")
118
+
119
+ Zip::File.open(archive.path) do |zip_file|
120
+ zip_file.each do |f|
121
+ if f.name == "normalize.css-master/normalize.css"
122
+ path = File.join(@directory, 'scss/vendor/normalize.scss')
123
+ begin
124
+ zip_file.extract(f, path) if !File.exist? path
125
+ rescue Exception => e
126
+ Kaizen::CLI.pout(:error, "Unable to write #{path}")
127
+ end
128
+ end
129
+ end
130
+ end
131
+ end
132
+
133
+ ##
134
+ # Download a path and save it to a temp directory
135
+ #
136
+ def save_to_tempfile(url)
137
+ verbose("Downloading #{url}")
138
+
139
+ uri = URI.parse(url)
140
+ http = Net::HTTP.new(uri.host, uri.port)
141
+ http.use_ssl = true
142
+
143
+ http.start do |http|
144
+ resp = http.get(uri.path)
145
+ file = Tempfile.new('master.zip')
146
+ file.binmode
147
+ file.write(resp.body)
148
+ file.flush
149
+ file.close
150
+
151
+ verbose("Saved to #{file.path}")
152
+
153
+ file
154
+ end
155
+ end
156
+
157
+ ##
158
+ # Output helper
159
+ #
160
+ def self.pout(optn, msg)
161
+ format = '%d/%m/%Y %H:%M'
162
+
163
+ case optn
164
+ when :error
165
+ puts "#{Time.now.strftime(format)} #{Paint[msg, :red]}"
166
+ when :info
167
+ puts "#{Time.now.strftime(format)} #{Paint[msg, :green]}"
168
+ when :warn
169
+ puts "#{Time.now.strftime(format)} #{Paint[msg, :yellow]}"
170
+ when :debug
171
+ puts "#{Time.now.strftime(format)} #{Paint[msg, :cyan]}"
172
+ when :default
173
+ puts msg
174
+ end
175
+ end
176
+
177
+ ##
178
+ # Watch the provided directory
179
+ #
180
+ def self.watch(path)
181
+ path = File.expand_path(path)
182
+
183
+ if File.exist? path
184
+ Kaizen::CLI.pout(:info, "Watching: #{path}")
185
+
186
+ options = {
187
+ :syntax => :scss,
188
+ :style => :compressed,
189
+ :cache => false,
190
+ :read_cache => false
191
+ }
192
+
193
+ Sass::Engine::DEFAULT_OPTIONS[:load_paths].tap do |load_paths|
194
+ load_paths << "#{path}/scss"
195
+ end
196
+
197
+ css_directory = "#{path}/css"
198
+
199
+ if !File.exist?(css_directory)
200
+ Dir.mkdir(css_directory)
201
+ end
202
+
203
+ has_error = false
204
+
205
+ loop do
206
+ css = Sass::Engine.new(
207
+ File.read("#{path}/scss/main.scss"), options
208
+ )
209
+
210
+ begin
211
+ File.open("#{css_directory}/main.css", "w") do |f|
212
+ f.write css.render
213
+ end
214
+
215
+ if has_error
216
+ Kaizen::CLI.pout(:debug, "You fixed the issue, thanks :)")
217
+ has_error = false
218
+ end
219
+
220
+ sleep 3
221
+ rescue Sass::SyntaxError => e
222
+ Kaizen::CLI.pout(:error, e.message)
223
+ has_error = true
224
+ sleep 10
225
+ end
226
+ end
227
+ else
228
+ Kaizen::CLI.pout(:error, "Path does not exist: #{path}")
229
+ end
230
+ end
231
+
232
+ end
233
+ end
@@ -0,0 +1,9 @@
1
+ require 'minitest/autorun'
2
+ require 'kaizen-cli'
3
+
4
+ class KaizenTest < Minitest::Test
5
+ def setup
6
+ # @TODO: Test Download
7
+ # @TODO: Test Unzip
8
+ end
9
+ end
metadata ADDED
@@ -0,0 +1,224 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kaizen-cli
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.9
5
+ platform: ruby
6
+ authors:
7
+ - Nico Van Zyl
8
+ - Sean Nieuwoudt
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2016-06-06 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: minitest
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '5.7'
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 5.7.0
24
+ type: :runtime
25
+ prerelease: false
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ requirements:
28
+ - - "~>"
29
+ - !ruby/object:Gem::Version
30
+ version: '5.7'
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 5.7.0
34
+ - !ruby/object:Gem::Dependency
35
+ name: rake
36
+ requirement: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.4'
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 10.4.2
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - "~>"
49
+ - !ruby/object:Gem::Version
50
+ version: '10.4'
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 10.4.2
54
+ - !ruby/object:Gem::Dependency
55
+ name: bundler
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '1.7'
61
+ type: :runtime
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '1.7'
68
+ - !ruby/object:Gem::Dependency
69
+ name: zip-zip
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '0.3'
75
+ type: :runtime
76
+ prerelease: false
77
+ version_requirements: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '0.3'
82
+ - !ruby/object:Gem::Dependency
83
+ name: rubyzip
84
+ requirement: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '1.2'
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: 1.2.0
92
+ type: :runtime
93
+ prerelease: false
94
+ version_requirements: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - "~>"
97
+ - !ruby/object:Gem::Version
98
+ version: '1.2'
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: 1.2.0
102
+ - !ruby/object:Gem::Dependency
103
+ name: paint
104
+ requirement: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - "~>"
107
+ - !ruby/object:Gem::Version
108
+ version: '1.0'
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: 1.0.1
112
+ type: :runtime
113
+ prerelease: false
114
+ version_requirements: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - "~>"
117
+ - !ruby/object:Gem::Version
118
+ version: '1.0'
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: 1.0.1
122
+ - !ruby/object:Gem::Dependency
123
+ name: sass
124
+ requirement: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - "~>"
127
+ - !ruby/object:Gem::Version
128
+ version: '3.4'
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: 3.4.22
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '3.4'
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ version: 3.4.22
142
+ - !ruby/object:Gem::Dependency
143
+ name: bourbon
144
+ requirement: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - "~>"
147
+ - !ruby/object:Gem::Version
148
+ version: '4.2'
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ version: 4.2.7
152
+ type: :runtime
153
+ prerelease: false
154
+ version_requirements: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - "~>"
157
+ - !ruby/object:Gem::Version
158
+ version: '4.2'
159
+ - - ">="
160
+ - !ruby/object:Gem::Version
161
+ version: 4.2.7
162
+ - !ruby/object:Gem::Dependency
163
+ name: rubocop
164
+ requirement: !ruby/object:Gem::Requirement
165
+ requirements:
166
+ - - "~>"
167
+ - !ruby/object:Gem::Version
168
+ version: '0.40'
169
+ - - ">="
170
+ - !ruby/object:Gem::Version
171
+ version: 0.40.0
172
+ type: :development
173
+ prerelease: false
174
+ version_requirements: !ruby/object:Gem::Requirement
175
+ requirements:
176
+ - - "~>"
177
+ - !ruby/object:Gem::Version
178
+ version: '0.40'
179
+ - - ">="
180
+ - !ruby/object:Gem::Version
181
+ version: 0.40.0
182
+ description: Kaizen is a simple-as-possible responsive Sass framework.
183
+ email: team@wixelhq.com
184
+ executables:
185
+ - kzn
186
+ extensions: []
187
+ extra_rdoc_files: []
188
+ files:
189
+ - ".gitignore"
190
+ - ".ruby-version"
191
+ - Gemfile
192
+ - LICENSE
193
+ - README.md
194
+ - Rakefile
195
+ - bin/kzn
196
+ - install.sh
197
+ - kaizen-cli.gemspec
198
+ - lib/kaizen.rb
199
+ - test/test_kaizen.rb
200
+ homepage: https://wixelhq.com
201
+ licenses:
202
+ - MIT
203
+ metadata: {}
204
+ post_install_message:
205
+ rdoc_options: []
206
+ require_paths:
207
+ - lib
208
+ required_ruby_version: !ruby/object:Gem::Requirement
209
+ requirements:
210
+ - - ">="
211
+ - !ruby/object:Gem::Version
212
+ version: '0'
213
+ required_rubygems_version: !ruby/object:Gem::Requirement
214
+ requirements:
215
+ - - ">="
216
+ - !ruby/object:Gem::Version
217
+ version: '0'
218
+ requirements: []
219
+ rubyforge_project:
220
+ rubygems_version: 2.5.1
221
+ signing_key:
222
+ specification_version: 4
223
+ summary: Kaizen CLI is the command line tool for the Kaizen framework
224
+ test_files: []