ymdp 0.1.0 → 0.1.1

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 (82) hide show
  1. data/LICENSE +1 -1
  2. data/Rakefile +13 -19
  3. data/VERSION +1 -1
  4. data/lib/new_application/Gemfile +1 -0
  5. data/lib/ymdp/compiler/template_compiler.rb +19 -3
  6. data/lib/ymdp/config.rb +4 -0
  7. data/lib/ymdp/deploy/ymdt.rb +118 -0
  8. data/lib/ymdp/support/string_masker.rb +17 -0
  9. data/lib/ymdp/tasks/ymdp.rake +13 -61
  10. data/lib/ymdp/translator/base.rb +6 -3
  11. data/lib/ymdp.rb +3 -0
  12. data/spec/data/Rakefile +3 -0
  13. data/spec/data/VERSION +1 -0
  14. data/spec/data/app/.gitignore +1 -0
  15. data/spec/data/app/assets/images/lightbox/lightbox_bg.png +0 -0
  16. data/spec/data/app/assets/javascripts/OpenMailIntl.js +291 -0
  17. data/spec/data/app/assets/javascripts/controls.js +965 -0
  18. data/spec/data/app/assets/javascripts/date.js +104 -0
  19. data/spec/data/app/assets/javascripts/dragdrop.js +974 -0
  20. data/spec/data/app/assets/javascripts/effects.js +1123 -0
  21. data/spec/data/app/assets/javascripts/lowpro.js +320 -0
  22. data/spec/data/app/assets/javascripts/prototype.js +4874 -0
  23. data/spec/data/app/assets/javascripts/scriptaculous.js +68 -0
  24. data/spec/data/app/assets/yrb/en-US/application_en-US.pres +7 -0
  25. data/spec/data/app/helpers/application_helper.rb +3 -0
  26. data/spec/data/app/javascripts/application.js +580 -0
  27. data/spec/data/app/javascripts/debug.js +138 -0
  28. data/spec/data/app/javascripts/flash.js +96 -0
  29. data/spec/data/app/javascripts/header.js +13 -0
  30. data/spec/data/app/javascripts/help.js +76 -0
  31. data/spec/data/app/javascripts/i18n.js +235 -0
  32. data/spec/data/app/javascripts/launcher.js +159 -0
  33. data/spec/data/app/javascripts/logger.js +61 -0
  34. data/spec/data/app/javascripts/tag_helper.js +178 -0
  35. data/spec/data/app/stylesheets/application.css +0 -0
  36. data/spec/data/app/stylesheets/ie.css +0 -0
  37. data/spec/data/app/stylesheets/ie6.css +0 -0
  38. data/spec/data/app/stylesheets/ie7.css +0 -0
  39. data/spec/data/app/stylesheets/ie8.css +0 -0
  40. data/spec/data/app/stylesheets/lightbox.css +30 -0
  41. data/spec/data/app/stylesheets/non_ie.css +0 -0
  42. data/spec/data/app/views/layouts/application.html.haml +35 -0
  43. data/spec/data/app/views/page.html.haml +1 -0
  44. data/spec/data/app/views/shared/_error.html.haml +8 -0
  45. data/spec/data/app/views/shared/_flash.html.haml +2 -0
  46. data/spec/data/app/views/shared/_javascripts.html.haml +22 -0
  47. data/spec/data/app/views/shared/_loading.html.haml +13 -0
  48. data/spec/data/app/views/shared/_stylesheets.html.haml +23 -0
  49. data/spec/data/config/categories.yml +6 -0
  50. data/spec/data/config/config.yml +28 -0
  51. data/spec/data/config/config.yml.example +30 -0
  52. data/spec/data/config/constants.rb +54 -0
  53. data/spec/data/config/content.yml +2 -0
  54. data/spec/data/config/servers.yml +9 -0
  55. data/spec/data/config/servers.yml.example +9 -0
  56. data/spec/data/lib/init.rb +13 -0
  57. data/spec/data/lib/tasks/environment.rake +4 -0
  58. data/spec/data/lib/tasks/keys.rake +3 -0
  59. data/spec/data/lib/tasks/setup.rake +13 -0
  60. data/spec/data/lib/tasks/ymdp.rake +4 -0
  61. data/spec/data/script/build +9 -0
  62. data/spec/data/script/config +13 -0
  63. data/spec/data/script/destroy +18 -0
  64. data/spec/data/script/generate +4 -0
  65. data/spec/data/script/gitrm +17 -0
  66. data/spec/data/script/growl +6 -0
  67. data/spec/data/script/images +48 -0
  68. data/spec/data/script/jslint.js +5072 -0
  69. data/spec/data/script/langs +31 -0
  70. data/spec/data/script/translate +5 -0
  71. data/spec/data/script/ymdt +1895 -0
  72. data/spec/data/script/ymdt.old +1890 -0
  73. data/spec/data/script/yuicompressor-2.4.2.jar +0 -0
  74. data/spec/spec.opts +1 -0
  75. data/spec/spec_helper.rb +11 -0
  76. data/spec/translator_spec.rb +9 -0
  77. data/spec/ymdp_spec.rb +5 -0
  78. data/spec/ymdt_spec.rb +149 -0
  79. data/ymdp.gemspec +78 -6
  80. metadata +78 -6
  81. data/test/helper.rb +0 -10
  82. data/test/test_ymdp.rb +0 -4
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009 Jeff Coleman
1
+ Copyright (c) 2010 Capital Thought
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/Rakefile CHANGED
@@ -27,36 +27,30 @@ rescue LoadError
27
27
  puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
28
28
  end
29
29
 
30
- require 'rake/testtask'
31
- Rake::TestTask.new(:test) do |test|
32
- test.libs << 'lib' << 'test'
33
- test.pattern = 'test/**/test_*.rb'
34
- test.verbose = true
30
+
31
+ require 'spec/rake/spectask'
32
+ Spec::Rake::SpecTask.new(:spec) do |spec|
33
+ spec.libs << 'lib' << 'spec'
34
+ spec.spec_files = FileList['spec/**/*_spec.rb']
35
+ spec.spec_opts = ['-c']
35
36
  end
36
37
 
37
- begin
38
- require 'rcov/rcovtask'
39
- Rcov::RcovTask.new do |test|
40
- test.libs << 'test'
41
- test.pattern = 'test/**/test_*.rb'
42
- test.verbose = true
43
- end
44
- rescue LoadError
45
- task :rcov do
46
- abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
47
- end
38
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
39
+ spec.libs << 'lib' << 'spec'
40
+ spec.pattern = 'spec/**/*_spec.rb'
41
+ spec.rcov = true
48
42
  end
49
43
 
50
- task :test => :check_dependencies
44
+ task :spec => :check_dependencies
51
45
 
52
- task :default => :test
46
+ task :default => :spec
53
47
 
54
48
  require 'rake/rdoctask'
55
49
  Rake::RDocTask.new do |rdoc|
56
50
  version = File.exist?('VERSION') ? File.read('VERSION') : ""
57
51
 
58
52
  rdoc.rdoc_dir = 'rdoc'
59
- rdoc.title = "ymdp #{version}"
53
+ rdoc.title = "translator #{version}"
60
54
  rdoc.rdoc_files.include('README*')
61
55
  rdoc.rdoc_files.include('lib/**/*.rb')
62
56
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -8,5 +8,6 @@ gem "sishen-rtranslate"
8
8
  gem "basepath"
9
9
  gem "rake"
10
10
  gem "ymdp"
11
+ gem "timer"
11
12
 
12
13
  disable_system_gems
@@ -1,3 +1,5 @@
1
+ require 'grit'
2
+
1
3
  include Grit
2
4
 
3
5
  include YMDP::Config
@@ -33,11 +35,20 @@ module TemplateBuilder
33
35
  @hash = git_hash
34
36
  @message = message
35
37
  @subdir = subdir
36
- @version = CONFIG["version"]
37
- @sprint_name = CONFIG["sprint_name"]
38
+
39
+ set_content_variables
40
+
38
41
  @view = base_filename(@file.split("/").last)
39
42
  Application.current_view = @view
40
43
  end
44
+
45
+ def set_content_variables
46
+ content = YAML.load_file("#{BASE_PATH}/config/content.yml")
47
+ content.each do |key, value|
48
+ attribute = "@#{key}"
49
+ instance_variable_set(attribute, value) unless instance_variable_defined?(attribute)
50
+ end
51
+ end
41
52
 
42
53
  def build
43
54
  unless @file =~ /#{YMDP_ROOT}\/app\/views\/_/
@@ -108,7 +119,12 @@ end
108
119
  class YMDPTemplate
109
120
  include ActionView::Helpers::TagHelper
110
121
  include TemplateBuilder
111
- include ApplicationHelper
122
+
123
+ begin
124
+ include ApplicationHelper
125
+ rescue NameError
126
+ end
127
+
112
128
  include YMDP::Base
113
129
  include YMDP::AssetTagHelper
114
130
  include YMDP::FormTagHelper
data/lib/ymdp/config.rb CHANGED
@@ -61,5 +61,9 @@ module YMDP
61
61
  def verbose?
62
62
  config("verbose")
63
63
  end
64
+
65
+ def growl?
66
+ config("growl")
67
+ end
64
68
  end
65
69
  end
@@ -0,0 +1,118 @@
1
+ module YMDT
2
+ class System
3
+ def self.execute(command, params={})
4
+ if params[:return]
5
+ `#{command}`
6
+ else
7
+ system command
8
+ end
9
+ end
10
+ end
11
+
12
+ class Base
13
+ attr_accessor :username, :password, :script_path
14
+
15
+ def initialize(params={})
16
+ @username = params[:username]
17
+ @password = params[:password]
18
+ unless @username
19
+ raise ArgumentError.new("username required")
20
+ end
21
+ unless @password
22
+ raise ArgumentError.new("password required")
23
+ end
24
+ @script_path = params[:script_path] || "./script/ymdt"
25
+ end
26
+
27
+ def put(params={})
28
+ invoke(:put, params)
29
+ end
30
+
31
+ def get(params={})
32
+ invoke(:get, params)
33
+ end
34
+
35
+ def create(params={})
36
+ raise ArgumentError.new("application_id required") unless params[:application_id]
37
+ invoke(:get, params)
38
+ end
39
+
40
+ def ls(params={})
41
+ invoke(:ls, {:return => true}.merge(params))
42
+ end
43
+
44
+ def upgrade(params={})
45
+ invoke(:upgrade, params)
46
+ end
47
+
48
+ # prepares the commands to correctly reference the application and path
49
+ #
50
+ def invoke(command, params={})
51
+ command_string = compile_command(command, params)
52
+ output_command(command_string)
53
+ execute(command_string, params)
54
+ end
55
+
56
+ private
57
+
58
+ def output_command(command_string)
59
+ $stdout.puts
60
+ $stdout.puts StringMasker.new(command_string, :username => username, :password => password).to_s
61
+ end
62
+
63
+ def compile_command(command, params)
64
+ full_path = nil
65
+
66
+ # construct relative path to the application's location in the servers directory
67
+ #
68
+ if params[:application]
69
+ full_path = "#{SERVERS_PATH}/" << params[:application]
70
+ full_path = full_path << "/" << params[:path] if params[:path]
71
+ end
72
+
73
+ # construct command line
74
+ #
75
+ options = []
76
+
77
+ # execute script
78
+ #
79
+ options << script_path
80
+
81
+ # command (:put, :get, etc)
82
+ #
83
+ options << command
84
+
85
+ # path
86
+ #
87
+ options << "\"#{full_path}\"" if full_path
88
+
89
+ # optional sync flag MUST BE PLACED HERE
90
+ #
91
+ options << "-s" if params[:sync]
92
+
93
+ # optional application ID flag
94
+ #
95
+ options << "-a#{params[:application_id]}" if params[:application_id]
96
+
97
+ # username and password
98
+
99
+ options << "-u#{username}"
100
+ options << "-p#{password}"
101
+
102
+ options.join(" ")
103
+ end
104
+
105
+ # execute the command, or not, and return the results, or not
106
+ #
107
+ def execute(command, params={})
108
+ unless params[:dry_run]
109
+ if params[:return]
110
+ System.execute(command, :return => true)
111
+ else
112
+ $stdout.puts
113
+ System.execute(command)
114
+ end
115
+ end
116
+ end
117
+ end
118
+ end
@@ -0,0 +1,17 @@
1
+ class StringMasker
2
+ attr_accessor :string, :params, :output_string
3
+
4
+ def initialize(string, params)
5
+ output_string = string.dup
6
+
7
+ params.each do |key, value|
8
+ output_string.gsub!(value, "[#{key}]")
9
+ end
10
+
11
+ @output_string = output_string
12
+ end
13
+
14
+ def to_s
15
+ output_string
16
+ end
17
+ end
@@ -1,3 +1,5 @@
1
+ require 'deploy/ymdt'
2
+
1
3
  include YMDP::Config
2
4
 
3
5
  begin
@@ -157,12 +159,6 @@ DOCS
157
159
  puts docs
158
160
  end
159
161
 
160
- def time(message="")
161
- Timer.new(:title => "YMDP").time(message) do
162
- yield
163
- end
164
- end
165
-
166
162
  desc "Deploys application to YMDP servers"
167
163
  task :deploy do
168
164
  time("Deployed #{@application}: #{@path}") do
@@ -478,46 +474,17 @@ end
478
474
 
479
475
  # END OF RAKE TASKS
480
476
 
481
- def invoke_ymdt(command_string, application, path="", return_results=false)
482
- dir = "./servers/" << application
483
- path = dir << "/" << path
484
-
485
- command = []
486
- command << command_string
487
- command << "\"#{path}\""
488
- command << "-s" if @sync
489
-
490
- ymdt_command(command, return_results)
477
+ def time(message="")
478
+ Timer.new(:title => "YMDP", :growl => growl?).time(message) do
479
+ yield
480
+ end
491
481
  end
492
482
 
493
- def ymdt_command(commands, return_results=false)
494
- command = []
495
- # command << "php"
496
- command << "./script/ymdt"
497
-
498
- command << commands
499
-
500
- command << "-u#{@username}"
501
- command << "-p#{@password}"
502
- command_string = command.join(" ")
503
-
504
- display_string = command_string.dup
505
- display_string.gsub!(@username, "[username]")
506
- display_string.gsub!(@password, "[password]")
507
-
508
- puts
509
- puts display_string
510
-
511
- unless @dry_run
512
- if return_results
513
- `#{command_string}`
514
- else
515
- puts
516
- system command_string
517
- end
518
- end
483
+ def ymdt
484
+ @ymdt ||= YMDT::Base.new(:username => @username, :password => @password)
519
485
  end
520
486
 
487
+
521
488
  def validated_embedded_js(path)
522
489
  # jslint only accepts files, later we can hack it to accept stdin pipes
523
490
  doc = open(path) { |f|
@@ -542,7 +509,7 @@ def deploy(application, path)
542
509
  Rake::Task["validate:#{application}:javascripts"].invoke if validate_js_assets?
543
510
  Rake::Task["validate:#{application}:json"].invoke if validate_json_assets?
544
511
 
545
- invoke_ymdt("put", application, path)
512
+ ymdt.put(:application => application, :path => path)
546
513
  end
547
514
 
548
515
  def deploy_path(application, path)
@@ -568,7 +535,7 @@ def deploy_path(application, path)
568
535
 
569
536
  if file =~ Regexp.new(path)
570
537
  puts file
571
- invoke_ymdt("put", application, new_path)
538
+ ymdt.put(:application => application, :path => new_path)
572
539
  end
573
540
  end
574
541
  end
@@ -587,7 +554,7 @@ def deploy_yrb(application, path, options={})
587
554
  end
588
555
 
589
556
  def list(application, path)
590
- invoke_ymdt("ls", application, path, true)
557
+ ymdt.ls(:application => application, :path => path, :return_results => true)
591
558
  end
592
559
 
593
560
  def check_asset_ids(application, path)
@@ -687,22 +654,7 @@ def create_directory_from_application(application, path="")
687
654
  time("Done creating #{application}: #{path}") do
688
655
  puts "Creating #{application}: #{path}"
689
656
  application_id = SERVERS[application]["application_id"]
690
-
691
- dir = "./servers/#{application}"
692
-
693
- if path == ""
694
- path = dir
695
- else
696
- path = "./" << path
697
- end
698
-
699
- command = []
700
-
701
- command << "get"
702
- command << path
703
- command << "-a#{application_id}"
704
-
705
- ymdt_command(command)
657
+ ymdt.get(:application => application, :path => path, :application_id => application_id)
706
658
  end
707
659
  end
708
660
 
@@ -91,9 +91,6 @@ module YMDP
91
91
  # Finds English language translation keys which have not been translated
92
92
  # and translates them through Google Translate.
93
93
  #
94
- # Usage:
95
- # YMDP::Translator::Base.new().translate
96
- #
97
94
  class Base
98
95
  include YMDP::FileSupport
99
96
  extend YMDP::FileSupport
@@ -303,6 +300,9 @@ module YMDP
303
300
  end
304
301
  end
305
302
 
303
+ # Usage:
304
+ # YMDP::Translator::Yaml.new().translate
305
+ #
306
306
  class Yaml < Base
307
307
  include YMDP::Yaml::Support
308
308
  extend YMDP::Yaml::Support
@@ -340,6 +340,9 @@ module YMDP
340
340
  end
341
341
  end
342
342
 
343
+ # Usage:
344
+ # YMDP::Translator::YRB.new().translate
345
+ #
343
346
  class YRB < Base
344
347
  include YMDP::YRB::Support
345
348
  extend YMDP::YRB::Support
data/lib/ymdp.rb CHANGED
@@ -7,6 +7,9 @@ $LOAD_PATH.unshift dir unless $LOAD_PATH.include?(dir)
7
7
  # load application
8
8
  #
9
9
 
10
+ require 'erb'
11
+ require 'set'
12
+
10
13
  require File.expand_path("#{dir}/tag_helper")
11
14
  require File.expand_path("#{dir}/asset_tag_helper")
12
15
 
@@ -0,0 +1,3 @@
1
+ Dir["./lib/tasks/*.rake"].each do |file|
2
+ load file
3
+ end
data/spec/data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 6.0.0 Felucia
@@ -0,0 +1 @@
1
+ assets.zip