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 CHANGED
@@ -194,6 +194,14 @@ module Jeanny
194
194
  @keys.map { |x| [x, @values[@keys.index(x)]] }
195
195
  end
196
196
 
197
+ def to_yaml
198
+ yaml = []
199
+ each do |key, val|
200
+ yaml.push({ key => val })
201
+ end
202
+ yaml.to_yaml
203
+ end
204
+
197
205
  end
198
206
 
199
207
  class Code
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
- meat = File.open File.expand_path(@compare_file)
57
- meat.read.gsub(/\s+|\'/, '').gsub(/^.*\{|\}.*$/, '').split(',').each do |item|
58
- item = item.split('=>').delete_if { |x| x.nil? or x.empty? }
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: "0.99"
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-02-02 00:00:00 +02:00
12
+ date: 2010-03-01 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies: []
15
15