projit 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,14 @@
1
+ v0.5.0 / 2011-11-23
2
+
3
+ Enhancements
4
+
5
+ - Create empty project directories as part of DSL
6
+ - DSL to specify project subdirectories
7
+
8
+ Changes
9
+
10
+ - Remove option to symlink to Dropbox from CLI
11
+ - To symlink to Dropbox call `create_link_in_dropbox` in your template
12
+ - Make type an argument instead of an option
13
+ - Type is now specified after new
14
+ - It defaults to template if not specified
data/README.markdown CHANGED
@@ -18,10 +18,14 @@ This will run the recipe you have installed in `~/.projit/template.rb`. To get t
18
18
 
19
19
  This will run the same recipe but also clone the specified git repository (assuming you have `clone_from_git` in your recipe).
20
20
 
21
- projit new personal/projit\_demo --type screencast
21
+ projit new screencast personal/projit_demo
22
22
 
23
23
  Runs the recipe stored in `~/.projit/screencast.rb` to setup a directory structure for screencasting. To get the generator that I use for screencasting download [this gist][screencasting] (structure stolen from @topfunky).
24
24
 
25
+ ## Templates
26
+
27
+ Projit makes a few methods available to you to assist you in creating your directory structure. Use `project_name` to get access to the name you specified at the command line. `create_project_directory` will create the directory specified by "name" at your project root; its counterpart `create_project_subdirs` will create the directories you specified by calling `project_subdirs` under the project. Finally, `create_link_in_dropbox` will symlink your project to Dropbox (add a `dropbox_home` option to ~/.projit/config).
28
+
25
29
  ## Contributions
26
30
 
27
31
  Contributions are encouraged, but given the very personal nature of workflows don't be suprised if I prefer creating recipes over adding to projit itself. Feel free to send pull requests though, it's the only way for me to see how other people use this. I will not accept Ruby code without spec coverage.
data/lib/projit/cli.rb CHANGED
@@ -4,9 +4,9 @@ require 'projit'
4
4
  module Projit
5
5
  class CLI < Thor
6
6
 
7
- desc "new NAME", "Create project named NAME under current directory or CLIENT if specified"
8
- class_options dropbox: false, git: nil, type: nil
9
- def new(name)
7
+ desc "new TYPE NAME", "Create project named NAME under current directory using the template specified by TYPE"
8
+ class_options git: nil
9
+ def new(type, name=nil)
10
10
  args = ARGV.reject { |a| a == "new" }
11
11
  Projit::ProjectGenerator.start args
12
12
  end
@@ -9,19 +9,34 @@ module Projit
9
9
 
10
10
  source_root "~/.projit"
11
11
 
12
- argument :project
13
- class_options dropbox: false, git: nil
14
- class_option :type, default: "template"
12
+ argument :type, default: "template"
13
+ argument :project, required: false
14
+ class_options git: nil
15
15
 
16
16
  def new
17
17
  apply projit_template
18
18
  end
19
19
 
20
-
21
20
  protected
22
21
 
23
22
  def projit_template
24
- "#{options[:type]}.rb"
23
+ "#{template_name}.rb"
24
+ end
25
+
26
+ def create_project_directory
27
+ in_project_root do
28
+ empty_directory project_name
29
+ end
30
+ end
31
+
32
+ def project_subdirs(subdirs)
33
+ @project_subdirs = subdirs
34
+ end
35
+
36
+ def create_project_subdirs
37
+ in_project_directory do
38
+ @project_subdirs.each { |d| empty_directory d }
39
+ end
25
40
  end
26
41
 
27
42
  def in_project_root(&block)
@@ -29,11 +44,10 @@ module Projit
29
44
  end
30
45
 
31
46
  def in_project_directory(&block)
32
- inside projects_home_path.join(project), &block
47
+ inside projects_home_path.join(project_name), &block
33
48
  end
34
49
 
35
50
  def create_link_in_dropbox(name)
36
- return unless options[:dropbox]
37
51
  unless dropbox_configured?
38
52
  say "How can I create a link to your Dropbox if you haven't told me where in your Dropbox to create it? Please add a value for 'dropbox_home' to ~/.projit/config."
39
53
  return
@@ -57,11 +71,19 @@ module Projit
57
71
  end
58
72
 
59
73
  def project_path
60
- Pathname.new project
74
+ Pathname.new project_name
75
+ end
76
+
77
+ def project_name
78
+ project || type
79
+ end
80
+
81
+ def template_name
82
+ (project && type) || "template"
61
83
  end
62
84
 
63
85
  def project_full_path
64
- projects_home_path.join(project)
86
+ projects_home_path.join(project_name)
65
87
  end
66
88
 
67
89
  def project_base
@@ -1,3 +1,3 @@
1
1
  module Projit
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
@@ -20,12 +20,6 @@ describe Projit::ProjectGenerator do
20
20
  subject.stub :create_link
21
21
  end
22
22
 
23
- it "Skips linking with Dropbox when option is not supplied" do
24
- (subject.stub :options).and_return dropbox: false
25
- subject.should_not_receive :create_link
26
- subject.send :create_link_in_dropbox, "test"
27
- end
28
-
29
23
  context "with Dropbox configured" do
30
24
 
31
25
  before do
@@ -108,10 +102,14 @@ describe Projit::ProjectGenerator do
108
102
  end
109
103
 
110
104
  context "support project types" do
111
- it "uses type parameter to find the template script" do
112
- subject.stub(options: { type: "web_application" })
105
+ it "uses type argument to find the template script" do
106
+ subject.stub(type: "web_application")
113
107
  subject.send(:projit_template).should eq "web_application.rb"
114
108
  end
109
+ it "uses type argument for project name if name isn't specified" do
110
+ subject.stub(type: "project", name: nil)
111
+ subject.send(:project_name).should eq "project"
112
+ end
115
113
  end
116
114
 
117
115
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: projit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-03 00:00:00.000000000Z
12
+ date: 2011-11-23 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
16
- requirement: &70287568473380 !ruby/object:Gem::Requirement
16
+ requirement: &70232051991160 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70287568473380
24
+ version_requirements: *70232051991160
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &70287568472960 !ruby/object:Gem::Requirement
27
+ requirement: &70232051990620 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70287568472960
35
+ version_requirements: *70232051990620
36
36
  description: Generate project directory structure based on a switchable template.
37
37
  email:
38
38
  - joe@joefiorini.com
@@ -44,6 +44,7 @@ files:
44
44
  - .gitignore
45
45
  - .rbenv-gemsets
46
46
  - .rvmrc
47
+ - Changelog.markdown
47
48
  - Gemfile
48
49
  - README.markdown
49
50
  - Rakefile