organize 0.1.0 → 1.0.0
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/.gitignore +5 -1
- data/Gemfile.lock +10 -10
- data/Rakefile +17 -1
- data/lib/organize/project.rb +8 -18
- data/lib/organize/runner.rb +23 -19
- data/lib/organize/version.rb +1 -1
- data/organize.gemspec +1 -1
- data/spec/organize/project_spec.rb +17 -109
- data/spec/organize/runner_spec.rb +19 -30
- metadata +6 -7
- data/.bundle/config +0 -2
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -2,7 +2,7 @@ PATH
|
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
4
|
organize (0.1.0)
|
5
|
-
optitron (~> 0.
|
5
|
+
optitron (~> 0.2)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: http://rubygems.org/
|
@@ -14,11 +14,11 @@ GEM
|
|
14
14
|
fakefs (0.2.1)
|
15
15
|
infinity_test (0.2.0)
|
16
16
|
watchr (>= 0.7)
|
17
|
-
optitron (0.
|
18
|
-
callsite (
|
19
|
-
ruby2ruby (
|
20
|
-
ruby_parser (
|
21
|
-
sexp_processor (
|
17
|
+
optitron (0.2.0)
|
18
|
+
callsite (~> 0.0.4)
|
19
|
+
ruby2ruby (~> 1.2.4)
|
20
|
+
ruby_parser (~> 2.0)
|
21
|
+
sexp_processor (~> 3.0.4)
|
22
22
|
rspec (2.0.0.beta.22)
|
23
23
|
rspec-core (= 2.0.0.beta.22)
|
24
24
|
rspec-expectations (= 2.0.0.beta.22)
|
@@ -29,12 +29,12 @@ GEM
|
|
29
29
|
rspec-mocks (2.0.0.beta.22)
|
30
30
|
rspec-core (= 2.0.0.beta.22)
|
31
31
|
rspec-expectations (= 2.0.0.beta.22)
|
32
|
-
ruby2ruby (1.2.
|
32
|
+
ruby2ruby (1.2.5)
|
33
33
|
ruby_parser (~> 2.0)
|
34
34
|
sexp_processor (~> 3.0)
|
35
|
-
ruby_parser (2.0.
|
35
|
+
ruby_parser (2.0.5)
|
36
36
|
sexp_processor (~> 3.0)
|
37
|
-
sexp_processor (3.0.
|
37
|
+
sexp_processor (3.0.5)
|
38
38
|
watchr (0.7)
|
39
39
|
|
40
40
|
PLATFORMS
|
@@ -45,7 +45,7 @@ DEPENDENCIES
|
|
45
45
|
derickbailey-notamock (~> 0.0.1)
|
46
46
|
fakefs (~> 0.2)
|
47
47
|
infinity_test (~> 0.2)
|
48
|
-
optitron (~> 0.
|
48
|
+
optitron (~> 0.2)
|
49
49
|
organize!
|
50
50
|
rspec (= 2.0.0.beta.22)
|
51
51
|
watchr (~> 0.6)
|
data/Rakefile
CHANGED
@@ -2,4 +2,20 @@ require 'bundler'
|
|
2
2
|
Bundler::GemHelper.install_tasks
|
3
3
|
|
4
4
|
require 'rspec/core/rake_task'
|
5
|
-
RSpec::Core::RakeTask.new :rspec
|
5
|
+
RSpec::Core::RakeTask.new :rspec
|
6
|
+
|
7
|
+
def gemspec
|
8
|
+
file = 'organize.gemspec'
|
9
|
+
@gemspec ||= eval(File.read(file), binding, file)
|
10
|
+
end
|
11
|
+
|
12
|
+
desc 'Build the gem'
|
13
|
+
task :gem do
|
14
|
+
sh 'gem build organize.gemspec'
|
15
|
+
mv "#{gemspec.full_name}.gem", 'pkg'
|
16
|
+
end
|
17
|
+
|
18
|
+
desc 'Install organize'
|
19
|
+
task :install => :gem do
|
20
|
+
sh "gem install pkg/#{gemspec.full_name}.gem"
|
21
|
+
end
|
data/lib/organize/project.rb
CHANGED
@@ -1,23 +1,16 @@
|
|
1
1
|
module Organize
|
2
2
|
class Project
|
3
3
|
|
4
|
-
attr_reader :
|
4
|
+
attr_reader :name
|
5
|
+
PREFIX = File.expand_path('~/Projects')
|
6
|
+
SHARED_PREFIX = File.expand_path('~/Dropbox')
|
5
7
|
|
6
|
-
|
7
|
-
:prefix => '~/Projects',
|
8
|
-
:shared_prefix => '~/Dropbox'
|
9
|
-
}
|
10
|
-
|
11
|
-
def initialize(name, options = {})
|
8
|
+
def initialize(name)
|
12
9
|
@name = name
|
13
|
-
|
14
|
-
options = DEFAULTS.merge(options)
|
15
|
-
@prefix = options[:prefix]
|
16
|
-
@shared_prefix = options[:shared_prefix]
|
17
10
|
end
|
18
11
|
|
19
12
|
def path
|
20
|
-
File.join(
|
13
|
+
File.join(PREFIX, name)
|
21
14
|
end
|
22
15
|
|
23
16
|
def archive_path
|
@@ -25,7 +18,7 @@ module Organize
|
|
25
18
|
end
|
26
19
|
|
27
20
|
def shared_path
|
28
|
-
File.join(
|
21
|
+
File.join(SHARED_PREFIX, name)
|
29
22
|
end
|
30
23
|
|
31
24
|
def shared_link_path
|
@@ -33,7 +26,7 @@ module Organize
|
|
33
26
|
end
|
34
27
|
|
35
28
|
def project_archive_path
|
36
|
-
File.join(
|
29
|
+
File.join(PREFIX, 'Archive')
|
37
30
|
end
|
38
31
|
|
39
32
|
def create
|
@@ -41,10 +34,7 @@ module Organize
|
|
41
34
|
FileUtils.mkdir_p(shared_path)
|
42
35
|
FileUtils.mkdir_p(archive_path)
|
43
36
|
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
|
37
|
+
FileUtils.ln_s(shared_path, shared_link_path) unless File.exists?(shared_link_path)
|
48
38
|
end
|
49
39
|
end
|
50
40
|
end
|
data/lib/organize/runner.rb
CHANGED
@@ -1,38 +1,42 @@
|
|
1
1
|
require 'optitron'
|
2
2
|
require 'yaml'
|
3
|
+
require 'fileutils'
|
3
4
|
|
4
5
|
module Organize
|
5
6
|
class Runner < Optitron::CLI
|
6
7
|
desc 'Install organize to your home directory.'
|
7
|
-
def install
|
8
|
+
def install
|
9
|
+
prefix = Project::PREFIX
|
10
|
+
shared_prefix = Project::SHARED_PREFIX
|
11
|
+
|
12
|
+
# Create the prefix and shared prefix.
|
8
13
|
FileUtils.mkdir_p(prefix)
|
9
14
|
FileUtils.mkdir_p(File.join(prefix, 'Archive'))
|
10
15
|
FileUtils.mkdir_p(shared_prefix)
|
11
|
-
FileUtils.mkdir_p(File.join(prefix, 'Other'))
|
12
|
-
FileUtils.ln_s(inbox, File.join(prefix, 'Inbox'))
|
13
16
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
+
# Create Inbox pseudo-project
|
18
|
+
inbox = File.join(prefix, 'Inbox')
|
19
|
+
inbox_shared = File.join(shared_prefix, 'Inbox')
|
20
|
+
inbox_shared_link = File.join(inbox, 'Shared')
|
21
|
+
|
22
|
+
FileUtils.ln_s(File.expand_path('~/Desktop'), inbox) unless File.exists?(inbox)
|
23
|
+
FileUtils.mkdir_p(inbox_shared)
|
24
|
+
FileUtils.ln_s(inbox_shared, inbox_shared_link) unless File.exists?(inbox_shared_link)
|
17
25
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
}
|
26
|
+
# Create the Other project
|
27
|
+
other = Project.new('Other')
|
28
|
+
other.create
|
22
29
|
|
23
|
-
|
30
|
+
%w{Documents Movies Music Pictures Public Sites}.each do |directory|
|
31
|
+
old_directory = File.expand_path("~/#{directory}")
|
32
|
+
new_directory = File.join(other.path, directory)
|
33
|
+
FileUtils.ln_s(old_directory, new_directory) unless File.exists?(new_directory)
|
34
|
+
end
|
24
35
|
end
|
25
36
|
|
26
37
|
desc 'Creates a new project.'
|
27
38
|
def create(name)
|
28
|
-
|
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']
|
39
|
+
Project.new(name).create
|
36
40
|
end
|
37
41
|
end
|
38
42
|
end
|
data/lib/organize/version.rb
CHANGED
data/organize.gemspec
CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.required_rubygems_version = '~> 1.3.6'
|
16
16
|
s.rubyforge_project = 'organize'
|
17
17
|
|
18
|
-
s.add_dependency 'optitron', '~> 0.
|
18
|
+
s.add_dependency 'optitron', '~> 0.2'
|
19
19
|
|
20
20
|
s.add_development_dependency 'bundler', '~> 1.0'
|
21
21
|
s.add_development_dependency 'rspec', '2.0.0.beta.22'
|
@@ -8,42 +8,17 @@ describe Organize::Project do
|
|
8
8
|
subject.name.should == 'Foo'
|
9
9
|
end
|
10
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
11
|
describe '#path' do
|
36
12
|
before do
|
37
|
-
project.track_methods :
|
13
|
+
project.track_methods :name
|
38
14
|
subject
|
39
15
|
end
|
40
16
|
|
41
17
|
subject { project.path }
|
42
18
|
|
43
19
|
it 'should combine the prefix and name' do
|
44
|
-
project.should have_received(:prefix)
|
45
20
|
project.should have_received(:name)
|
46
|
-
should == '~/Projects/Foo'
|
21
|
+
should == File.expand_path('~/Projects/Foo')
|
47
22
|
end
|
48
23
|
end
|
49
24
|
|
@@ -57,22 +32,21 @@ describe Organize::Project do
|
|
57
32
|
|
58
33
|
it 'should tack on Archive to the end of the path' do
|
59
34
|
project.should have_received(:path)
|
60
|
-
should == '~/Projects/Foo/Archive'
|
35
|
+
should == File.expand_path('~/Projects/Foo/Archive')
|
61
36
|
end
|
62
37
|
end
|
63
38
|
|
64
39
|
describe '#shared_path' do
|
65
40
|
before do
|
66
|
-
project.track_methods :
|
41
|
+
project.track_methods :name
|
67
42
|
subject
|
68
43
|
end
|
69
44
|
|
70
45
|
subject { project.shared_path }
|
71
46
|
|
72
47
|
it 'should tack on the name to the end of the shared path' do
|
73
|
-
project.should have_received(:shared_prefix)
|
74
48
|
project.should have_received(:name)
|
75
|
-
should == '~/Dropbox/Foo'
|
49
|
+
should == File.expand_path('~/Dropbox/Foo')
|
76
50
|
end
|
77
51
|
end
|
78
52
|
|
@@ -86,104 +60,38 @@ describe Organize::Project do
|
|
86
60
|
|
87
61
|
it 'should tack on Shared to the end of the path' do
|
88
62
|
project.should have_received(:path)
|
89
|
-
should == '~/Projects/Foo/Shared'
|
63
|
+
should == File.expand_path('~/Projects/Foo/Shared')
|
90
64
|
end
|
91
65
|
end
|
92
66
|
|
93
67
|
describe '#project_archive_path' do
|
94
|
-
before do
|
95
|
-
project.track_methods :prefix
|
96
|
-
subject
|
97
|
-
end
|
98
|
-
|
99
68
|
subject { project.project_archive_path }
|
100
69
|
|
101
70
|
it 'should tack on Archive to the end of the prefix' do
|
102
|
-
|
103
|
-
should == '~/Projects/Archive'
|
71
|
+
should == File.expand_path('~/Projects/Archive')
|
104
72
|
end
|
105
73
|
end
|
106
74
|
|
107
75
|
describe '#create' do
|
108
76
|
before do
|
109
|
-
FileUtils.rm_rf(
|
110
|
-
|
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
|
77
|
+
FileUtils.rm_rf(File.expand_path('~'))
|
78
|
+
project.create
|
142
79
|
end
|
143
80
|
|
144
|
-
|
145
|
-
|
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
|
81
|
+
it 'should create the project directory' do
|
82
|
+
File.directory?(project.path).should be_true
|
154
83
|
end
|
155
84
|
|
156
|
-
|
157
|
-
|
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
|
85
|
+
it 'should create the shared project directory' do
|
86
|
+
File.directory?(project.shared_path).should be_true
|
171
87
|
end
|
172
88
|
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
it 'should be created' do
|
177
|
-
File.directory?(project.archive_path).should be_true
|
178
|
-
end
|
89
|
+
it 'should creat the archive directory' do
|
90
|
+
File.directory?(project.archive_path).should be_true
|
179
91
|
end
|
180
92
|
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
it 'should be created' do
|
185
|
-
File.directory?(project.project_archive_path).should be_true
|
186
|
-
end
|
93
|
+
it 'should create the project archive directory' do
|
94
|
+
File.directory?(project.project_archive_path).should be_true
|
187
95
|
end
|
188
96
|
end
|
189
97
|
end
|
@@ -1,62 +1,51 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Organize::Runner do
|
4
|
-
let(:runner) { Organize::Runner
|
4
|
+
let(:runner) { Organize::Runner }
|
5
5
|
subject { runner }
|
6
6
|
|
7
7
|
before do
|
8
8
|
FileUtils.rm_rf '~'
|
9
9
|
|
10
|
-
|
11
|
-
|
10
|
+
%w{Desktop Documents Movies Music Pictures Public Sites}.each do |directory|
|
11
|
+
directory = File.expand_path("~/#{directory}")
|
12
|
+
FileUtils.mkdir_p(directory)
|
12
13
|
end
|
13
14
|
end
|
14
15
|
|
15
|
-
# TODO: Make these tests not suck.
|
16
16
|
describe '#install' do
|
17
|
-
|
18
|
-
before { subject }
|
17
|
+
before { runner.dispatch(%w{install}) }
|
19
18
|
|
20
|
-
it 'should create the
|
21
|
-
|
19
|
+
it 'should create the prefixes' do
|
20
|
+
%w{Projects Dropbox}.each do |directory|
|
21
|
+
directory = File.expand_path("~/#{directory}")
|
22
22
|
File.directory?(directory).should be_true
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
it 'should
|
27
|
-
|
28
|
-
File.
|
26
|
+
it 'should create the Inbox and Other projects' do
|
27
|
+
%w{Inbox Other}.each do |directory|
|
28
|
+
directory = File.expand_path("~/Projects/#{directory}")
|
29
|
+
File.directory?(directory).should be_true
|
29
30
|
end
|
30
31
|
end
|
31
32
|
|
32
|
-
it 'should
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
33
|
+
it 'should symlink the Other directories' do
|
34
|
+
%w{Documents Movies Music Pictures Public Sites}.each do |directory|
|
35
|
+
directory = File.expand_path("~/Projects/Other/#{directory}")
|
36
|
+
File.symlink?(directory).should be_true
|
37
|
+
end
|
37
38
|
end
|
38
39
|
end
|
39
40
|
|
40
41
|
describe '#create' do
|
41
|
-
subject { runner.create 'Foo' }
|
42
|
-
|
43
42
|
before do
|
44
|
-
runner.install
|
45
|
-
|
43
|
+
runner.dispatch(%w{install})
|
44
|
+
runner.dispatch(%w{create Foo})
|
46
45
|
end
|
47
46
|
|
48
47
|
it 'should create the new project' do
|
49
48
|
File.directory?('~/Projects/Foo').should be_true
|
50
49
|
end
|
51
50
|
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
51
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: organize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
|
-
- 0
|
8
7
|
- 1
|
9
8
|
- 0
|
10
|
-
|
9
|
+
- 0
|
10
|
+
version: 1.0.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Alexander Kern
|
@@ -26,11 +26,11 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
hash:
|
29
|
+
hash: 15
|
30
30
|
segments:
|
31
31
|
- 0
|
32
|
-
-
|
33
|
-
version: "0.
|
32
|
+
- 2
|
33
|
+
version: "0.2"
|
34
34
|
type: :runtime
|
35
35
|
version_requirements: *id001
|
36
36
|
- !ruby/object:Gem::Dependency
|
@@ -137,7 +137,6 @@ extensions: []
|
|
137
137
|
extra_rdoc_files: []
|
138
138
|
|
139
139
|
files:
|
140
|
-
- .bundle/config
|
141
140
|
- .gitignore
|
142
141
|
- .rspec
|
143
142
|
- Gemfile
|
data/.bundle/config
DELETED