quik 0.1.1 → 0.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 785b1927725b5af2d4d264dc3132321c3f131c1d
4
- data.tar.gz: b6434cd8d1f3efa6ecc20f7c4d22816344349ded
3
+ metadata.gz: ec4d08a256216dfb3a8551980b43722a36f120c3
4
+ data.tar.gz: 371f5399bc9662da8d31f42b2127d41454ad1228
5
5
  SHA512:
6
- metadata.gz: 30a338f561763c7598ebc0bc178bbbd9b728728adae312646f55e132fed137c3f82e0a58625001b9b366bf4d6c3466fd6723de0be2ad4b5b207f7fa7ebfd2fa2
7
- data.tar.gz: 27b4f8c2845a1755bcead194bce36dc9b7d543d1914a78f7e124261722df64b2ebd824fc06ef44a3f60304c2ac6a84924503e8f29257793d196b46dd6858f8b5
6
+ metadata.gz: 1728295b7296be2f344409c4f0bdbbd2433d5c9f0a27a950b2b661395129220b946898517a8e0850dc9b99cb2fafb933292c0989266287d4f932052a0a3101be
7
+ data.tar.gz: ab52d9f8afde30ef62a06127720d902944e7e499bf6644ca882c6622146ac2c0f924a9e13902ef6ac5d4d987bbf156f08c9a512a2664c21983e914653d993ac6
data/Manifest.txt CHANGED
@@ -8,6 +8,7 @@ lib/quik.rb
8
8
  lib/quik/builder.rb
9
9
  lib/quik/cli/main.rb
10
10
  lib/quik/cli/opts.rb
11
+ lib/quik/colors.rb
11
12
  lib/quik/config.rb
12
13
  lib/quik/merger.rb
13
14
  lib/quik/package.rb
@@ -20,5 +21,8 @@ test/data/gem-starter-template/lib/__filename__/$filename$.rb
20
21
  test/data/gem-starter-template/lib/__filename__/__filename__/test.rb
21
22
  test/data/gem-starter-template/lib/__filename__/version.rb
22
23
  test/helper.rb
24
+ test/test_colors.rb
25
+ test/test_config.rb
23
26
  test/test_merger.rb
24
27
  test/test_package.rb
28
+ test/test_wizard.rb
data/README.md CHANGED
@@ -83,8 +83,9 @@ folder.
83
83
 
84
84
  **More Quick Starter Wizard Scripts**
85
85
 
86
- See the [Rubyref Scripts](https://github.com/rubyref/scripts) library.
86
+ For more ruby quick starter scripts, see the [Rubyref Scripts](https://github.com/rubyref/scripts) library.
87
87
 
88
+ For static site (e.g. jekyll) quick starter scripts, see the [Mr. Hyde's Scripts](https://github.com/mrhydescripts/scripts) library.
88
89
 
89
90
 
90
91
 
data/lib/quik.rb CHANGED
@@ -22,7 +22,7 @@ require 'quik/merger'
22
22
  require 'quik/config'
23
23
  require 'quik/wizard'
24
24
  require 'quik/builder'
25
-
25
+ require 'quik/colors'
26
26
 
27
27
 
28
28
  require 'quik/cli/opts'
data/lib/quik/builder.rb CHANGED
@@ -47,6 +47,8 @@ class Builder
47
47
  # do nothing; dry run
48
48
  else
49
49
  @pak = Package.new( key )
50
+
51
+ puts "GET #{@pak.remote_zip_url}".bold.green ## output network access in green bold
50
52
  @pak.download
51
53
  ## pak.unzip( "#{@output_dir}/#{key}" )
52
54
  end
data/lib/quik/cli/main.rb CHANGED
@@ -58,6 +58,9 @@ def self.fetch_script( name )
58
58
  else ## fetch remote script
59
59
  url = "https://github.com/rubyref/scripts/raw/master/#{name}.rb"
60
60
  ## assume utf8 text encoding for now
61
+
62
+ puts "GET #{url}".bold.green ## output network access in green bold
63
+
61
64
  worker = Fetcher::Worker.new
62
65
  text = worker.read_utf8!( url )
63
66
  end
@@ -0,0 +1,147 @@
1
+ # encoding: utf-8
2
+
3
+ ### todo: move to textutils for (re)use - why? why not??
4
+ ### todo add some references to alternative color gems
5
+ ##
6
+ ## e.g. https://github.com/fazibear/colorize
7
+ ## http://github.com/ssoroka/ansi
8
+ ## http://flori.github.com/term-ansicolor/
9
+ ## http://github.com/sickill/rainbow
10
+
11
+
12
+ ## move to core_ext.rb - why? why not??
13
+
14
+ ###
15
+ ## fix: use css style
16
+ ## e.g. color( :red )
17
+ ## color( :blue )
18
+ ## background_color( :red )
19
+ ## font_style( :bold ) -- why? why not??
20
+
21
+ class String
22
+
23
+ def self.use_colors?
24
+ @@use_color ||= true
25
+ ## todo/fix: check for windows on load (set to false;otherwise true)
26
+ @@use_color
27
+ end
28
+
29
+ def self.use_colors=(value)
30
+ @@use_color = value
31
+ end
32
+
33
+
34
+ def red() colorize(31); end
35
+ def green() colorize(32); end
36
+ def yellow() colorize(33); end ## note: more brown-ish (if not used w/ bold/bright mode) ??
37
+ def blue() colorize(34); end
38
+ def magenta() colorize(35); end ## pink ??
39
+ def cyan() colorize(36); end ## light blue ??
40
+
41
+ def bold() colorize(1); end ## just use 0 clear for now; instead of BOLD_OFF (22) code; use bright as an alias??
42
+
43
+ private
44
+ def colorize(code)
45
+ if self.class.use_colors?
46
+ "\e[#{code}m#{self}\e[0m"
47
+ else
48
+ self
49
+ end
50
+ end
51
+
52
+
53
+ ## todo - add modes e.g. bold/underscore/etc.
54
+ =begin
55
+ class String
56
+ def black; "\e[30m#{self}\e[0m" end
57
+ def red; "\e[31m#{self}\e[0m" end
58
+ def green; "\e[32m#{self}\e[0m" end
59
+ def brown; "\e[33m#{self}\e[0m" end
60
+ def blue; "\e[34m#{self}\e[0m" end
61
+ def magenta; "\e[35m#{self}\e[0m" end
62
+ def cyan; "\e[36m#{self}\e[0m" end
63
+ def gray; "\e[37m#{self}\e[0m" end
64
+
65
+ def on_black; "\e[40m#{self}\e[0m" end
66
+ def on_red; "\e[41m#{self}\e[0m" end
67
+ def on_green; "\e[42m#{self}\e[0m" end
68
+ def on_brown; "\e[43m#{self}\e[0m" end
69
+ def on_blue; "\e[44m#{self}\e[0m" end
70
+ def on_magenta; "\e[45m#{self}\e[0m" end
71
+ def on_cyan; "\e[46m#{self}\e[0m" end
72
+ def on_gray; "\e[47m#{self}\e[0m" end
73
+
74
+ def bold; "\e[1m#{self}\e[21m" end
75
+ def italic; "\e[3m#{self}\e[23m" end
76
+ def underline; "\e[4m#{self}\e[24m" end
77
+ def blink; "\e[5m#{self}\e[25m" end
78
+ def reverse_color; "\e[7m#{self}\e[27m" end
79
+
80
+ use Ansi constants - why? why not? e.g.:
81
+ //foreground color
82
+ public static final String BLACK_TEXT() { return "\033[30m";}
83
+ public static final String RED_TEXT() { return "\033[31m";}
84
+ public static final String GREEN_TEXT() { return "\033[32m";}
85
+ public static final String BROWN_TEXT() { return "\033[33m";}
86
+ public static final String BLUE_TEXT() { return "\033[34m";}
87
+ public static final String MAGENTA_TEXT() { return "\033[35m";}
88
+ public static final String CYAN_TEXT() { return "\033[36m";}
89
+ public static final String GRAY_TEXT() { return "\033[37m";}
90
+
91
+ //background color
92
+ public static final String BLACK_BACK() { return "\033[40m";}
93
+ public static final String RED_BACK() { return "\033[41m";}
94
+ public static final String GREEN_BACK() { return "\033[42m";}
95
+ public static final String BROWN_BACK() { return "\033[43m";}
96
+ public static final String BLUE_BACK() { return "\033[44m";}
97
+ public static final String MAGENTA_BACK() { return "\033[45m";}
98
+ public static final String CYAN_BACK() { return "\033[46m";}
99
+ public static final String WHITE_BACK() { return "\033[47m";}
100
+
101
+ //ANSI control chars
102
+ public static final String RESET_COLORS() { return "\033[0m";}
103
+ public static final String BOLD_ON() { return "\033[1m";}
104
+ public static final String BLINK_ON() { return "\033[5m";}
105
+ public static final String REVERSE_ON() { return "\033[7m";}
106
+ public static final String BOLD_OFF() { return "\033[22m";}
107
+ public static final String BLINK_OFF() { return "\033[25m";}
108
+ public static final String REVERSE_OFF() { return "\033[27m";}
109
+ end
110
+
111
+ Code Effect
112
+ 0 Turn off all attributes
113
+ 1 Set bright mode
114
+ 4 Set underline mode
115
+ 5 Set blink mode
116
+ 7 Exchange foreground and background colors
117
+ 8 Hide text (foreground color would be the same as background)
118
+ 30 Black text
119
+ 31 Red text
120
+ 32 Green text
121
+ 33 Yellow text
122
+ 34 Blue text
123
+ 35 Magenta text
124
+ 36 Cyan text
125
+ 37 White text
126
+ 39 Default text color
127
+ 40 Black background
128
+ 41 Red background
129
+ 42 Green background
130
+ 43 Yellow background
131
+ 44 Blue background
132
+ 45 Magenta background
133
+ 46 Cyan background
134
+ 47 White background
135
+ 49 Default background color
136
+
137
+ note:
138
+ puts "\e[31m" # set format (red foreground)
139
+ puts "\e[0" # clear format
140
+ puts "green-#{"red".red}-green".green # will be green-red-normal, because of \e[0
141
+ e.g. for now colors can NOT get nested
142
+ plus if you bold/italic/etc. use it before the color e.g.
143
+ bold.red etc.
144
+ =end
145
+
146
+
147
+ end # class String
data/lib/quik/package.rb CHANGED
@@ -36,7 +36,7 @@ class Package
36
36
  dest_zip = local_zip_path
37
37
 
38
38
  ## make sure dest folder exists
39
- FileUtils.mkdir_p( local_zip_dir ) unless Dir.exists?( local_zip_dir )
39
+ FileUtils.mkdir_p( local_zip_dir ) unless Dir.exist?( local_zip_dir )
40
40
  fetch_archive( src, dest_zip )
41
41
  end
42
42
 
@@ -45,7 +45,7 @@ class Package
45
45
  dest_unzip = unzip_dir ## local_unzip_dir
46
46
 
47
47
  ## check if folders exists? if not create folder in path
48
- FileUtils.mkdir_p( dest_unzip ) unless Dir.exists?( dest_unzip )
48
+ FileUtils.mkdir_p( dest_unzip ) unless Dir.exist?( dest_unzip )
49
49
  unzip_archive( src, dest_unzip )
50
50
  end
51
51
 
@@ -75,6 +75,12 @@ private
75
75
  # e.g
76
76
  # !/starter-gh-pages/_layouts/ becomes
77
77
  # !/_layouts/ etc.
78
+
79
+ ##
80
+ ## note:
81
+ ## skip all files in "root" folder
82
+ ## only unzip files in /template(s)/ folder
83
+
78
84
  Zip::File.open( src ) do |zipfile|
79
85
  zipfile.each do |file|
80
86
  if file.directory?
@@ -83,10 +89,20 @@ private
83
89
  ### fix: only cut-off if master or gh-pages ???
84
90
  ## check if others include root folder?
85
91
  name = file.name[ file.name.index('/')+1..-1] ## cut-off root/first path entry
86
- path = File.join( dest, name)
87
- puts " unzip file zip entry - #{file.name} to #{path}"
88
- FileUtils.mkdir_p( File.dirname( path) )
89
- zipfile.extract(file, path) unless File.exist?(path)
92
+
93
+ ## note: name must start w/ template/ or templates/
94
+ ## otherwise gets skipped as "top level" docu
95
+ if name =~ /^template(s)?\//
96
+ name = name[ name.index('/')+1..-1] ## cut-off first path entry (e.g. template(s)/)
97
+
98
+ path = File.join( dest, name)
99
+ puts " unzip file zip entry - #{file.name} to #{path}"
100
+ FileUtils.mkdir_p( File.dirname( path) )
101
+ ## todo/fix: check - always overwrite if file exists - why? why not??
102
+ zipfile.extract(file, path) unless File.exist?(path)
103
+ else
104
+ puts " skip top-level docu file entry - #{file.name}"
105
+ end
90
106
  end
91
107
  end
92
108
  end
data/lib/quik/version.rb CHANGED
@@ -3,8 +3,8 @@
3
3
  module Quik
4
4
 
5
5
  MAJOR = 0 ## todo: namespace inside version or something - why? why not??
6
- MINOR = 1
7
- PATCH = 1
6
+ MINOR = 2
7
+ PATCH = 0
8
8
  VERSION = [MAJOR,MINOR,PATCH].join('.')
9
9
 
10
10
  def self.version
@@ -0,0 +1,39 @@
1
+ # encoding: utf-8
2
+
3
+ ###
4
+ # to run use
5
+ # ruby -I ./lib -I ./test test/test_colors.rb
6
+
7
+
8
+ require 'helper'
9
+
10
+
11
+ class TestColors < MiniTest::Test
12
+
13
+ def test_colors
14
+
15
+ puts "this text is blue".blue
16
+ puts "this text is red".red
17
+ puts "this text is green".green + "this text is yellow".yellow
18
+ puts "this text is magenta".magenta
19
+ puts "this text is cyan".cyan
20
+
21
+ puts "this text is blue".bold.blue
22
+ puts "this text is red".bold.red
23
+ puts "this text is green".bold.green + "this text is yellow".bold.yellow
24
+
25
+ pp String.use_colors?
26
+
27
+ assert true ## if we get here; everything is ok
28
+ end
29
+
30
+ def test_codes
31
+ assert_equal "\e[31mred\e[0m", "red".red
32
+ assert_equal "\e[34m\e[31mblue\e[0m\e[0m", "blue".red.blue
33
+ ## better to generate "\e[34m;[31m" -- why? why not? e.g. one starting escpape and codes delimited by ; ??
34
+ assert_equal "\e[1mway bold\e[0m", "way bold".bold
35
+ assert_equal "\e[36m\e[1mcyan bold\e[0m\e[0m", "cyan bold".bold.cyan
36
+ end
37
+
38
+ end # class TestColors
39
+
@@ -0,0 +1,31 @@
1
+ # encoding: utf-8
2
+
3
+ ###
4
+ # to run use
5
+ # ruby -I ./lib -I ./test test/test_config.rb
6
+
7
+
8
+ require 'helper'
9
+
10
+
11
+ class TestConfig < MiniTest::Test
12
+
13
+ def test_config
14
+
15
+ c = Quik::OpenConfig.new
16
+ c.title = 'title'
17
+ c.author.name = 'name'
18
+
19
+ c.mrhyde.last_updated = Time.now
20
+ c.mrhyde.title = 'title'
21
+ c.mrhyde.name = 'name'
22
+ c.mrhyde.theme = 'theme'
23
+ c.mrhyde.meta.info = 'test nested nested value'
24
+
25
+ pp c.to_h
26
+
27
+ assert true ## if we get here; everything is ok
28
+ end
29
+
30
+
31
+ end # class TestConfig
@@ -0,0 +1,50 @@
1
+ # encoding: utf-8
2
+
3
+ ###
4
+ # to run use
5
+ # ruby -I ./lib -I ./test test/test_wizard.rb
6
+
7
+
8
+ require 'helper'
9
+
10
+
11
+ class TestWizard < MiniTest::Test
12
+
13
+ include Quik::Wizard ## lets you use ask etc.
14
+
15
+ def test_ask
16
+
17
+ $QUIK_WIZARD_IN = EchoIO.new( <<EOS )
18
+ Another Beautiful Static Site
19
+
20
+ H. J.
21
+
22
+ 2
23
+ n
24
+ y
25
+ EOS
26
+
27
+ say "Hello, Wizard!"
28
+
29
+ title = ask "What's your site's title", "Your Site Title"
30
+ assert_equal 'Another Beautiful Static Site', title
31
+
32
+ title = ask "What's your site's title", "Your Site Title"
33
+ assert_equal 'Your Site Title', title
34
+
35
+ name = ask "Your Name"
36
+ assert_equal 'H. J.', name
37
+
38
+ theme = select "Select your theme", ["Starter", "Bootstrap", "Minimal"]
39
+ assert_equal 'Starter', theme
40
+
41
+ theme = select "Select your theme", ["Starter", "Bootstrap", "Minimal"]
42
+ assert_equal 'Bootstrap', theme
43
+
44
+ assert_equal false, yes?( "Add to GitHub" )
45
+ assert_equal false, no?( "Add to GitHub" )
46
+
47
+ assert true ## if we get here; everything is ok
48
+ end
49
+
50
+ end # class TestWizard
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quik
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-18 00:00:00.000000000 Z
11
+ date: 2015-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logutils
@@ -131,6 +131,7 @@ files:
131
131
  - lib/quik/builder.rb
132
132
  - lib/quik/cli/main.rb
133
133
  - lib/quik/cli/opts.rb
134
+ - lib/quik/colors.rb
134
135
  - lib/quik/config.rb
135
136
  - lib/quik/merger.rb
136
137
  - lib/quik/package.rb
@@ -143,8 +144,11 @@ files:
143
144
  - test/data/gem-starter-template/lib/__filename__/__filename__/test.rb
144
145
  - test/data/gem-starter-template/lib/__filename__/version.rb
145
146
  - test/helper.rb
147
+ - test/test_colors.rb
148
+ - test/test_config.rb
146
149
  - test/test_merger.rb
147
150
  - test/test_package.rb
151
+ - test/test_wizard.rb
148
152
  homepage: https://github.com/rubylibs/quik
149
153
  licenses:
150
154
  - Public Domain
@@ -172,5 +176,8 @@ signing_key:
172
176
  specification_version: 4
173
177
  summary: quik - ruby quick starter template script wizard .:. the missing code generator
174
178
  test_files:
179
+ - test/test_wizard.rb
175
180
  - test/test_merger.rb
181
+ - test/test_colors.rb
182
+ - test/test_config.rb
176
183
  - test/test_package.rb