itcss_cli 0.1.2 → 0.1.3

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: a7b4727924bf10b9cf3591b0ca65ad66e5465851
4
- data.tar.gz: 342fa68a245039c2d2a62636eb674e1ff45c46bd
3
+ metadata.gz: 095287d9c35897f38d76153eb69f5be2078a8c17
4
+ data.tar.gz: e709597aa6a1b50dc0d9b63ebb66196de4f0c311
5
5
  SHA512:
6
- metadata.gz: 9e9f313dd409febbf439ce0b1733294a24a61f61501cfae288c1adc5678ef85c2d689e23333438692ea05c8fd30df9f76d697141cf2beb6769e2f6b5c9408b4a
7
- data.tar.gz: b358d18698e31c7d6aafe90ec7a089a7c7a06bede9203107e14318bc97631f4107b0ff39aa894e43729dd0cad2a75239979c459c940d734b2a57e4ffade85535
6
+ metadata.gz: 1185993120076b6b6fcf28425067db95801e376ee4149a4312d0dff41a3a95ef803c89393641d386917c3c019be7ce358139ad9df3043753307feafe34139cca
7
+ data.tar.gz: be70322b4387c8640ed3af9b77eab2f052534f7d20245d1d024708b4eb172b83c54cac4eeb5280dd29f9e160a42fd6204b600f75048e0208eaeae42f0962d1fc
data/bin/itcss CHANGED
@@ -3,4 +3,4 @@
3
3
  require 'itcss_cli'
4
4
 
5
5
  init = ItcssCli::Init.new
6
- init.command
6
+ init.command_parser
Binary file
@@ -1,3 +1,3 @@
1
1
  module ItcssCli
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
data/lib/itcss_cli.rb CHANGED
@@ -6,29 +6,72 @@ module ItcssCli
6
6
  class Init
7
7
 
8
8
  ITCSS_DIR = "stylesheets"
9
- ITCSS_FILE_TEMPLATE = File.expand_path(File.join(File.dirname(__FILE__), "../templates/itcss_file.erb"))
9
+ ITCSS_BASE_FILE = "application"
10
+ ITCSS_MODULE_TEMPLATE = File.expand_path(File.join(File.dirname(__FILE__), "../templates/itcss_module.erb"))
11
+ ITCSS_APP_TEMPLATE = File.expand_path(File.join(File.dirname(__FILE__), "../templates/itcss_application.erb"))
12
+ ITCSS_FILES = ["settings", "tools", "generic", "base", "objects", "components", "trumps"]
10
13
 
11
- def command
12
- ARGV.each do |arg|
14
+ def command_parser
15
+ # $ itcss init
16
+ if ARGV[0] == 'init'
13
17
 
14
- File.open ITCSS_FILE_TEMPLATE do |io|
15
- template = ERB.new io.read
16
18
 
17
- files = {
18
- "settings" => "#settings.example",
19
- "components" => "#components.example"
20
- }
19
+ # $ itcss install example
20
+ elsif ARGV[0] == 'install' && ARGV[1] == 'example'
21
+ new_itcss_basic_structure
21
22
 
22
- FileUtils.mkdir_p ITCSS_DIR
23
23
 
24
- files.each do |file, contents|
25
- File.open "#{ITCSS_DIR}/#{file}.#{file}.sass", "w+" do |out|
26
- out.puts template.result binding
27
- end
28
- end
24
+ # $ itcss new components buttons
25
+ elsif ARGV[0] == 'new' && ARGV[1] && ARGV[2]
26
+ occur = ITCSS_FILES.each_index.select{|i| ITCSS_FILES[i].include? ARGV[1]}
27
+ if occur.size == 1
28
+ new_itcss_module(ITCSS_FILES[occur[0]], ARGV[2])
29
29
  end
30
+ end
31
+
32
+ # Enable ITCSS_BASE_FILE to import all itcss dependencies
33
+ generate_base_file
34
+ end
35
+
36
+ def new_itcss_basic_structure
37
+ File.open ITCSS_MODULE_TEMPLATE do |io|
38
+ template = ERB.new io.read
39
+
40
+ ITCSS_FILES.each do |file|
41
+ new_itcss_file(file, 'example', template)
42
+ end
43
+ end
44
+ end
30
45
 
46
+ def new_itcss_module(type, file)
47
+ File.open ITCSS_MODULE_TEMPLATE do |io|
48
+ template = ERB.new io.read
49
+ new_itcss_file(type, file, template)
31
50
  end
32
51
  end
52
+
53
+ def new_itcss_file(type, file, template)
54
+ FileUtils.mkdir_p ITCSS_DIR
55
+ FileUtils.mkdir_p "#{ITCSS_DIR}/#{type}"
56
+
57
+ contents = "##{type}.#{file}"
58
+ File.open "#{ITCSS_DIR}/#{type}/_#{type}.#{file}.sass", "w+" do |out|
59
+ out.puts template.result binding
60
+ end
61
+ end
62
+
63
+ def generate_base_file
64
+ itcss_files = Dir[ File.join(ITCSS_DIR, '**', '*') ].reject { |p| File.directory? p }
65
+
66
+ File.open ITCSS_APP_TEMPLATE do |io|
67
+ template = ERB.new io.read
68
+
69
+ contents = "application.sass"
70
+ File.open "#{ITCSS_DIR}/application.sass", "w+" do |out|
71
+ out.puts template.result binding
72
+ end
73
+ end
74
+ end
75
+
33
76
  end
34
77
  end
@@ -0,0 +1,6 @@
1
+ <%= "// " + "=" * 40 %>
2
+ <%= "// " + contents %>
3
+ <%= "// " + "=" * 40 %>
4
+ <% itcss_files.each do |file| %>
5
+ @import "<%= file.sub! "#{ITCSS_DIR}/", '' %>"
6
+ <% end %>
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.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kande Bonfim
@@ -57,10 +57,12 @@ files:
57
57
  - bin/setup
58
58
  - itcss_cli-0.1.0.gem
59
59
  - itcss_cli-0.1.1.gem
60
+ - itcss_cli-0.1.2.gem
60
61
  - itcss_cli.gemspec
61
62
  - lib/itcss_cli.rb
62
63
  - lib/itcss_cli/version.rb
63
- - templates/itcss_file.erb
64
+ - templates/itcss_application.erb
65
+ - templates/itcss_module.erb
64
66
  homepage: https://github.com/kandebonfim/itcss_cli
65
67
  licenses:
66
68
  - MIT
File without changes