wp_scaffold 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +6 -0
  3. data/.rspec +2 -0
  4. data/Guardfile +8 -0
  5. data/README.md +9 -1
  6. data/bin/wp +19 -8
  7. data/lib/.DS_Store +0 -0
  8. data/lib/wp_scaffold.rb +27 -8
  9. data/lib/wp_scaffold/helpers/text_helpers.rb +19 -0
  10. data/lib/wp_scaffold/models/generator.rb +43 -0
  11. data/lib/wp_scaffold/models/generators/custom_post_type.rb +26 -0
  12. data/lib/wp_scaffold/models/generators/setting.rb +14 -0
  13. data/lib/wp_scaffold/models/generators/theme.rb +21 -0
  14. data/lib/wp_scaffold/templates/custom_post_type/custom-post-types/custom.php +30 -0
  15. data/lib/wp_scaffold/templates/custom_post_type/page-custom.php.erb +38 -0
  16. data/lib/wp_scaffold/templates/custom_post_type/single-custom.php.erb +25 -0
  17. data/lib/wp_scaffold/templates/setting/wp_scaffold_settings.txt.erb +1 -0
  18. data/lib/wp_scaffold/templates/{theme_base → theme/custom_theme}/README.md +1 -1
  19. data/lib/wp_scaffold/templates/{theme_base → theme/custom_theme}/category.php +0 -0
  20. data/lib/wp_scaffold/templates/{theme_base → theme/custom_theme}/footer.php +0 -0
  21. data/lib/wp_scaffold/templates/{theme_base → theme/custom_theme}/front-page.php +0 -0
  22. data/lib/wp_scaffold/templates/{theme_base → theme/custom_theme}/functions.php +8 -4
  23. data/lib/wp_scaffold/templates/{theme_base → theme/custom_theme}/functions/breadcrumbs.php +0 -0
  24. data/lib/wp_scaffold/templates/{theme_base → theme/custom_theme}/header.php +6 -5
  25. data/lib/wp_scaffold/templates/{theme_base → theme/custom_theme}/home.php +0 -0
  26. data/lib/wp_scaffold/templates/{theme_base → theme/custom_theme}/index.php +0 -0
  27. data/lib/wp_scaffold/templates/theme/custom_theme/js/main.js +7 -0
  28. data/lib/wp_scaffold/templates/{theme_base → theme/custom_theme}/js/vendor/fastclick.js +0 -0
  29. data/lib/wp_scaffold/templates/{theme_base → theme/custom_theme}/js/vendor/html5shiv.js +0 -0
  30. data/lib/wp_scaffold/templates/{theme_base → theme/custom_theme}/js/vendor/jquery.easydropdown.min.js +0 -0
  31. data/lib/wp_scaffold/templates/{theme_base → theme/custom_theme}/js/vendor/retina-1.1.0.min.js +0 -0
  32. data/lib/wp_scaffold/templates/{theme_base → theme/custom_theme}/page.php +0 -0
  33. data/lib/wp_scaffold/templates/{theme_base → theme/custom_theme}/partials/content-post.php +0 -0
  34. data/lib/wp_scaffold/templates/{theme_base → theme/custom_theme}/screenshot.png +0 -0
  35. data/lib/wp_scaffold/templates/{theme_base → theme/custom_theme}/single.php +0 -0
  36. data/lib/wp_scaffold/templates/theme/custom_theme/style.css +7 -0
  37. data/lib/wp_scaffold/usage.txt +2 -1
  38. data/lib/wp_scaffold/version.rb +1 -1
  39. data/spec/models/cpt_spec.rb +38 -0
  40. data/spec/models/generator_spec.rb +38 -0
  41. data/spec/models/setting_spec.rb +33 -0
  42. data/spec/models/theme_spec.rb +35 -0
  43. data/spec/spec_helper.rb +31 -0
  44. data/spec/templates/files/php/test_file_3.php.erb +5 -0
  45. data/spec/templates/files/test_file_1.txt +1 -0
  46. data/spec/templates/files/test_file_2.txt.erb +1 -0
  47. data/spec/wp_scaffold_spec.rb +34 -0
  48. data/wp_scaffold.gemspec +4 -1
  49. metadata +95 -36
  50. data/lib/wp_scaffold/generator.rb +0 -81
  51. data/lib/wp_scaffold/helper.rb +0 -11
  52. data/lib/wp_scaffold/templates/.DS_Store +0 -0
  53. data/lib/wp_scaffold/templates/custom_post_type/page-custom.php +0 -50
  54. data/lib/wp_scaffold/templates/custom_post_type/register-cpt.php +0 -31
  55. data/lib/wp_scaffold/templates/custom_post_type/single-custom.php +0 -18
  56. data/lib/wp_scaffold/templates/theme_base/.gitignore +0 -2
  57. data/lib/wp_scaffold/templates/theme_base/coffee/main.coffee +0 -2
  58. data/lib/wp_scaffold/templates/theme_base/functions/theme-settings.php +0 -60
  59. data/lib/wp_scaffold/templates/theme_base/js/main.js +0 -2
  60. data/lib/wp_scaffold/templates/theme_base/style.css +0 -211
  61. data/lib/wp_scaffold/templates/theme_base/styles/_base.scss +0 -36
  62. data/lib/wp_scaffold/templates/theme_base/styles/_grid.scss +0 -327
  63. data/lib/wp_scaffold/templates/theme_base/styles/_normalize.scss +0 -410
  64. data/lib/wp_scaffold/templates/theme_base/styles/style.scss +0 -19
@@ -0,0 +1,7 @@
1
+ (function(){
2
+ jQuery(document).ready(function(e){
3
+
4
+ return console.log("ready to go!")
5
+
6
+ })
7
+ }).call(this);
@@ -0,0 +1,7 @@
1
+ /*
2
+ Theme Name: <%= @generator.name.titleize %>
3
+ Description: Blank theme with basic Wordpress functions included.
4
+ Author: [Author Name]
5
+ Author URI: [Author Website]
6
+ Version: 0.1
7
+ */
@@ -5,7 +5,8 @@ USAGE:
5
5
  To create a new theme:
6
6
  wp new "theme name"
7
7
 
8
+
8
9
  To create a custom post type (from within your theme's root directory):
9
- wp cpt "Post Type Name"
10
+ wp cpt "Post Type Name"
10
11
 
11
12
  Make sure that your custom post type name is singular; wp_scaffold with take care of pluralizing it for you.
@@ -1,3 +1,3 @@
1
1
  module WpScaffold
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -0,0 +1,38 @@
1
+ require "spec_helper"
2
+
3
+ describe CustomPostType do
4
+
5
+ it "has a name" do
6
+ expect(CustomPostType.method_defined?(:name)).to be_true
7
+ end
8
+
9
+ it "has a default name" do
10
+ expect(CustomPostType.new.name).to eq CustomPostType::DEFAULT_NAME
11
+ end
12
+
13
+ it "can overwrite the default name" do
14
+ cpt_name = "a custom name"
15
+ expect(CustomPostType.new(cpt_name).name).to eq cpt_name
16
+ end
17
+
18
+ it "gets copied to the current folder" do
19
+ expect(CustomPostType.new.destination).to eq ""
20
+ end
21
+
22
+ it "gets copied from the CPT template folder" do
23
+ expect(CustomPostType.new.template_path).to eq "custom_post_type"
24
+ end
25
+
26
+ it "renames the files appropriatly" do
27
+ cpt = CustomPostType.new("My Post Type")
28
+ cpt.generate
29
+ expect(File.exists?("page-my-post-type.php")).to be_true
30
+ expect(File.exists?("single-my-post-type.php")).to be_true
31
+ expect(File.exists?("custom-post-types/my-post-type.php")).to be_true
32
+
33
+ # delete files
34
+ # FileUtils.rm_rf "custom-post-types"
35
+ FileUtils.rm %w( page-my-post-type.php single-my-post-type.php )
36
+ end
37
+
38
+ end
@@ -0,0 +1,38 @@
1
+ require "spec_helper"
2
+
3
+ describe Generator do
4
+
5
+ it "has a template path" do
6
+ expect(Generator.method_defined?(:template_path)).to be_true
7
+ end
8
+
9
+ it "has a destination" do
10
+ expect(Generator.method_defined?(:destination)).to be_true
11
+ end
12
+
13
+ it "has a name" do
14
+ expect(Generator.method_defined?(:name)).to be_true
15
+ end
16
+
17
+ it "compiles the templates to the destination directory" do
18
+ generator_name = "My Generator!"
19
+
20
+ # Run the method
21
+ gen = Generator.new
22
+ gen.template_path = "../../../spec/templates/files"
23
+ gen.destination = @test_destination
24
+ gen.name = generator_name
25
+ gen.generate
26
+
27
+ # Were the files copied?
28
+ expect(File).to exist(WpScaffold::Base::USER_DIRECTORY + @test_destination + "/" + "test_file_1.txt")
29
+
30
+ # And did the templating work?
31
+ file2 = File.read(WpScaffold::Base::USER_DIRECTORY + @test_destination + "/" + "test_file_2.txt")
32
+ expect(file2).to include generator_name
33
+
34
+ file3 = File.read(WpScaffold::Base::USER_DIRECTORY + @test_destination + "/" + "php/test_file_3.php")
35
+ expect(file3).to include generator_name
36
+ end
37
+
38
+ end
@@ -0,0 +1,33 @@
1
+ require "spec_helper"
2
+
3
+ describe Setting do
4
+
5
+ it "has a user_path_setting" do
6
+ expect(Setting.method_defined?(:user_path_setting)).to be_true
7
+ end
8
+
9
+ it "gets copied to the current user's home folder" do
10
+ expect(Setting.new.destination).to eq ENV['HOME']
11
+ end
12
+
13
+ it "gets copied from the setting template folder" do
14
+ expect(Setting.new.template_path).to eq "setting"
15
+ end
16
+
17
+ it "sets the user_path_setting based on user input" do
18
+ user_path = "my_custom_path"
19
+ setting = Setting.new(user_path)
20
+ expect(setting.user_path_setting).to eq user_path
21
+ end
22
+
23
+ it "includes the user's custom template path" do
24
+ user_path = "documents/wp_scaffold_custom_templates/"
25
+ setting = Setting.new(user_path)
26
+ setting.generate
27
+ expect(File.read(ENV['HOME']+"/wp_scaffold_settings.txt")).to eq user_path
28
+
29
+ # delete it
30
+ FileUtils.rm ENV['HOME']+"/wp_scaffold_settings.txt"
31
+ end
32
+
33
+ end
@@ -0,0 +1,35 @@
1
+ require "spec_helper"
2
+
3
+ describe Theme do
4
+
5
+ it "has a name" do
6
+ expect(Theme.method_defined?(:name)).to be_true
7
+ end
8
+
9
+ it "has a default name" do
10
+ expect(Theme.new.name).to eq Theme::DEFAULT_NAME
11
+ end
12
+
13
+ it "can overwrite the default name" do
14
+ theme_name = "a custom name"
15
+ expect(Theme.new(theme_name).name).to eq theme_name
16
+ end
17
+
18
+ it "gets copied to the current folder" do
19
+ expect(Theme.new.destination).to eq ""
20
+ end
21
+
22
+ it "gets copied from the theme template folder" do
23
+ expect(Theme.new.template_path).to eq "theme"
24
+ end
25
+
26
+ it "renames its enclosing folder to match the theme name" do
27
+ theme = Theme.new("My New Theme")
28
+ theme.generate
29
+ expect(File.directory?("my_new_theme")).to be_true
30
+
31
+ # delete it
32
+ FileUtils.rm_rf "my_new_theme"
33
+ end
34
+
35
+ end
@@ -0,0 +1,31 @@
1
+ require_relative "../lib/wp_scaffold"
2
+
3
+ include FileUtils
4
+
5
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
6
+ RSpec.configure do |config|
7
+
8
+ config.treat_symbols_as_metadata_keys_with_true_values = true
9
+ config.run_all_when_everything_filtered = true
10
+ config.filter_run :focus
11
+
12
+ # Run specs in random order to surface order dependencies.
13
+ config.order = 'random'
14
+
15
+ config.before(:each) do
16
+ @test_destination = "tmp"
17
+ FileUtils.mkdir_p "../tmp"
18
+ end
19
+
20
+ config.after(:each) do
21
+ FileUtils.rm_rf "../tmp"
22
+ end
23
+
24
+ config.before(:all) do
25
+ # delete our settings file
26
+ if File.exists? ENV['HOME']+"/wp_scaffold_settings.txt"
27
+ FileUtils.rm ENV['HOME']+"/wp_scaffold_settings.txt"
28
+ end
29
+ end
30
+
31
+ end
@@ -0,0 +1,5 @@
1
+ <?php
2
+
3
+ echo 'My name is <%= @generator.name %>';
4
+
5
+ ?>
@@ -0,0 +1 @@
1
+ This is only a test!
@@ -0,0 +1 @@
1
+ This is only a test with a name: <%= @generator.name %>
@@ -0,0 +1,34 @@
1
+ require "spec_helper"
2
+
3
+ describe WpScaffold::Base do
4
+
5
+ it "has a pwd helper" do
6
+ expect(WpScaffold::Base::USER_DIRECTORY).not_to be_nil
7
+ end
8
+
9
+ it "has a default template base" do
10
+ expect(WpScaffold::Base::TEMPLATE_BASE).not_to be_nil
11
+ end
12
+
13
+
14
+ # context "when the user has a settings file" do
15
+
16
+ # before :each do
17
+ # # create a settings file
18
+ # @user_path = "documents/my_wp_scaffold_custom_templates/"
19
+ # setting = Setting.new(@user_path)
20
+ # setting.generate
21
+ # end
22
+
23
+ # after :each do
24
+ # # delete our settings file
25
+ # FileUtils.rm File.expand_path('~')+"/wp_scaffold_settings.txt"
26
+ # end
27
+
28
+ # it "loads the user's template base" do
29
+ # expect(WpScaffold::Base::TEMPLATE_BASE).to eq File.expand_path('~') + "/" + @user_path
30
+ # end
31
+
32
+ # end # when the user has a settings file
33
+
34
+ end
@@ -21,7 +21,10 @@ Gem::Specification.new do |spec|
21
21
  # Development Dependencies
22
22
  spec.add_development_dependency "bundler", "~> 1.3"
23
23
  spec.add_development_dependency "rake"
24
+ spec.add_development_dependency "rspec"
25
+ spec.add_development_dependency "guard-rspec"
24
26
 
25
27
  # Runtime Dependencies
26
- spec.add_runtime_dependency %q<activesupport>, [">= 0"]
28
+ spec.add_runtime_dependency "activesupport"
29
+ spec.add_runtime_dependency "colorize"
27
30
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wp_scaffold
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Hackley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-27 00:00:00.000000000 Z
11
+ date: 2014-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,6 +38,34 @@ dependencies:
38
38
  - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: guard-rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
41
69
  - !ruby/object:Gem::Dependency
42
70
  name: activesupport
43
71
  requirement: !ruby/object:Gem::Requirement
@@ -52,6 +80,20 @@ dependencies:
52
80
  - - '>='
53
81
  - !ruby/object:Gem::Version
54
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: colorize
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
55
97
  description: Scaffold commands for Wordpress theme development.
56
98
  email:
57
99
  - nathanhackley@gmail.com
@@ -61,47 +103,55 @@ extensions: []
61
103
  extra_rdoc_files: []
62
104
  files:
63
105
  - .gitignore
106
+ - .rspec
64
107
  - Gemfile
108
+ - Guardfile
65
109
  - LICENSE.txt
66
110
  - README.md
67
111
  - Rakefile
68
112
  - bin/wp
69
113
  - lib/.DS_Store
70
114
  - lib/wp_scaffold.rb
71
- - lib/wp_scaffold/generator.rb
72
- - lib/wp_scaffold/helper.rb
73
- - lib/wp_scaffold/templates/.DS_Store
74
- - lib/wp_scaffold/templates/custom_post_type/page-custom.php
75
- - lib/wp_scaffold/templates/custom_post_type/register-cpt.php
76
- - lib/wp_scaffold/templates/custom_post_type/single-custom.php
77
- - lib/wp_scaffold/templates/theme_base/.gitignore
78
- - lib/wp_scaffold/templates/theme_base/README.md
79
- - lib/wp_scaffold/templates/theme_base/category.php
80
- - lib/wp_scaffold/templates/theme_base/coffee/main.coffee
81
- - lib/wp_scaffold/templates/theme_base/footer.php
82
- - lib/wp_scaffold/templates/theme_base/front-page.php
83
- - lib/wp_scaffold/templates/theme_base/functions.php
84
- - lib/wp_scaffold/templates/theme_base/functions/breadcrumbs.php
85
- - lib/wp_scaffold/templates/theme_base/functions/theme-settings.php
86
- - lib/wp_scaffold/templates/theme_base/header.php
87
- - lib/wp_scaffold/templates/theme_base/home.php
88
- - lib/wp_scaffold/templates/theme_base/index.php
89
- - lib/wp_scaffold/templates/theme_base/js/main.js
90
- - lib/wp_scaffold/templates/theme_base/js/vendor/fastclick.js
91
- - lib/wp_scaffold/templates/theme_base/js/vendor/html5shiv.js
92
- - lib/wp_scaffold/templates/theme_base/js/vendor/jquery.easydropdown.min.js
93
- - lib/wp_scaffold/templates/theme_base/js/vendor/retina-1.1.0.min.js
94
- - lib/wp_scaffold/templates/theme_base/page.php
95
- - lib/wp_scaffold/templates/theme_base/partials/content-post.php
96
- - lib/wp_scaffold/templates/theme_base/screenshot.png
97
- - lib/wp_scaffold/templates/theme_base/single.php
98
- - lib/wp_scaffold/templates/theme_base/style.css
99
- - lib/wp_scaffold/templates/theme_base/styles/_base.scss
100
- - lib/wp_scaffold/templates/theme_base/styles/_grid.scss
101
- - lib/wp_scaffold/templates/theme_base/styles/_normalize.scss
102
- - lib/wp_scaffold/templates/theme_base/styles/style.scss
115
+ - lib/wp_scaffold/.DS_Store
116
+ - lib/wp_scaffold/helpers/text_helpers.rb
117
+ - lib/wp_scaffold/models/generator.rb
118
+ - lib/wp_scaffold/models/generators/custom_post_type.rb
119
+ - lib/wp_scaffold/models/generators/setting.rb
120
+ - lib/wp_scaffold/models/generators/theme.rb
121
+ - lib/wp_scaffold/templates/custom_post_type/custom-post-types/custom.php
122
+ - lib/wp_scaffold/templates/custom_post_type/page-custom.php.erb
123
+ - lib/wp_scaffold/templates/custom_post_type/single-custom.php.erb
124
+ - lib/wp_scaffold/templates/setting/wp_scaffold_settings.txt.erb
125
+ - lib/wp_scaffold/templates/theme/custom_theme/README.md
126
+ - lib/wp_scaffold/templates/theme/custom_theme/category.php
127
+ - lib/wp_scaffold/templates/theme/custom_theme/footer.php
128
+ - lib/wp_scaffold/templates/theme/custom_theme/front-page.php
129
+ - lib/wp_scaffold/templates/theme/custom_theme/functions.php
130
+ - lib/wp_scaffold/templates/theme/custom_theme/functions/breadcrumbs.php
131
+ - lib/wp_scaffold/templates/theme/custom_theme/header.php
132
+ - lib/wp_scaffold/templates/theme/custom_theme/home.php
133
+ - lib/wp_scaffold/templates/theme/custom_theme/index.php
134
+ - lib/wp_scaffold/templates/theme/custom_theme/js/main.js
135
+ - lib/wp_scaffold/templates/theme/custom_theme/js/vendor/fastclick.js
136
+ - lib/wp_scaffold/templates/theme/custom_theme/js/vendor/html5shiv.js
137
+ - lib/wp_scaffold/templates/theme/custom_theme/js/vendor/jquery.easydropdown.min.js
138
+ - lib/wp_scaffold/templates/theme/custom_theme/js/vendor/retina-1.1.0.min.js
139
+ - lib/wp_scaffold/templates/theme/custom_theme/page.php
140
+ - lib/wp_scaffold/templates/theme/custom_theme/partials/content-post.php
141
+ - lib/wp_scaffold/templates/theme/custom_theme/screenshot.png
142
+ - lib/wp_scaffold/templates/theme/custom_theme/single.php
143
+ - lib/wp_scaffold/templates/theme/custom_theme/style.css
103
144
  - lib/wp_scaffold/usage.txt
104
145
  - lib/wp_scaffold/version.rb
146
+ - spec/models/cpt_spec.rb
147
+ - spec/models/generator_spec.rb
148
+ - spec/models/setting_spec.rb
149
+ - spec/models/theme_spec.rb
150
+ - spec/spec_helper.rb
151
+ - spec/templates/files/php/test_file_3.php.erb
152
+ - spec/templates/files/test_file_1.txt
153
+ - spec/templates/files/test_file_2.txt.erb
154
+ - spec/wp_scaffold_spec.rb
105
155
  - wp_scaffold.gemspec
106
156
  homepage: https://github.com/nathanhackley/wp_scaffold
107
157
  licenses:
@@ -123,8 +173,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
173
  version: '0'
124
174
  requirements: []
125
175
  rubyforge_project:
126
- rubygems_version: 2.0.6
176
+ rubygems_version: 2.2.1
127
177
  signing_key:
128
178
  specification_version: 4
129
179
  summary: Scaffold commands for Wordpress theme development.
130
- test_files: []
180
+ test_files:
181
+ - spec/models/cpt_spec.rb
182
+ - spec/models/generator_spec.rb
183
+ - spec/models/setting_spec.rb
184
+ - spec/models/theme_spec.rb
185
+ - spec/spec_helper.rb
186
+ - spec/templates/files/php/test_file_3.php.erb
187
+ - spec/templates/files/test_file_1.txt
188
+ - spec/templates/files/test_file_2.txt.erb
189
+ - spec/wp_scaffold_spec.rb