ditto_code 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/dittoc +61 -19
  3. data/lib/dittocode/parse.rb +5 -3
  4. metadata +15 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5fed41ea34a21cd5ca04e6e1e49170f86c22d196
4
- data.tar.gz: cee727cacd7234595c33cd6e716d392842ffa896
3
+ metadata.gz: 5549d700221d252487353b5b7b3399979672dc19
4
+ data.tar.gz: 2f6f6063f7c9637980ed943ddf3e109118b56e2d
5
5
  SHA512:
6
- metadata.gz: 7138f2589367b8d2c8526bbc4ef4db56226cb804a842610b5f5df878d358e121fd39098def71a255a21c5a7d74e309a23f44abca774ae65becf7f632dbb52175
7
- data.tar.gz: a775da4d2ad86fe823d76b72e9d987ca30263cd1321ec047b8ec4bfa8a9218b91f72687e054a40c102fee5f1ecada3c5942a716d9aa3ec5c3beb4e9544ef449e
6
+ metadata.gz: d45c0bc34ba051ae0c40a16e153a66ae271fc9ee085b71839e694bc2578982de4ac65b3ed2b05c73239fcadda0a4b465e7f4cb9caaf6354eafc8ffc9ed3f5023
7
+ data.tar.gz: ae585332913884569fa7aa483905462c780dfa01127e98ad7762dc5e93c4ac432ebdcb456b4ed0cf361bf7248ce14b215293be0514cfc629d6b190deedb4ba07
data/bin/dittoc CHANGED
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'ditto_code'
3
+ require 'rainbow'
4
+ require 'rainbow/ext/string'
3
5
 
4
6
  # ===============================================================
5
7
  # FUNCTIONS
@@ -11,6 +13,31 @@ def usage(s)
11
13
  exit(1)
12
14
  end
13
15
 
16
+ def showhelp
17
+
18
+ $stdout.puts("Usage: [options] ENVIRONMENT file|folder")
19
+ $stdout.puts("DittoCode")
20
+
21
+ end
22
+
23
+ def showHi
24
+
25
+ $stdout.puts "Ditto say -> Hey man! What's up?".color("ee82ee")
26
+ $stdout.puts("")
27
+ $stdout.puts " /~\\_.-~-._,--.._".color("ee82ee")
28
+ $stdout.puts " | ~-.._ ".color("ee82ee")
29
+ $stdout.puts " | . . \\".color("ee82ee")
30
+ $stdout.puts " | / ".color("ee82ee")
31
+ $stdout.puts " | --...., | \\ ".color("ee82ee")
32
+ $stdout.puts " / \\".color("ee82ee")
33
+ $stdout.puts " | |".color("ee82ee")
34
+ $stdout.puts " | \\".color("ee82ee")
35
+ $stdout.puts " / |".color("ee82ee")
36
+ $stdout.puts " \\_.-._ __...___.._______/".color("ee82ee")
37
+ $stdout.puts " ~~".color("ee82ee")
38
+
39
+ end
40
+
14
41
  # Check if the filepath is a file or a directory
15
42
  def isFile?(filepath)
16
43
  if File.file?(filepath)
@@ -65,6 +92,7 @@ $override = false;
65
92
  @recursive = false
66
93
  @allow_views = false
67
94
  $indent = false
95
+ @stop = false
68
96
 
69
97
  # ===============================================================
70
98
  # INITIATION
@@ -89,7 +117,16 @@ while ARGV[0]
89
117
  $indent = true
90
118
  when '--allow-views'
91
119
  ARGV.shift
92
- @allow_views = true
120
+ @allow_views = true
121
+ when '--help'
122
+ when '-h'
123
+ showHelp
124
+ @stop = true
125
+ ARGV.shift
126
+ when '-hi'
127
+ showHi
128
+ @stop = true
129
+ ARGV.shift
93
130
  when /^-/
94
131
  usage("Unknown option: #{ARGV[0].inspect}");
95
132
  else
@@ -107,29 +144,34 @@ end
107
144
  # EXECUTION
108
145
  # ===============================================================
109
146
 
110
- # Initiate ditto
111
- @ditto = DittoCode::Parse.new($environment, $override, $verbose, $indent)
112
147
 
113
- # Check if the user has introduce a folder/file
114
- if $folder.empty?
148
+ unless @stop
149
+
150
+ # Initiate ditto
151
+ @ditto = DittoCode::Parse.new($environment, $override, $verbose, $indent)
115
152
 
116
- usage("There aren't any folder/file")
153
+ # Check if the user has introduce a folder/file
154
+ if $folder.empty?
117
155
 
118
- else
156
+ usage("There aren't any folder/file")
119
157
 
120
- # Check if is a folder
121
- if $isFolder
122
- # Check /
123
- unless $folder.end_with?("/") then $folder = $folder + "/" end
124
- # Iterate inside the folder
125
- iterateFolder($folder)
126
158
  else
127
- # Only a file
128
- if $folder.end_with?('.rb')
129
- @ditto.transformation($folder, false)
130
- elsif $folder.end_with?('.erb') && @allow_views
131
- @ditto.transformation($folder, true)
132
- end
159
+
160
+ # Check if is a folder
161
+ if $isFolder
162
+ # Check /
163
+ unless $folder.end_with?("/") then $folder = $folder + "/" end
164
+ # Iterate inside the folder
165
+ iterateFolder($folder)
166
+ else
167
+ # Only a file
168
+ if $folder.end_with?('.rb')
169
+ @ditto.transformation($folder, false)
170
+ elsif $folder.end_with?('.erb') && @allow_views
171
+ @ditto.transformation($folder, true)
172
+ end
173
+ end
174
+
133
175
  end
134
176
 
135
177
  end
@@ -3,6 +3,8 @@ module DittoCode
3
3
 
4
4
  # Require
5
5
  require 'indentation'
6
+ require 'rainbow'
7
+ require 'rainbow/ext/string'
6
8
 
7
9
  # Say hello ditto
8
10
  def self.hi
@@ -104,7 +106,7 @@ module DittoCode
104
106
  end
105
107
 
106
108
  if @verbose || dittos != 0
107
- say "[Ok] #{dittos} lines ditted on #{@dir_name}#{@file_name}!"
109
+ say "#{dittos} lines ditted on #{@dir_name}#{@file_name}! [ "+"OK".color("64d67f")+" ]"
108
110
  end
109
111
 
110
112
  closeFile(out_file)
@@ -112,9 +114,9 @@ module DittoCode
112
114
  rescue => e
113
115
 
114
116
  if e.class == Errno::EISDIR
115
- say "[Err] If you wants to use a directory use the option -f"
117
+ say "[Err] If you wants to use a directory use the option -f [ "+"ERR".color("ed5757")+" ]"
116
118
  else
117
- say "[Err] Oh no! I have an error :("
119
+ say "[Err] Oh no! I have an error :( [ "+"ERR".color("ed5757")+" ]"
118
120
  end
119
121
 
120
122
  if @verbose
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ditto_code
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Angel M Miguel
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.1.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: rainbow
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 2.0.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 2.0.0
27
41
  description: Transform your ruby code based on a custom variable.
28
42
  email: angel@laux.es
29
43
  executables: