jeanny 0.99 → 0.99.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/jeanny/engine.rb +8 -0
- data/lib/jeanny/sugar.rb +9 -52
- metadata +2 -2
data/lib/jeanny/engine.rb
CHANGED
data/lib/jeanny/sugar.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'singleton'
|
2
|
+
require 'yaml'
|
2
3
|
|
3
4
|
module Jeanny
|
4
5
|
|
@@ -53,45 +54,16 @@ module Jeanny
|
|
53
54
|
saved_classes = []
|
54
55
|
|
55
56
|
begin
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
if item.length.eql? 2
|
60
|
-
saved_classes << [item[0], item[1]]
|
61
|
-
else
|
62
|
-
fail JeannyCompareFileFormatError, "Какая то ерунда с одим (а может больше) классом. Можно пропустить, но хрен его знает что дальше будет…\n" + "файл: #{file}, строка: #{index}\n#{raw_data[index]}".red
|
63
|
-
end
|
57
|
+
saved_classes = YAML.load_file @compare_file
|
58
|
+
saved_classes.map! do |x|
|
59
|
+
x.to_a.flatten
|
64
60
|
end
|
65
|
-
|
66
|
-
# p saved_classes
|
67
|
-
|
61
|
+
p saved_classes
|
68
62
|
rescue Exception => e
|
69
63
|
$stderr.puts e.message
|
70
64
|
exit 1
|
71
65
|
end
|
72
66
|
|
73
|
-
# begin
|
74
|
-
# # Открываем файл
|
75
|
-
# raw_file = File.open_file @compare_file
|
76
|
-
# raw_data = raw_file.split "\n"
|
77
|
-
#
|
78
|
-
# # ... и читаем структиуру
|
79
|
-
# raw_data.map do |line|
|
80
|
-
# line.split(':').map do |hash|
|
81
|
-
# hash.strip
|
82
|
-
# end
|
83
|
-
# end.each_with_index do |item, index|
|
84
|
-
# if item.length != 2 or item[1].empty?
|
85
|
-
# fail JeannyCompareFileFormatError, "Какая то ерунда с одим (а может больше) классом. Можно пропустить, но хрен его знает что дальше будет…\n" + "файл: #{file}, строка: #{index}\n#{raw_data[index]}".red
|
86
|
-
# else
|
87
|
-
# saved_classes << [item[0], item[1]]
|
88
|
-
# end
|
89
|
-
# end
|
90
|
-
# rescue Exception => e
|
91
|
-
# $stderr.puts e.message
|
92
|
-
# exit 1
|
93
|
-
# end
|
94
|
-
|
95
67
|
# Сравниваем
|
96
68
|
new_classes = @engine.compare_with saved_classes
|
97
69
|
|
@@ -108,27 +80,12 @@ module Jeanny
|
|
108
80
|
|
109
81
|
def save file = ''
|
110
82
|
|
111
|
-
fail RuntimeError, 'на данном этапе нельзя вызывать сохранение классов' unless canbe[:save]
|
83
|
+
fail RuntimeError, 'на данном этапе нельзя вызывать сохранение классов' unless @canbe[:save]
|
112
84
|
|
113
85
|
file = file.empty? ? @compare_file : file
|
114
|
-
temp = <<CODE
|
115
|
-
[%
|
116
|
-
classes =
|
117
|
-
{
|
118
|
-
%classes%
|
119
|
-
}
|
120
|
-
%]
|
121
|
-
CODE
|
122
|
-
|
123
|
-
File.open(File.expand_path(file), 'w') do |f|
|
124
|
-
|
125
|
-
classes = []
|
126
|
-
@engine.classes.each do |key, val|
|
127
|
-
classes << " " * 20 + "'#{key}'" + " => '#{val}'".rjust(50 - key.length)
|
128
|
-
end
|
129
|
-
|
130
|
-
f.puts temp.gsub /%classes%/, classes.join(",\n")
|
131
86
|
|
87
|
+
open(file, 'w') do |f|
|
88
|
+
f.puts @engine.classes.to_yaml
|
132
89
|
end unless file.nil? or file.empty?
|
133
90
|
|
134
91
|
end
|
@@ -263,4 +220,4 @@ CODE
|
|
263
220
|
|
264
221
|
end
|
265
222
|
|
266
|
-
end
|
223
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jeanny
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.99.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- gfranco
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-
|
12
|
+
date: 2010-03-01 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|