organize 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,2 @@
1
+ ---
2
+ BUNDLE_DISABLE_SHARED_GEMS: "1"
@@ -0,0 +1,2 @@
1
+ pkg/*
2
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ -Ispec
2
+ --color
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source :gemcutter
2
+ gemspec
@@ -0,0 +1,51 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ organize (0.1.0)
5
+ optitron (~> 0.1)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ callsite (0.0.4)
11
+ derickbailey-notamock (0.0.1)
12
+ rspec (>= 1.2.9)
13
+ diff-lcs (1.1.2)
14
+ fakefs (0.2.1)
15
+ infinity_test (0.2.0)
16
+ watchr (>= 0.7)
17
+ optitron (0.1.7)
18
+ callsite (= 0.0.4)
19
+ ruby2ruby (= 1.2.4)
20
+ ruby_parser (>= 2.0)
21
+ sexp_processor (= 3.0.4)
22
+ rspec (2.0.0.beta.22)
23
+ rspec-core (= 2.0.0.beta.22)
24
+ rspec-expectations (= 2.0.0.beta.22)
25
+ rspec-mocks (= 2.0.0.beta.22)
26
+ rspec-core (2.0.0.beta.22)
27
+ rspec-expectations (2.0.0.beta.22)
28
+ diff-lcs (>= 1.1.2)
29
+ rspec-mocks (2.0.0.beta.22)
30
+ rspec-core (= 2.0.0.beta.22)
31
+ rspec-expectations (= 2.0.0.beta.22)
32
+ ruby2ruby (1.2.4)
33
+ ruby_parser (~> 2.0)
34
+ sexp_processor (~> 3.0)
35
+ ruby_parser (2.0.4)
36
+ sexp_processor (~> 3.0)
37
+ sexp_processor (3.0.4)
38
+ watchr (0.7)
39
+
40
+ PLATFORMS
41
+ ruby
42
+
43
+ DEPENDENCIES
44
+ bundler (~> 1.0)
45
+ derickbailey-notamock (~> 0.0.1)
46
+ fakefs (~> 0.2)
47
+ infinity_test (~> 0.2)
48
+ optitron (~> 0.1)
49
+ organize!
50
+ rspec (= 2.0.0.beta.22)
51
+ watchr (~> 0.6)
@@ -0,0 +1,5 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'rspec/core/rake_task'
5
+ RSpec::Core::RakeTask.new :rspec
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require 'organize'
3
+ Organize::Runner.dispatch
@@ -0,0 +1,5 @@
1
+ module Organize
2
+ autoload :Project, 'organize/project'
3
+ autoload :Runner, 'organize/runner'
4
+ autoload :Version, 'organize/version'
5
+ end
@@ -0,0 +1,50 @@
1
+ module Organize
2
+ class Project
3
+
4
+ attr_reader :prefix, :shared_prefix, :name
5
+
6
+ DEFAULTS = {
7
+ :prefix => '~/Projects',
8
+ :shared_prefix => '~/Dropbox'
9
+ }
10
+
11
+ def initialize(name, options = {})
12
+ @name = name
13
+
14
+ options = DEFAULTS.merge(options)
15
+ @prefix = options[:prefix]
16
+ @shared_prefix = options[:shared_prefix]
17
+ end
18
+
19
+ def path
20
+ File.join(prefix, name)
21
+ end
22
+
23
+ def archive_path
24
+ File.join(path, 'Archive')
25
+ end
26
+
27
+ def shared_path
28
+ File.join(shared_prefix, name)
29
+ end
30
+
31
+ def shared_link_path
32
+ File.join(path, 'Shared')
33
+ end
34
+
35
+ def project_archive_path
36
+ File.join(prefix, 'Archive')
37
+ end
38
+
39
+ def create
40
+ FileUtils.mkdir_p(path)
41
+ FileUtils.mkdir_p(shared_path)
42
+ FileUtils.mkdir_p(archive_path)
43
+ FileUtils.mkdir_p(project_archive_path)
44
+
45
+ unless File.exists?(shared_link_path)
46
+ FileUtils.ln_s(shared_path, shared_link_path)
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,38 @@
1
+ require 'optitron'
2
+ require 'yaml'
3
+
4
+ module Organize
5
+ class Runner < Optitron::CLI
6
+ desc 'Install organize to your home directory.'
7
+ def install(prefix = '~/Projects', shared_prefix = '~/Dropbox', inbox = '~/Desktop')
8
+ FileUtils.mkdir_p(prefix)
9
+ FileUtils.mkdir_p(File.join(prefix, 'Archive'))
10
+ FileUtils.mkdir_p(shared_prefix)
11
+ FileUtils.mkdir_p(File.join(prefix, 'Other'))
12
+ FileUtils.ln_s(inbox, File.join(prefix, 'Inbox'))
13
+
14
+ ['Documents', 'Movies', 'Music', 'Pictures', 'Public', 'Sites'].each do |directory|
15
+ FileUtils.ln_s("~/#{directory}", File.join(prefix, 'Other', directory))
16
+ end
17
+
18
+ config = {
19
+ 'prefix' => prefix,
20
+ 'shared_prefix' => shared_prefix
21
+ }
22
+
23
+ File.open('~/.organize', 'w+') { |f| f.write(YAML::dump(config)) }
24
+ end
25
+
26
+ desc 'Creates a new project.'
27
+ def create(name)
28
+ config = YAML::load_file '~/.organize'
29
+ project = Project.new name, :prefix => config['prefix'], :shared_prefix => config['shared_prefix']
30
+ project.create
31
+ end
32
+
33
+ desc 'Gets the prefix.'
34
+ def prefix
35
+ print YAML::load_file('~/.organize')['prefix']
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,3 @@
1
+ module Organize
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,30 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
3
+ require 'organize/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'organize'
7
+ s.version = Organize::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ['Alexander Kern']
10
+ s.email = ['alex@kernul.com']
11
+ s.homepage = 'http://github.com/CapnKernul/organize'
12
+ s.summary = 'Organize your Mac filesystem.'
13
+ s.description = 'Creates directories and links to manage your Mac consistently.'
14
+
15
+ s.required_rubygems_version = '~> 1.3.6'
16
+ s.rubyforge_project = 'organize'
17
+
18
+ s.add_dependency 'optitron', '~> 0.1'
19
+
20
+ s.add_development_dependency 'bundler', '~> 1.0'
21
+ s.add_development_dependency 'rspec', '2.0.0.beta.22'
22
+ s.add_development_dependency 'watchr', '~> 0.6'
23
+ s.add_development_dependency 'derickbailey-notamock', '~> 0.0.1'
24
+ s.add_development_dependency 'fakefs', '~> 0.2'
25
+ s.add_development_dependency 'infinity_test', '~> 0.2'
26
+
27
+ s.files = `git ls-files`.split("\n")
28
+ s.executables = `git ls-files`.split("\n").map {|f| f[%r{^bin/(.*)}, 1]}.compact
29
+ s.require_path = 'lib'
30
+ end
@@ -0,0 +1,189 @@
1
+ require 'spec_helper'
2
+
3
+ describe Organize::Project do
4
+ let(:project) { Organize::Project.new 'Foo' }
5
+ subject { project }
6
+
7
+ it 'should have a name' do
8
+ subject.name.should == 'Foo'
9
+ end
10
+
11
+ context 'when created without a prefix' do
12
+ its(:prefix) { should == '~/Projects' }
13
+ end
14
+
15
+ context 'when created without a shared prefix' do
16
+ its(:shared_prefix) { should == '~/Dropbox' }
17
+ end
18
+
19
+ context 'when created with a prefix' do
20
+ subject { Organize::Project.new 'Foo', :prefix => '~/Prefix' }
21
+
22
+ it 'should use that prefix instead of the default one' do
23
+ subject.prefix.should == '~/Prefix'
24
+ end
25
+ end
26
+
27
+ context 'when created with a shared prefix' do
28
+ subject { Organize::Project.new 'Foo', :shared_prefix => '~/Shared' }
29
+
30
+ it 'should use that prefix instead of the default one' do
31
+ subject.shared_prefix.should == '~/Shared'
32
+ end
33
+ end
34
+
35
+ describe '#path' do
36
+ before do
37
+ project.track_methods :prefix, :name
38
+ subject
39
+ end
40
+
41
+ subject { project.path }
42
+
43
+ it 'should combine the prefix and name' do
44
+ project.should have_received(:prefix)
45
+ project.should have_received(:name)
46
+ should == '~/Projects/Foo'
47
+ end
48
+ end
49
+
50
+ describe '#archive_path' do
51
+ before do
52
+ project.track_methods :path
53
+ subject
54
+ end
55
+
56
+ subject { project.archive_path }
57
+
58
+ it 'should tack on Archive to the end of the path' do
59
+ project.should have_received(:path)
60
+ should == '~/Projects/Foo/Archive'
61
+ end
62
+ end
63
+
64
+ describe '#shared_path' do
65
+ before do
66
+ project.track_methods :shared_prefix, :name
67
+ subject
68
+ end
69
+
70
+ subject { project.shared_path }
71
+
72
+ it 'should tack on the name to the end of the shared path' do
73
+ project.should have_received(:shared_prefix)
74
+ project.should have_received(:name)
75
+ should == '~/Dropbox/Foo'
76
+ end
77
+ end
78
+
79
+ describe '#shared_link_path' do
80
+ before do
81
+ project.track_methods :path
82
+ subject
83
+ end
84
+
85
+ subject { project.shared_link_path }
86
+
87
+ it 'should tack on Shared to the end of the path' do
88
+ project.should have_received(:path)
89
+ should == '~/Projects/Foo/Shared'
90
+ end
91
+ end
92
+
93
+ describe '#project_archive_path' do
94
+ before do
95
+ project.track_methods :prefix
96
+ subject
97
+ end
98
+
99
+ subject { project.project_archive_path }
100
+
101
+ it 'should tack on Archive to the end of the prefix' do
102
+ project.should have_received(:prefix)
103
+ should == '~/Projects/Archive'
104
+ end
105
+ end
106
+
107
+ describe '#create' do
108
+ before do
109
+ FileUtils.rm_rf(project.prefix)
110
+ FileUtils.rm_rf(project.shared_prefix)
111
+ end
112
+
113
+ subject { project.create }
114
+
115
+ context 'when the prefix does not exist' do
116
+ before { subject }
117
+
118
+ it 'should be created' do
119
+ File.directory?(project.prefix).should be_true
120
+ end
121
+
122
+ it 'should create the project directory' do
123
+ File.directory?(project.path).should be_true
124
+ end
125
+ end
126
+
127
+ context 'when the prefix does exist' do
128
+ let(:other_project_path) { File.join(project.prefix, 'Bar') }
129
+
130
+ before do
131
+ FileUtils.mkdir_p(other_project_path)
132
+ subject
133
+ end
134
+
135
+ it 'should not delete the other files/directories in the prefix' do
136
+ File.directory?(other_project_path).should be_true
137
+ end
138
+
139
+ it 'should only create the project directory' do
140
+ File.directory?(project.path).should be_true
141
+ end
142
+ end
143
+
144
+ context 'when the shared prefix does not exist' do
145
+ before { subject }
146
+
147
+ it 'should be created' do
148
+ File.directory?(project.shared_prefix).should be_true
149
+ end
150
+
151
+ it 'should create the project directory' do
152
+ File.directory?(project.shared_path).should be_true
153
+ end
154
+ end
155
+
156
+ context 'when the shared prefix does exist' do
157
+ let(:other_shared_path) { File.join(project.shared_prefix, 'Bar') }
158
+
159
+ before do
160
+ FileUtils.mkdir_p(other_shared_path)
161
+ subject
162
+ end
163
+
164
+ it 'should not delete the other files/directories in the shared prefix' do
165
+ File.directory?(other_shared_path).should be_true
166
+ end
167
+
168
+ it 'should only create the project shared directory' do
169
+ File.directory?(project.shared_path).should be_true
170
+ end
171
+ end
172
+
173
+ context 'when the archive path does not exist' do
174
+ before { subject }
175
+
176
+ it 'should be created' do
177
+ File.directory?(project.archive_path).should be_true
178
+ end
179
+ end
180
+
181
+ context 'when the project archive path does not exist' do
182
+ before { subject }
183
+
184
+ it 'should be created' do
185
+ File.directory?(project.project_archive_path).should be_true
186
+ end
187
+ end
188
+ end
189
+ end
@@ -0,0 +1,62 @@
1
+ require 'spec_helper'
2
+
3
+ describe Organize::Runner do
4
+ let(:runner) { Organize::Runner.new }
5
+ subject { runner }
6
+
7
+ before do
8
+ FileUtils.rm_rf '~'
9
+
10
+ ['~/Desktop', '~/Documents', '~/Movies', '~/Music', '~/Pictures', '~/Public', '~/Sites'].each do |directory|
11
+ FileUtils.mkdir_p directory
12
+ end
13
+ end
14
+
15
+ # TODO: Make these tests not suck.
16
+ describe '#install' do
17
+ subject { runner.install }
18
+ before { subject }
19
+
20
+ it 'should create the necessary directories' do
21
+ ['~', '~/Projects', '~/Dropbox', '~/Projects/Archive', '~/Projects/Other'].each do |directory|
22
+ File.directory?(directory).should be_true
23
+ end
24
+ end
25
+
26
+ it 'should symlink the Other directories' do
27
+ ['Documents', 'Movies', 'Music', 'Pictures', 'Public', 'Sites'].each do |directory|
28
+ File.symlink?(File.join('~/Projects/Other', directory)).should be_true
29
+ end
30
+ end
31
+
32
+ it 'should write to the .organize file correctly' do
33
+ YAML::load_file('~/.organize').should == {
34
+ 'prefix' => '~/Projects',
35
+ 'shared_prefix' => '~/Dropbox'
36
+ }
37
+ end
38
+ end
39
+
40
+ describe '#create' do
41
+ subject { runner.create 'Foo' }
42
+
43
+ before do
44
+ runner.install
45
+ subject
46
+ end
47
+
48
+ it 'should create the new project' do
49
+ File.directory?('~/Projects/Foo').should be_true
50
+ end
51
+ end
52
+
53
+ describe '#prefix' do
54
+ subject { runner.prefix }
55
+ before { runner.install }
56
+
57
+ it 'should return the prefix' do
58
+ stdout = capture(:stdout) { subject }
59
+ stdout.should == '~/Projects'
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,13 @@
1
+ require 'bundler/setup'
2
+
3
+ require 'rspec'
4
+ require 'not_a_mock'
5
+ require 'fakefs/spec_helpers'
6
+
7
+ require 'organize'
8
+ Dir[File.dirname(__FILE__) + '/support/**/*.rb'].each { |f| require f }
9
+
10
+ RSpec.configure do |config|
11
+ config.mock_with NotAMock::RspecMockFrameworkAdapter
12
+ config.include FakeFS::SpecHelpers
13
+ end
@@ -0,0 +1,15 @@
1
+ require 'stringio'
2
+
3
+ def capture(*streams)
4
+ streams.map! { |stream| stream.to_s }
5
+
6
+ begin
7
+ result = StringIO.new
8
+ streams.each { |stream| eval "$#{stream} = result" }
9
+ yield
10
+ ensure
11
+ streams.each { |stream| eval("$#{stream} = #{stream.upcase}") }
12
+ end
13
+
14
+ result.string
15
+ end
File without changes
metadata ADDED
@@ -0,0 +1,194 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: organize
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Alexander Kern
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-10-05 00:00:00 -07:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: optitron
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ hash: 9
30
+ segments:
31
+ - 0
32
+ - 1
33
+ version: "0.1"
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: bundler
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ hash: 15
45
+ segments:
46
+ - 1
47
+ - 0
48
+ version: "1.0"
49
+ type: :development
50
+ version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ name: rspec
53
+ prerelease: false
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - "="
58
+ - !ruby/object:Gem::Version
59
+ hash: 62196431
60
+ segments:
61
+ - 2
62
+ - 0
63
+ - 0
64
+ - beta
65
+ - 22
66
+ version: 2.0.0.beta.22
67
+ type: :development
68
+ version_requirements: *id003
69
+ - !ruby/object:Gem::Dependency
70
+ name: watchr
71
+ prerelease: false
72
+ requirement: &id004 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ hash: 7
78
+ segments:
79
+ - 0
80
+ - 6
81
+ version: "0.6"
82
+ type: :development
83
+ version_requirements: *id004
84
+ - !ruby/object:Gem::Dependency
85
+ name: derickbailey-notamock
86
+ prerelease: false
87
+ requirement: &id005 !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ~>
91
+ - !ruby/object:Gem::Version
92
+ hash: 29
93
+ segments:
94
+ - 0
95
+ - 0
96
+ - 1
97
+ version: 0.0.1
98
+ type: :development
99
+ version_requirements: *id005
100
+ - !ruby/object:Gem::Dependency
101
+ name: fakefs
102
+ prerelease: false
103
+ requirement: &id006 !ruby/object:Gem::Requirement
104
+ none: false
105
+ requirements:
106
+ - - ~>
107
+ - !ruby/object:Gem::Version
108
+ hash: 15
109
+ segments:
110
+ - 0
111
+ - 2
112
+ version: "0.2"
113
+ type: :development
114
+ version_requirements: *id006
115
+ - !ruby/object:Gem::Dependency
116
+ name: infinity_test
117
+ prerelease: false
118
+ requirement: &id007 !ruby/object:Gem::Requirement
119
+ none: false
120
+ requirements:
121
+ - - ~>
122
+ - !ruby/object:Gem::Version
123
+ hash: 15
124
+ segments:
125
+ - 0
126
+ - 2
127
+ version: "0.2"
128
+ type: :development
129
+ version_requirements: *id007
130
+ description: Creates directories and links to manage your Mac consistently.
131
+ email:
132
+ - alex@kernul.com
133
+ executables:
134
+ - organize
135
+ extensions: []
136
+
137
+ extra_rdoc_files: []
138
+
139
+ files:
140
+ - .bundle/config
141
+ - .gitignore
142
+ - .rspec
143
+ - Gemfile
144
+ - Gemfile.lock
145
+ - Rakefile
146
+ - bin/organize
147
+ - lib/organize.rb
148
+ - lib/organize/project.rb
149
+ - lib/organize/runner.rb
150
+ - lib/organize/version.rb
151
+ - organize.gemspec
152
+ - spec/organize/project_spec.rb
153
+ - spec/organize/runner_spec.rb
154
+ - spec/spec_helper.rb
155
+ - spec/support/helpers/capture.rb
156
+ - spec/support/matchers/matchers.rb
157
+ has_rdoc: true
158
+ homepage: http://github.com/CapnKernul/organize
159
+ licenses: []
160
+
161
+ post_install_message:
162
+ rdoc_options: []
163
+
164
+ require_paths:
165
+ - lib
166
+ required_ruby_version: !ruby/object:Gem::Requirement
167
+ none: false
168
+ requirements:
169
+ - - ">="
170
+ - !ruby/object:Gem::Version
171
+ hash: 3
172
+ segments:
173
+ - 0
174
+ version: "0"
175
+ required_rubygems_version: !ruby/object:Gem::Requirement
176
+ none: false
177
+ requirements:
178
+ - - ~>
179
+ - !ruby/object:Gem::Version
180
+ hash: 23
181
+ segments:
182
+ - 1
183
+ - 3
184
+ - 6
185
+ version: 1.3.6
186
+ requirements: []
187
+
188
+ rubyforge_project: organize
189
+ rubygems_version: 1.3.7
190
+ signing_key:
191
+ specification_version: 3
192
+ summary: Organize your Mac filesystem.
193
+ test_files: []
194
+