ymdp_generator 0.0.1 → 0.0.3
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.
- data/History.txt +3 -0
- data/LICENSE +1 -1
- data/README.rdoc +31 -2
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/lib/view.rb +20 -3
- data/lib/ymdp_generator.rb +3 -0
- data/spec/spec_helper.rb +24 -0
- data/spec/ymdp_generator_spec.rb +1 -19
- data/ymdp_generator.gemspec +6 -3
- metadata +13 -3
- data/lib/support/file.rb +0 -54
data/History.txt
ADDED
data/LICENSE
CHANGED
data/README.rdoc
CHANGED
@@ -1,6 +1,35 @@
|
|
1
1
|
= ymdp_generator
|
2
2
|
|
3
|
-
|
3
|
+
Generates a new view, with all the associated files relating to that view.
|
4
|
+
|
5
|
+
Creates the following files:
|
6
|
+
|
7
|
+
1. View, at "#{BASE_PATH}/app/assets/views/_view_.html.haml"
|
8
|
+
|
9
|
+
A Haml file with a single line of boilerplate copy.
|
10
|
+
|
11
|
+
2. JavaScript file, at "#{BASE_PATH}/app/javascripts/_view_.js"
|
12
|
+
|
13
|
+
A complete set of the basic JavaScript functions needed to execute a page.
|
14
|
+
|
15
|
+
3. Stylesheet, at "#{BASE_PATH}/app/stylesheets/_view_.css"
|
16
|
+
|
17
|
+
A blank CSS file.
|
18
|
+
|
19
|
+
4. Translation keys, at "#{BASE_PATH}/app/assets/yrb/en-US/new_view_en-US.pres"
|
20
|
+
|
21
|
+
A new translation file, with a heading and a subhead key.
|
22
|
+
|
23
|
+
5. Modification
|
24
|
+
|
25
|
+
Currently the only modification to any existing files is the creation of a 'launcher' method
|
26
|
+
in "#{BASE_PATH}/app/javascripts/launcher.js"
|
27
|
+
|
28
|
+
6. Translation of new keys into all languages.
|
29
|
+
|
30
|
+
Translates the new keys into all languages and creates associated ".pres" files in the
|
31
|
+
correct subdirectories.
|
32
|
+
|
4
33
|
|
5
34
|
== Note on Patches/Pull Requests
|
6
35
|
|
@@ -14,4 +43,4 @@ Description goes here.
|
|
14
43
|
|
15
44
|
== Copyright
|
16
45
|
|
17
|
-
Copyright (c) 2010
|
46
|
+
Copyright (c) 2010 Capital Thought. See LICENSE for details.
|
data/Rakefile
CHANGED
@@ -11,6 +11,7 @@ begin
|
|
11
11
|
gem.homepage = "http://github.com/progressions/ymdp_generator"
|
12
12
|
gem.authors = ["Jeff Coleman"]
|
13
13
|
gem.add_development_dependency "rspec", ">= 1.2.6"
|
14
|
+
gem.add_runtime_dependency "f", ">= 0"
|
14
15
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
15
16
|
end
|
16
17
|
Jeweler::GemcutterTasks.new
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
data/lib/view.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
require '
|
1
|
+
require 'rubygems'
|
2
|
+
require 'f'
|
2
3
|
require 'erb'
|
3
4
|
|
4
5
|
# Generates new files for a new view.
|
@@ -28,8 +29,6 @@ OUTPUT
|
|
28
29
|
# Basic processing of templates (ERB by default).
|
29
30
|
#
|
30
31
|
class Base
|
31
|
-
include YMDP::FileSupport
|
32
|
-
|
33
32
|
attr_accessor :view, :template_path, :application_path
|
34
33
|
|
35
34
|
# View name should be a single word that's valid as a filename.
|
@@ -126,6 +125,24 @@ OUTPUT
|
|
126
125
|
def destination_dir
|
127
126
|
raise "Define in child"
|
128
127
|
end
|
128
|
+
|
129
|
+
# friendlier display of paths
|
130
|
+
def display_path(path)
|
131
|
+
path = File.expand_path(path)
|
132
|
+
path.gsub(BASE_PATH, "")
|
133
|
+
end
|
134
|
+
|
135
|
+
def confirm_overwrite(path)
|
136
|
+
if File.exists?(path)
|
137
|
+
$stdout.puts "File exists: #{File.expand_path(path)}"
|
138
|
+
$stdout.print " overwrite? (y/n)"
|
139
|
+
answer = $stdin.gets
|
140
|
+
|
141
|
+
answer =~ /^y/i
|
142
|
+
else
|
143
|
+
true
|
144
|
+
end
|
145
|
+
end
|
129
146
|
end
|
130
147
|
|
131
148
|
# A View is an HTML file, located at "#{BASE_PATH}/app/views/_view_.html.haml".
|
data/lib/ymdp_generator.rb
CHANGED
@@ -40,6 +40,9 @@ module YMDP
|
|
40
40
|
def initialize(params={})
|
41
41
|
@template_path = params[:template_path]
|
42
42
|
@application_path = params[:application_path]
|
43
|
+
|
44
|
+
raise ArgumentError.new("template_path is required") unless @template_path
|
45
|
+
raise ArgumentError.new("application_path is required") unless @application_path
|
43
46
|
end
|
44
47
|
|
45
48
|
def generate(view)
|
data/spec/spec_helper.rb
CHANGED
@@ -10,3 +10,27 @@ require 'spec/autorun'
|
|
10
10
|
Spec::Runner.configure do |config|
|
11
11
|
|
12
12
|
end
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
def stub_screen_io
|
17
|
+
# stub screen I/O
|
18
|
+
$stdout.stub!(:puts)
|
19
|
+
$stdout.stub!(:print)
|
20
|
+
end
|
21
|
+
|
22
|
+
def stub_file_io(unprocessed_file)
|
23
|
+
# stub file I/O
|
24
|
+
@file ||= mock('file').as_null_object
|
25
|
+
@file.stub!(:read).and_return(unprocessed_file)
|
26
|
+
|
27
|
+
File.stub!(:exists?).and_return(false)
|
28
|
+
File.stub!(:open).and_yield(@file)
|
29
|
+
end
|
30
|
+
|
31
|
+
def stub_erb(processed_file)
|
32
|
+
# stub ERB
|
33
|
+
@erb ||= mock('erb').as_null_object
|
34
|
+
@erb.stub!(:result).and_return(processed_file)
|
35
|
+
ERB.stub!(:new).and_return(@erb)
|
36
|
+
end
|
data/spec/ymdp_generator_spec.rb
CHANGED
@@ -2,9 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
2
2
|
|
3
3
|
describe "Generate" do
|
4
4
|
before(:each) do
|
5
|
-
|
6
|
-
$stdout.stub!(:puts)
|
7
|
-
$stdout.stub!(:print)
|
5
|
+
stub_screen_io
|
8
6
|
|
9
7
|
@template_path = "templates"
|
10
8
|
@application_path = "app"
|
@@ -66,22 +64,6 @@ describe "Generate" do
|
|
66
64
|
end
|
67
65
|
end
|
68
66
|
|
69
|
-
def stub_file_io(unprocessed_file)
|
70
|
-
# stub file I/O
|
71
|
-
@file ||= mock('file').as_null_object
|
72
|
-
@file.stub!(:read).and_return(unprocessed_file)
|
73
|
-
|
74
|
-
File.stub!(:exists?).and_return(false)
|
75
|
-
File.stub!(:open).and_yield(@file)
|
76
|
-
end
|
77
|
-
|
78
|
-
def stub_erb(processed_file)
|
79
|
-
# stub ERB
|
80
|
-
@erb ||= mock('erb').as_null_object
|
81
|
-
@erb.stub!(:result).and_return(processed_file)
|
82
|
-
ERB.stub!(:new).and_return(@erb)
|
83
|
-
end
|
84
|
-
|
85
67
|
describe "subclasses" do
|
86
68
|
before(:each) do
|
87
69
|
@view = "funk"
|
data/ymdp_generator.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{ymdp_generator}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.3"
|
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"]
|
12
|
-
s.date = %q{2010-01-
|
12
|
+
s.date = %q{2010-01-25}
|
13
13
|
s.description = %q{Generates new views, JavaScripts, stylesheets and translation assets for Yahoo! Mail Development Platform applications.}
|
14
14
|
s.email = %q{progressions@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -19,11 +19,11 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.files = [
|
20
20
|
".document",
|
21
21
|
".gitignore",
|
22
|
+
"History.txt",
|
22
23
|
"LICENSE",
|
23
24
|
"README.rdoc",
|
24
25
|
"Rakefile",
|
25
26
|
"VERSION",
|
26
|
-
"lib/support/file.rb",
|
27
27
|
"lib/view.rb",
|
28
28
|
"lib/ymdp_generator.rb",
|
29
29
|
"spec/spec.opts",
|
@@ -47,11 +47,14 @@ Gem::Specification.new do |s|
|
|
47
47
|
|
48
48
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
49
49
|
s.add_development_dependency(%q<rspec>, [">= 1.2.6"])
|
50
|
+
s.add_runtime_dependency(%q<f>, [">= 0"])
|
50
51
|
else
|
51
52
|
s.add_dependency(%q<rspec>, [">= 1.2.6"])
|
53
|
+
s.add_dependency(%q<f>, [">= 0"])
|
52
54
|
end
|
53
55
|
else
|
54
56
|
s.add_dependency(%q<rspec>, [">= 1.2.6"])
|
57
|
+
s.add_dependency(%q<f>, [">= 0"])
|
55
58
|
end
|
56
59
|
end
|
57
60
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ymdp_generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Coleman
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-01-
|
12
|
+
date: 2010-01-25 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -22,6 +22,16 @@ dependencies:
|
|
22
22
|
- !ruby/object:Gem::Version
|
23
23
|
version: 1.2.6
|
24
24
|
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: f
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
25
35
|
description: Generates new views, JavaScripts, stylesheets and translation assets for Yahoo! Mail Development Platform applications.
|
26
36
|
email: progressions@gmail.com
|
27
37
|
executables: []
|
@@ -34,11 +44,11 @@ extra_rdoc_files:
|
|
34
44
|
files:
|
35
45
|
- .document
|
36
46
|
- .gitignore
|
47
|
+
- History.txt
|
37
48
|
- LICENSE
|
38
49
|
- README.rdoc
|
39
50
|
- Rakefile
|
40
51
|
- VERSION
|
41
|
-
- lib/support/file.rb
|
42
52
|
- lib/view.rb
|
43
53
|
- lib/ymdp_generator.rb
|
44
54
|
- spec/spec.opts
|
data/lib/support/file.rb
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
module YMDP
|
2
|
-
module FileSupport
|
3
|
-
def confirm_overwrite(path)
|
4
|
-
if File.exists?(path)
|
5
|
-
$stdout.puts "File exists: #{File.expand_path(path)}"
|
6
|
-
$stdout.print " overwrite? (y/n)"
|
7
|
-
answer = $stdin.gets
|
8
|
-
|
9
|
-
answer =~ /^y/i
|
10
|
-
else
|
11
|
-
true
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
# friendlier display of paths
|
16
|
-
def display_path(path)
|
17
|
-
path = File.expand_path(path)
|
18
|
-
path.gsub(BASE_PATH, "")
|
19
|
-
end
|
20
|
-
|
21
|
-
# saves the output string to the filename given
|
22
|
-
#
|
23
|
-
def save_to_file(output, filename)
|
24
|
-
unless File.exists?(filename)
|
25
|
-
File.open(filename, "w") do |w|
|
26
|
-
w.write(output)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
# given a path and line number, returns the line and two lines previous
|
32
|
-
#
|
33
|
-
def get_line_from_file(path, line_number)
|
34
|
-
line_number = line_number.to_i
|
35
|
-
output = ""
|
36
|
-
lines = []
|
37
|
-
|
38
|
-
File.open(path) do |f|
|
39
|
-
lines = f.readlines
|
40
|
-
end
|
41
|
-
|
42
|
-
output += "\n"
|
43
|
-
|
44
|
-
3.times do |i|
|
45
|
-
line = lines[line_number-(3-i)]
|
46
|
-
output += line if line
|
47
|
-
end
|
48
|
-
|
49
|
-
output += "\n"
|
50
|
-
|
51
|
-
output
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|