qbuild 0.1.0.pre1 → 0.1.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: d471087792d1c18ca03c886977539c6def82be3a
4
- data.tar.gz: 458551e8a399f47d2c0d1a124eef0b7a4f4e8f63
3
+ metadata.gz: c0950972156cdc46e57489743403c62f5815e280
4
+ data.tar.gz: 3eade37f1d566130f4a31ad1349599d0c6ae0218
5
5
  SHA512:
6
- metadata.gz: b76333ff9ed4dad58a42530244d3fc7bec18c2a8df1e90a30574a0a4add470a145ff98a16ba7a6ba307eaaf9d91673177795c4384a54bca506601a2770b458ee
7
- data.tar.gz: 05aae8452a81961b3c91aa27f83efb0d8248d85509ce665fea3a2edfea584f3426b7451fd8a07b6a62aad8f273ea2d9f306cd75f2e0b6f604a7d94bd9fdb8a4c
6
+ metadata.gz: f1c46340f454eb02224cc3dc33323f49519a47c6e4b349f5febc1ad540afb3002139266efbf3625e97647563d664b50df92b0c1c577d8a154710db66505f9955
7
+ data.tar.gz: e4b75dce9394c5fb9de85526b09054f6f8dc949cd22fc0dd589199890ec38c513c5c71fbd93e56a70c247ac61978657d3765d3124a2afe0bc795d8ed0aa1a8e8
data/COC.md CHANGED
@@ -1,3 +1,3 @@
1
1
  # Code of Conduct
2
2
 
3
- Just don't be a dick.
3
+ Don't be a dick.
@@ -2,15 +2,12 @@
2
2
  "js_paths": [
3
3
  "scripts"
4
4
  ],
5
- "stylesheets_paths": [
6
- "stylesheets"
5
+ "minified_js_path": "scripts",
6
+ "stylesheet_filenames": [
7
+ "stylesheets/style.scss"
7
8
  ],
9
+ "minified_stylesheets_path": "stylesheets",
8
10
  "stylesheet_name": "style.min.css",
9
- "pre_build": [
10
- "ls -lah",
11
- "echo Starting build..."
12
- ],
13
- "post_build": [
14
- "echo Build finished!"
15
- ]
11
+ "pre_build": [],
12
+ "post_build": []
16
13
  }
@@ -1,6 +1,8 @@
1
1
  require_relative 'qbuild/version'
2
2
  require_relative 'qbuild/config'
3
3
  require_relative 'qbuild/jshandler'
4
+ require_relative 'qbuild/stylesheet_handler'
5
+ require_relative 'qbuild/build_action'
4
6
 
5
7
  module Qbuild
6
8
  def self.main(arg)
@@ -10,6 +12,8 @@ module Qbuild
10
12
  display_version
11
13
  elsif arg[0] == '--options' || arg[0] == '-o'
12
14
  display_options
15
+ elsif arg[0] == 'run'
16
+ build_this_thing
13
17
  else
14
18
  display_help
15
19
  end
@@ -20,9 +24,34 @@ module Qbuild
20
24
  def self.init
21
25
  Qbuild::Config.init
22
26
  puts
23
- PadUtils.puts_c "Qbuild initialized.", :green
27
+ PadUtils.puts_c 'Qbuild initialized.', :green
24
28
  PadUtils.puts_c "Update options in '.qbuild.json'"
25
29
  puts
30
+ rescue
31
+ PadUtils.puts_c 'Something went really wrong.', :red
32
+ end
33
+
34
+ def self.build_this_thing
35
+ start_time = Time.now
36
+ puts
37
+ unless Qbuild::Config.pre_build.nil? || Qbuild::Config.pre_build.empty?
38
+ PadUtils.puts_c 'Running pre-build scripts...', :green
39
+ Qbuild::BuildAction.run_pre_build_actions
40
+ end
41
+ PadUtils.puts_c 'Minifying JavaScript...', :green
42
+ Qbuild::Jshandler.minify_js
43
+ PadUtils.puts_c 'Converting Sass & minifying CSS...', :green
44
+ Qbuild::StylesheetHandler.transpile_and_minify_style
45
+ unless Qbuild::Config.post_build.nil? || Qbuild::Config.post_build.empty?
46
+ PadUtils.puts_c 'Running post-build scripts...', :green
47
+ Qbuild::BuildAction.run_post_build_actions
48
+ end
49
+ end_time = Time.now
50
+ interval = PadUtils.interval(start_time, end_time, :seconds)
51
+ puts
52
+ PadUtils.puts_c "Completed in #{interval} seconds!", :green
53
+ rescue
54
+ PadUtils.puts_c 'Something went really wrong.', :red
26
55
  end
27
56
 
28
57
  def self.display_options
@@ -32,12 +61,18 @@ module Qbuild
32
61
  puts "- #{path}"
33
62
  end
34
63
 
35
- stylesheets_paths = Qbuild::Config.stylesheets_paths
36
- PadUtils.puts_c 'stylesheets_paths:', :blue
37
- stylesheets_paths.each do |path|
64
+ stylesheet_filenames = Qbuild::Config.stylesheet_filenames
65
+ PadUtils.puts_c 'stylesheet_filenames:', :blue
66
+ stylesheet_filenames.each do |path|
38
67
  puts "- #{path}"
39
68
  end
40
69
 
70
+ PadUtils.puts_c 'minified_js_path:', :blue
71
+ puts "- #{Qbuild::Config.minified_js_path}"
72
+
73
+ PadUtils.puts_c 'minified_stylesheets_path', :blue
74
+ puts "- #{Qbuild::Config.minified_stylesheets_path}"
75
+
41
76
  PadUtils.puts_c 'stylesheet_name:', :blue
42
77
  puts "- #{Qbuild::Config.stylesheet_name}"
43
78
 
@@ -0,0 +1,21 @@
1
+ module Qbuild
2
+ module BuildAction
3
+ def self.run_pre_build_actions
4
+ actions = Qbuild::Config.pre_build
5
+ unless actions.nil?
6
+ actions.each do |action|
7
+ system action.to_s
8
+ end
9
+ end
10
+ end
11
+
12
+ def self.run_post_build_actions
13
+ actions = Qbuild::Config.post_build
14
+ unless actions.nil?
15
+ actions.each do |action|
16
+ system action.to_s
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,9 +1,14 @@
1
1
  require 'pad_utils'
2
+ require 'fileutils'
2
3
 
3
4
  module Qbuild
4
5
  module Config
5
6
  INIT_CONFIG_FILE = "#{File.dirname(__FILE__)}/../assets/.qbuild.json".freeze
6
7
 
8
+ def self.create_target_directory(dir_name)
9
+ FileUtils.mkdir_p(dir_name) unless File.directory?(dir_name)
10
+ end
11
+
7
12
  def self.init
8
13
  PadUtils.copy_file(INIT_CONFIG_FILE, '.')
9
14
  end
@@ -12,8 +17,16 @@ module Qbuild
12
17
  read_key(:js_paths)
13
18
  end
14
19
 
15
- def self.stylesheets_paths
16
- read_key(:stylesheets_paths)
20
+ def self.minified_js_path
21
+ read_key(:minified_js_path)
22
+ end
23
+
24
+ def self.minified_stylesheets_path
25
+ read_key(:minified_stylesheets_path)
26
+ end
27
+
28
+ def self.stylesheet_filenames
29
+ read_key(:stylesheet_filenames)
17
30
  end
18
31
 
19
32
  def self.stylesheet_name
@@ -1,19 +1,26 @@
1
1
  require 'uglifier'
2
2
  require 'pad_utils'
3
- require_relative 'config_reader'
3
+ require_relative 'config'
4
4
 
5
- module Jshandler
6
- def self.minify_js
7
- js_path = ConfigReader.options[:js_path]
8
- Dir["#{js_path}/*.js"].each do |file|
9
- unless file.include? '.min.js'
10
- jsmin = Uglifier.new.compile(File.read(file))
11
- File.write(name_min_file(file), jsmin)
5
+ module Qbuild
6
+ module Jshandler
7
+ def self.minify_js
8
+ js_paths = Qbuild::Config.js_paths
9
+ min_js_path = Qbuild::Config.minified_js_path
10
+ Qbuild::Config.create_target_directory(min_js_path)
11
+ js_paths.each do |js_path|
12
+ Dir["#{js_path}/*.js"].each do |file|
13
+ unless file.include? '.min.js'
14
+ jsmin = Uglifier.new.compile(File.read(file))
15
+ File.write("#{min_js_path}/#{name_min_file(file)}", jsmin)
16
+ end
17
+ end
12
18
  end
13
19
  end
14
- end
15
20
 
16
- def self.name_min_file(file)
17
- file.gsub(/(.*)(.js)(.*)/, '\1.min.js\3')
21
+ def self.name_min_file(file)
22
+ file = File.basename file
23
+ file.gsub(/(.*)(.js)(.*)/, '\1.min.js\3')
24
+ end
18
25
  end
19
26
  end
@@ -0,0 +1,30 @@
1
+ require 'sass'
2
+ require 'pad_utils'
3
+
4
+ module Qbuild
5
+ module StylesheetHandler
6
+ def self.transpile_and_minify_style
7
+ style_formats = ['.css', '.scss']
8
+ style_filenames = Qbuild::Config.stylesheet_filenames
9
+ min_style_path = Qbuild::Config.minified_stylesheets_path
10
+ min_style_file = Qbuild::Config.stylesheet_name
11
+ Qbuild::Config.create_target_directory(min_style_path)
12
+ content = ''
13
+ style_filenames.each do |file|
14
+ next unless PadUtils.file_exist?(file)
15
+ next unless style_formats.include? File.extname(file)
16
+ next if file.include? '.min.css'
17
+ content += "\n#{File.read(file)}"
18
+ end
19
+ minified = scss_to_css content
20
+ File.write("#{min_style_path}/#{min_style_file}", minified)
21
+ end
22
+
23
+ def self.scss_to_css(content)
24
+ sass_engine = Sass::Engine.new(content, style: :compressed,
25
+ syntax: :scss,
26
+ cache: false)
27
+ sass_engine.render
28
+ end
29
+ end
30
+ end
@@ -1,3 +1,3 @@
1
1
  module Qbuild
2
- VERSION = "0.1.0.pre1"
2
+ VERSION = '0.1.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qbuild
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nico Schuele
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-16 00:00:00.000000000 Z
11
+ date: 2016-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pad_utils
@@ -84,9 +84,10 @@ files:
84
84
  - bin/qbuild
85
85
  - lib/assets/.qbuild.json
86
86
  - lib/qbuild.rb
87
+ - lib/qbuild/build_action.rb
87
88
  - lib/qbuild/config.rb
88
- - lib/qbuild/config_reader.rb
89
89
  - lib/qbuild/jshandler.rb
90
+ - lib/qbuild/stylesheet_handler.rb
90
91
  - lib/qbuild/version.rb
91
92
  homepage: https://github.com/nicoschuele/qbuild
92
93
  licenses:
@@ -103,9 +104,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
103
104
  version: 2.2.2
104
105
  required_rubygems_version: !ruby/object:Gem::Requirement
105
106
  requirements:
106
- - - ">"
107
+ - - ">="
107
108
  - !ruby/object:Gem::Version
108
- version: 1.3.1
109
+ version: '0'
109
110
  requirements: []
110
111
  rubyforge_project:
111
112
  rubygems_version: 2.5.1
@@ -1,23 +0,0 @@
1
- require 'pad_utils'
2
-
3
- module ConfigReader
4
- def self.options
5
- opts = {}
6
- unless PadUtils.file_exist?('.qbuild.json')
7
- opts = { js_path: 'scripts', scss_path: 'stylesheets', css_path: 'stylesheets', css_file: 'style.min.css' }
8
- return opts
9
- end
10
- conf = read_config
11
- opts = {
12
- js_path: conf[:js_path],
13
- scss_path: conf[:scss_path],
14
- css_path: conf[:css_path],
15
- css_file: conf[:css_file]
16
- }
17
- opts
18
- end
19
-
20
- def self.read_config
21
- PadUtils.json_file_to_hash('.qbuild.json')
22
- end
23
- end