ymdp 0.1.9 → 0.1.10

Sign up to get free protection for your applications and to get access to all the features.
data/.base ADDED
@@ -0,0 +1,5 @@
1
+ [load_paths]
2
+
3
+ [requires]
4
+
5
+ [consts]
data/.gitignore CHANGED
@@ -19,3 +19,7 @@ rdoc
19
19
  pkg
20
20
 
21
21
  ## PROJECT::SPECIFIC
22
+
23
+ vendor/bin/*
24
+ vendor/gems/*
25
+ !vendor/gems/cache/
data/Gemfile CHANGED
@@ -3,11 +3,15 @@ gem "haml"
3
3
  gem "json"
4
4
  gem "hpricot"
5
5
  gem "ruby-growl"
6
- gem "activesupport"
6
+ gem "activesupport", :require_as => "active_support"
7
7
  gem "sishen-rtranslate"
8
8
  gem "progressions-basepath", :require_as => "basepath"
9
- gem "progessions-g", :require_as => "g"
9
+ gem "progressions-g", :require_as => "g"
10
10
  gem "timer"
11
11
  gem "serenity"
12
12
  gem "ymdp_generator"
13
13
  gem "ymdt"
14
+ gem "yrb"
15
+ gem "idiom"
16
+
17
+ bin_path "vendor/bin"
@@ -1,3 +1,14 @@
1
+ == in Git
2
+
3
+
4
+ == 0.1.10 2010-01-22
5
+ * minor enhancements
6
+ * use YRB gem to parse .pres files
7
+
8
+ == 0.1.9 2010-01-22
9
+ * major enhancements
10
+ * extract translation into new gem, Idiom
11
+
1
12
  == 0.1.8.1 2010-01-20
2
13
  * bug fixes
3
14
  * fix typo in constants.rb
data/Rakefile CHANGED
@@ -24,6 +24,7 @@ begin
24
24
  gem.add_runtime_dependency "serenity", ">= 0"
25
25
  gem.add_runtime_dependency "ymdp_generator", ">= 0"
26
26
  gem.add_runtime_dependency "ymdt", ">= 0"
27
+ gem.add_runtime_dependency "yrb", ">= 0"
27
28
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
28
29
  end
29
30
  Jeweler::GemcutterTasks.new
@@ -46,7 +47,12 @@ Spec::Rake::SpecTask.new(:rcov) do |spec|
46
47
  spec.rcov = true
47
48
  end
48
49
 
49
- task :spec => :check_dependencies
50
+ task :bundle do
51
+ require 'vendor/gems/environment'
52
+ Bundler.require_env
53
+ end
54
+
55
+ task :spec => [:bundle, :check_dependencies]
50
56
 
51
57
  task :default => :spec
52
58
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.8.1
1
+ 0.1.10
@@ -130,7 +130,7 @@ module YMDP
130
130
  end
131
131
  )
132
132
  end
133
- end
133
+ end
134
134
  end
135
135
  end
136
136
 
@@ -1,10 +1,10 @@
1
- require 'translator/base'
2
-
3
1
  if ARGV[0] == "view"
4
2
  p = {
5
3
  :template_path => File.join(File.dirname(__FILE__), "..", "generator", "templates"),
6
4
  :application_path => APPLICATION_PATH
7
5
  }
8
6
  YMDP::Generator::Base.new(p).generate(ARGV[1])
9
- YMDP::Translator::YRB.translate
7
+ Dir["#{BASE_PATH}/app/assets/yrb/en-US/new_#{ARGV[1]}_en-US.pres"].each do |path|
8
+ Idiom::Base.translate(:source => path)
9
+ end
10
10
  end
@@ -1,3 +1,5 @@
1
+ require 'yrb'
2
+
1
3
  module YMDP
2
4
  module Compiler #:nodoc:
3
5
  module Template #:nodoc:
@@ -294,7 +296,7 @@ module YMDP
294
296
  # Convert them to a hash and write the hash to a JSON file.
295
297
  #
296
298
  # Each language can have as many YRB translation files (with an extension of ".pres")
297
- # as necessary. The files are concatenated together and translated into a single JSON file
299
+ # as necessary. The files are concatenated together and converted into a single JSON file
298
300
  # for each language.
299
301
  #
300
302
  class YRB < Base
@@ -322,7 +324,13 @@ module YMDP
322
324
  # Turn it back into a hash.
323
325
  #
324
326
  def to_hash
325
- JSON.parse(to_json)
327
+ yrb
328
+ end
329
+
330
+ # Parse YRB file
331
+ #
332
+ def yrb
333
+ ::YRB.load_file(@file)
326
334
  end
327
335
 
328
336
  # Convert the hash to Yaml if you should want to do that.
@@ -340,7 +348,7 @@ module YMDP
340
348
  # case, the JSON file.
341
349
  #
342
350
  def processed_template
343
- super.to_json
351
+ yrb.to_json
344
352
  end
345
353
 
346
354
  # Validate the JSON file.
@@ -362,49 +370,6 @@ module YMDP
362
370
  def convert_filename(filename)
363
371
  "#{base_filename(filename)}.json"
364
372
  end
365
-
366
- # Is this line a valid comment in YRB?
367
- def comment?(line)
368
- line =~ /^[\s]*#/
369
- end
370
-
371
- # Is this line valid YRB syntax?
372
- #
373
- def key_and_value_from_line(line)
374
- if line =~ /^([^\=]+)=(.+)/
375
- return $1, $2.strip
376
- else
377
- return nil, nil
378
- end
379
- end
380
-
381
- # Parse YRB and add it to a hash. Raise an error if the key already exists in the hash.
382
- #
383
- def process_template(template)
384
- @hash = {}
385
- lines = template.split("\n")
386
- lines.each do |line|
387
- unless comment?(line)
388
- key, value = key_and_value_from_line(line)
389
- unless key.blank?
390
- if @hash.has_key?(key)
391
- $stdout.puts
392
- $stdout.puts "Duplicate value in #{destination_path}"
393
- $stdout.puts " #{key}=#{@hash[key]}"
394
- $stdout.puts " #{key}=#{value}"
395
- $stdout.puts
396
- if @hash[key] == value
397
- $stdout.puts " Values are the same but duplicate values still should not exist!"
398
- $stdout.puts
399
- end
400
- raise "Duplicate key error"
401
- end
402
- @hash[key] = value
403
- end
404
- end
405
- end
406
- @hash
407
- end
408
373
 
409
374
  # Write JSON file to its destination.
410
375
  #
@@ -1,7 +1,5 @@
1
1
  require 'lib/init'
2
2
 
3
- require 'translator/base'
4
-
5
3
  @key = ENV["key"] || ""
6
4
  @key = @key.upcase
7
5
 
@@ -77,7 +75,9 @@ namespace :keys do
77
75
 
78
76
  desc "Translate any new keys into non-US languages"
79
77
  task :translate do
80
- YMDP::Translator::YRB.translate
78
+ Dir["#{BASE_PATH}/app/assets/yrb/en-US/*.pres"].each do |path|
79
+ Idiom::Base.translate(:source => path)
80
+ end
81
81
  end
82
82
 
83
83
  task :rename do
@@ -63,7 +63,7 @@ describe "Template" do
63
63
  File.stub!(:read).with("filename.pres").and_return("KEY=value\nKEY=value\n")
64
64
  lambda {
65
65
  @js_template.build
66
- }.should raise_error("Duplicate key error")
66
+ }.should raise_error(/Duplicate key error/)
67
67
  end
68
68
 
69
69
  describe "methods" do
@@ -1,6 +1,7 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__))
2
2
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
3
 
4
+
4
5
  BASE_PATH = File.dirname(__FILE__) + "/data"
5
6
  CONFIG_PATH = "#{BASE_PATH}/config"
6
7
  SERVERS_PATH = "#{BASE_PATH}/servers"
@@ -13,6 +14,8 @@ require 'g'
13
14
  require 'active_support'
14
15
  require 'spec'
15
16
  require 'spec/autorun'
17
+ require 'yrb'
18
+ require 'timer'
16
19
 
17
20
  require 'stubs'
18
21
  require 'default_settings'
@@ -3,6 +3,7 @@ def stub_io
3
3
  stub_file_io
4
4
  stub_file_utils
5
5
  stub_yaml
6
+ stub_yrb
6
7
  stub_growl
7
8
  end
8
9
 
@@ -40,6 +41,10 @@ def stub_yaml(output_hash={})
40
41
  YAML.stub!(:load_file).and_return(output_hash)
41
42
  end
42
43
 
44
+ def stub_yrb(output_hash={})
45
+ YRB.stub!(:load_file).and_return(output_hash)
46
+ end
47
+
43
48
  def stub_erb(processed_file="")
44
49
  @erb ||= mock('erb').as_null_object
45
50
  @erb.stub!(:result).and_return(processed_file)
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ymdp}
8
- s.version = "0.1.9"
8
+ s.version = "0.1.10"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jeff Coleman"]
@@ -17,7 +17,8 @@ Gem::Specification.new do |s|
17
17
  "README.rdoc"
18
18
  ]
19
19
  s.files = [
20
- ".document",
20
+ ".base",
21
+ ".document",
21
22
  ".gitignore",
22
23
  "Gemfile",
23
24
  "History.txt",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ymdp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Coleman
@@ -172,6 +172,7 @@ extra_rdoc_files:
172
172
  - LICENSE
173
173
  - README.rdoc
174
174
  files:
175
+ - .base
175
176
  - .document
176
177
  - .gitignore
177
178
  - Gemfile