itcss_cli 0.1.4 → 0.1.5

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: 6853a274f056753afd959f97c6a9d414b1d0a260
4
- data.tar.gz: 0014e848f9c64fa692128b5cc295a6d7ac2efae2
3
+ metadata.gz: ea154784e23c6a08385db6353432199f5775796b
4
+ data.tar.gz: f51d7a1b8c3049f4688bdd0a5f5f0f5b3e0eded1
5
5
  SHA512:
6
- metadata.gz: 2c571c4f48d04484e5f3bcffa4990d2311eb5b0f52ce5bdc8caf0a340ff56b97889c605044631bd0771dbc97b9af58ebdfa1a15a3780e68b4b90d00de0c8f290
7
- data.tar.gz: 1034e67d344e63f807bb63e4e0b26d9f2ed3b89b6a37017632706e06d74c237cf4131544daf741af6a5acb588e24763a732d081600125578bd3a8b32bd9fb1e4
6
+ metadata.gz: 0de32800b48ef55863416a7942e5f8713baf8484a4dd6b504eca6fa0429b6fb87dd73d29ca9b08698f02092e3dd08f1069008a493a1e061b670cd35eea8e712e
7
+ data.tar.gz: 0baa7860c0a2402132928e252ee168aa87bf5bacc174ff161eacf3c5e9a2ae57b33f150eb1d71cef22460451a46628c3973a0712b1b6d6d7df7cc9e443f32e51
Binary file
@@ -1,3 +1,3 @@
1
1
  module ItcssCli
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
data/lib/itcss_cli.rb CHANGED
@@ -2,28 +2,48 @@ require "itcss_cli/version"
2
2
  require "erb"
3
3
  require 'fileutils'
4
4
  require 'colorize'
5
+ require 'yaml'
5
6
 
6
7
  module ItcssCli
7
8
  class Init
8
9
 
9
- ITCSS_DIR = "stylesheets"
10
- ITCSS_BASE_FILE = "application"
10
+ ITCSS_CONFIG_FILE = 'itcss.yml'
11
+ ITCSS_CONFIG_TEMPLATE = File.expand_path(File.join(File.dirname(__FILE__), "../templates/itcss_config.erb"))
11
12
  ITCSS_MODULE_TEMPLATE = File.expand_path(File.join(File.dirname(__FILE__), "../templates/itcss_module.erb"))
12
13
  ITCSS_APP_TEMPLATE = File.expand_path(File.join(File.dirname(__FILE__), "../templates/itcss_application.erb"))
13
14
  ITCSS_FILES = ["settings", "tools", "generic", "base", "objects", "components", "trumps"]
14
15
 
16
+ if File.exist?(ITCSS_CONFIG_FILE)
17
+ ITCSS_CONFIG = YAML.load_file(ITCSS_CONFIG_FILE)
18
+ ITCSS_CONFIG['stylesheets_directory'].nil? ? ITCSS_DIR = nil : ITCSS_DIR = ITCSS_CONFIG['stylesheets_directory']
19
+ ITCSS_CONFIG['stylesheets_import_file'].nil? ? ITCSS_BASE_FILE = nil : ITCSS_BASE_FILE = ITCSS_CONFIG['stylesheets_import_file']
20
+ else
21
+ ITCSS_CONFIG = nil
22
+ end
23
+
24
+ def init_checker
25
+ if ITCSS_CONFIG.nil?
26
+ puts "There's no #{ITCSS_CONFIG_FILE} created yet. Run `itcss init` to create it.".red
27
+ abort
28
+ end
29
+ end
30
+
15
31
  def command_parser
16
32
  # $ itcss init
17
33
  if ARGV[0] == 'init'
34
+ init_itcss_config_file
18
35
 
19
36
 
20
37
  # $ itcss install example
21
38
  elsif ARGV[0] == 'install' && ARGV[1] == 'example'
39
+ init_checker
22
40
  new_itcss_basic_structure
23
41
 
24
42
 
25
43
  # $ itcss new components buttons
26
44
  elsif ARGV[0] == 'new' && ARGV[1] && ARGV[2]
45
+ init_checker
46
+
27
47
  occur = ITCSS_FILES.each_index.select{|i| ITCSS_FILES[i].include? ARGV[1]}
28
48
  if occur.size == 1
29
49
  new_itcss_module(ITCSS_FILES[occur[0]], ARGV[2])
@@ -31,10 +51,27 @@ module ItcssCli
31
51
  puts "'#{ARGV[1]}' is not an ITCSS module. Try settings, tools, generic, base, objects, components or trumps.".red
32
52
  abort
33
53
  end
54
+
55
+ # $ itcss update
56
+ elsif ARGV[0] == 'install' || ARGV[0] == 'new' || ARGV[0] == 'update'
57
+ generate_base_file
34
58
  end
59
+ end
35
60
 
36
- # Enable ITCSS_BASE_FILE to import all itcss dependencies
37
- generate_base_file
61
+ def init_itcss_config_file
62
+ unless File.exist?(ITCSS_CONFIG_FILE)
63
+ File.open ITCSS_CONFIG_TEMPLATE do |io|
64
+ template = ERB.new io.read
65
+
66
+ File.open ITCSS_CONFIG_FILE, "w+" do |out|
67
+ out.puts template.result binding
68
+ end
69
+ end
70
+ puts "create #{ITCSS_CONFIG_FILE}".green
71
+ else
72
+ puts "#{ITCSS_CONFIG_FILE} already exists.".red
73
+ abort
74
+ end
38
75
  end
39
76
 
40
77
  def new_itcss_basic_structure
@@ -50,7 +87,7 @@ module ItcssCli
50
87
  def new_itcss_module(type, file)
51
88
  File.open ITCSS_MODULE_TEMPLATE do |io|
52
89
  template = ERB.new io.read
53
- new_itcss_file(type, file, template)
90
+ new_itcss_file(type, file, template)
54
91
  end
55
92
  end
56
93
 
@@ -76,8 +113,8 @@ module ItcssCli
76
113
  File.open ITCSS_APP_TEMPLATE do |io|
77
114
  template = ERB.new io.read
78
115
 
79
- contents = "application.sass"
80
- File.open "#{ITCSS_DIR}/application.sass", "w+" do |out|
116
+ contents = "#{ITCSS_BASE_FILE}.sass"
117
+ File.open "#{ITCSS_DIR}/#{ITCSS_BASE_FILE}.sass", "w+" do |out|
81
118
  out.puts template.result binding
82
119
  end
83
120
  end
@@ -0,0 +1,6 @@
1
+ <%= "# " + "=" * 40 %>
2
+ <%= "# #itcss.yml" %>
3
+ <%= "# " + "=" * 40 %>
4
+
5
+ stylesheets_directory: 'styleshets'
6
+ stylesheets_import_file: 'application'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: itcss_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kande Bonfim
@@ -73,10 +73,12 @@ files:
73
73
  - itcss_cli-0.1.1.gem
74
74
  - itcss_cli-0.1.2.gem
75
75
  - itcss_cli-0.1.3.gem
76
+ - itcss_cli-0.1.4.gem
76
77
  - itcss_cli.gemspec
77
78
  - lib/itcss_cli.rb
78
79
  - lib/itcss_cli/version.rb
79
80
  - templates/itcss_application.erb
81
+ - templates/itcss_config.erb
80
82
  - templates/itcss_module.erb
81
83
  homepage: https://github.com/kandebonfim/itcss_cli
82
84
  licenses: