hash_rocket 0.3.9 → 0.4.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.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hash_rocket (0.3.8)
4
+ hash_rocket (0.3.9)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -0,0 +1,9 @@
1
+ class Error < Exception
2
+ def self.process_error(e, fn)
3
+ puts "ERROR: -------> #{e} .......\nON THIS FILE: -----> #{fn}"
4
+ end
5
+
6
+ def self.unprocessable_file(fn)
7
+ puts "THE FOLLOWING FILE CAN'T BE CONVERTED: -----> #{fn}"
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ class Notification
2
+ def self.timer(time)
3
+ puts "It took #{time} seconds to complete the process"
4
+ end
5
+ end
@@ -1,3 +1,3 @@
1
1
  module HashRocket
2
- VERSION = "0.3.9"
2
+ VERSION = "0.4.0"
3
3
  end
data/lib/hash_rocket.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require "hash_rocket/version"
2
2
  require "hash_rocket/object"
3
- require "hash_rocket/boom"
3
+ require "hash_rocket/error"
4
+ require "hash_rocket/notification"
4
5
  module HashRocket
5
6
 
6
7
  if defined?(Rails)
@@ -17,15 +18,19 @@ module HashRocket
17
18
  text = organize_symbols(text, verbose)
18
19
  File.open(fn, "w") {|file| file.puts text }
19
20
  rescue => e
20
- ::Boom.process_error(e, fn)
21
+ ::Error.process_error(e, fn)
21
22
  end
22
23
  else
23
- ::Boom.unprocessable_file(fn) if verbose
24
+ ::Error.unprocessable_file(fn) if verbose
24
25
  end
25
26
  end
27
+ ::Notification.timer(Time.now - @start) if verbose
26
28
  end
29
+
27
30
  private
31
+
28
32
  def self.path_parameters(folder,path)
33
+ @start = Time.now
29
34
  return path ? %W(#{path}) : Dir.glob("**/*") unless folder
30
35
  return Dir[folder + "/**/*"] if folder
31
36
  end
@@ -41,7 +46,7 @@ private
41
46
  end
42
47
 
43
48
  def self.organize_symbols(text, verbose)
44
- # TODO replace regex to match "first_line" without duplicated expression (remove OR / flatten )
49
+ # TODO replace regex to match "first_line" without duplicated expression ( remove OR / flatten )
45
50
  result = text.scan(/([^:]:\w{1,}(\ {1,}|[\ {1,}]?)=>(\ {1,}|[\ ]?))|(^:\w{1,}(\ {1,}|[\ {1,}]?)=>(\ {1,}|[\ ]?))/).flatten
46
51
  text = match_symbols(text, result, verbose) if result
47
52
  text
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hash_rocket
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.9
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2013-04-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70330597179360 !ruby/object:Gem::Requirement
16
+ requirement: &70115169843840 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70330597179360
24
+ version_requirements: *70115169843840
25
25
  description: find and replace old hash rocket
26
26
  email:
27
27
  - mathieub@4nkh.com
@@ -66,7 +66,8 @@ files:
66
66
  - doc/top-level-namespace.html
67
67
  - hash_rocket.gemspec
68
68
  - lib/hash_rocket.rb
69
- - lib/hash_rocket/boom.rb
69
+ - lib/hash_rocket/error.rb
70
+ - lib/hash_rocket/notification.rb
70
71
  - lib/hash_rocket/object.rb
71
72
  - lib/hash_rocket/railtie.rb
72
73
  - lib/hash_rocket/version.rb
@@ -1,9 +0,0 @@
1
- class Boom < Exception
2
- def self.process_error(e, fn)
3
- puts "ERROR: -------> #{e} .......\nON THIS FILE: -----> #{fn}"
4
- end
5
-
6
- def self.unprocessable_file(fn)
7
- puts "THE FOLLOWING FILE CAN'T BE CONVERTED: -----> #{fn}"
8
- end
9
- end