norminette 1.0.0.rc1.pre.0 → 1.0.0.rc2.pre.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/norminette +44 -49
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e1d367fb0aefd758e19a5b1f1fb73f8575c5c8a4
4
- data.tar.gz: d087f039fe301c03bcd21f66172d4e3e6a3b1242
3
+ metadata.gz: 1333bc4fa361ac722efa09d9a9c7549436ecc113
4
+ data.tar.gz: 9a0e3cfd461b3345e785cdd2ee86af26b094eafd
5
5
  SHA512:
6
- metadata.gz: 0bc69ce67ee61586fe35acb1f9a1e27fbae5ad2f20846272f98cb7f005159f88d16d1fd3ee86512ef57c0e45c550a7c275e6755be0b97eaec13e466fe1b97b1a
7
- data.tar.gz: 304e8bc6049e2aad4dfb76a590b0a048a97d283e2973526e86ac541492ae169c1ee482623ed0ad8d003db72f5a69ba4127cdee40034ddbdc1c867d3485285583
6
+ metadata.gz: daff01e41d247f8db7302fa37f89acda7dbaa5eca30fce84fedb0b558e97ef733f042b7123d8a9a6d754b5e425a433514f539107cd9903a9313164740167b9db
7
+ data.tar.gz: a5216396fc9acee103c7671fab2ef237200b41bc2f6591685dfb3c2efba26c322632393f2c113e0b9ade08fdd23d95a001d90f345f21d639646bdde788b3800d
@@ -5,14 +5,6 @@ require 'optparse'
5
5
 
6
6
  $current_path = Dir.pwd
7
7
 
8
- if File.symlink?(__FILE__)
9
- dir = File.expand_path(File.dirname(File.expand_path(__FILE__)) + "/" + File.dirname(File.readlink(__FILE__)))
10
- Dir.chdir dir
11
- else
12
- dir = File.expand_path(File.dirname(__FILE__))
13
- Dir.chdir dir
14
- end
15
-
16
8
  Bundler.require
17
9
  require 'bunny'
18
10
  require 'facter'
@@ -24,7 +16,7 @@ class Sender
24
16
  vhost: "/",
25
17
  user: "guest",
26
18
  password: "guest"
27
-
19
+
28
20
  @conn.start
29
21
  @ch = @conn.create_channel
30
22
  @x = @ch.default_exchange
@@ -37,10 +29,10 @@ class Sender
37
29
  @reply_queue.subscribe do |delivery_info, properties, payload|
38
30
  @counter -= 1
39
31
  block.call delivery_info, properties, payload
40
- @lock.synchronize { @condition.signal }
41
- end
32
+ @lock.synchronize { @condition.signal }
33
+ end
42
34
 
43
- at_exit { desinitialize }
35
+ at_exit { desinitialize }
44
36
  end
45
37
 
46
38
  def desinitialize
@@ -50,8 +42,9 @@ class Sender
50
42
 
51
43
  def publish content
52
44
  @counter += 1
53
- @x.publish content, routing_key: @routing_key,
54
- reply_to: @reply_queue.name
45
+ @x.publish content, routing_key: @routing_key,
46
+ reply_to: @reply_queue.name,
47
+ correlation_id: SecureRandom.uuid
55
48
  end
56
49
 
57
50
  def sync_if_needed max = Facter.value('processors')['count']
@@ -68,8 +61,8 @@ end
68
61
  class Norminette
69
62
  def initialize
70
63
  @files = []
71
- @sender = Sender.new do |delivery_info, properties, payload|
72
- manage_result JSON.parse(payload)
64
+ @sender = Sender.new do |delivery_info, properties, payload|
65
+ manage_result JSON.parse(payload)
73
66
  end
74
67
  end
75
68
 
@@ -99,7 +92,7 @@ class Norminette
99
92
  end
100
93
 
101
94
  def version
102
- puts "Local version:\n1.0.0.rc1"
95
+ puts "Local version:\n1.0.0.rc2"
103
96
  puts "Norminette version:"
104
97
  send_content({action: "version"}.to_json)
105
98
  end
@@ -113,7 +106,6 @@ class Norminette
113
106
  end
114
107
 
115
108
  def populate_file file
116
- file = (Pathname.new(file).absolute? ? file : File.join($current_path, file))
117
109
  unless is_a_valid_file? file
118
110
  manage_result 'filename' => file, 'display' => "Warning: Not a valid file"
119
111
  return
@@ -137,44 +129,47 @@ class Norminette
137
129
  @sender.publish content
138
130
  end
139
131
 
140
- def manage_result result
141
- puts "Norme: #{result['filename']}" if result['filename']
142
- puts result['display'] if result['display']
143
- exit 0 if result['stop'] == true
132
+ def cleanify_path filename
133
+ File.expand_path(filename).gsub(/^#$current_path\/?/, "./")
134
+ end
135
+
136
+ def manage_result result
137
+ puts "Norme: #{cleanify_path(result['filename'])}" if result['filename']
138
+ puts result['display'] if result['display']
139
+ exit 0 if result['stop'] == true
144
140
  end
145
141
  end
146
142
 
147
143
  class Parser
148
- def self.parse(options)
149
- args = OpenStruct.new
150
- opt_parser = OptionParser.new do |opts|
151
- opts.banner = "Usage: #$0 [options] [files_or_directories]"
152
-
153
- opts.on("-v", "--version", "Print version") do |n|
154
- args.version = true
155
- end
156
-
157
- opts.on("-R", "--rules Array", Array, "Rule to disable") do |rules|
158
- args.rules = rules
159
- end
160
-
161
- opts.on("-h", "--help", "Prints this help") do
162
- sender = Sender.new do |delivery_info, properties, payload|
163
- puts JSON.parse(payload)['display']
164
- end
144
+ def self.parse(options)
145
+ args = OpenStruct.new
146
+ opt_parser = OptionParser.new do |opts|
147
+ opts.banner = "Usage: #$0 [options] [files_or_directories]"
165
148
 
166
- puts opts
167
- puts "Norminette usage:"
168
- sender.publish({action: "help"}.to_json)
169
- sender.sync
170
- exit
171
- end
172
- end
149
+ opts.on("-v", "--version", "Print version") do |n|
150
+ args.version = true
151
+ end
152
+
153
+ opts.on("-R", "--rules Array", Array, "Rule to disable") do |rules|
154
+ args.rules = rules
155
+ end
173
156
 
174
- opt_parser.parse!(options) rescue abort $!.to_s
157
+ opts.on("-h", "--help", "Prints this help") do
158
+ sender = Sender.new do |delivery_info, properties, payload|
159
+ puts JSON.parse(payload)['display']
160
+ end
175
161
 
176
- return args
177
- end
162
+ puts opts
163
+ puts "Norminette usage:"
164
+ sender.publish({action: "help"}.to_json)
165
+ sender.sync
166
+ exit
167
+ end
168
+ end
169
+ opt_parser.parse!(options) rescue abort $!.to_s
170
+
171
+ return args
172
+ end
178
173
  end
179
174
 
180
175
  Norminette.new.check ARGV, Parser.parse(ARGV)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: norminette
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.rc1.pre.0
4
+ version: 1.0.0.rc2.pre.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bocal 42
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-09 00:00:00.000000000 Z
11
+ date: 2015-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bunny