project_group 0.1.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.
- checksums.yaml +15 -0
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +28 -0
- data/Gemfile.lock +130 -0
- data/Guardfile +34 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/bin/proj +7 -0
- data/lib/project_group.rb +18 -0
- data/lib/project_group/command.rb +72 -0
- data/lib/project_group/config.rb +98 -0
- data/lib/project_group/group.rb +16 -0
- data/lib/project_group/repo.rb +99 -0
- data/lib/project_group/single.rb +26 -0
- data/lib/project_group/sublime_project.rb +23 -0
- data/project_group.gemspec +103 -0
- data/spec/command_spec.rb +30 -0
- data/spec/config_spec.rb +126 -0
- data/spec/group_spec.rb +58 -0
- data/spec/project_group_spec.rb +9 -0
- data/spec/repo_spec.rb +71 -0
- data/spec/spec_helper.rb +22 -0
- data/spec/sublime_project_spec.rb +19 -0
- data/spec/support/ec.rb +7 -0
- data/spec/support/make_initial.rb +162 -0
- metadata +255 -0
@@ -0,0 +1,16 @@
|
|
1
|
+
module ProjectGroup
|
2
|
+
class Group
|
3
|
+
include FromHash
|
4
|
+
attr_accessor :name
|
5
|
+
fattr(:singles) { [] }
|
6
|
+
def <<(path)
|
7
|
+
self.singles << Single.new(:path => path)
|
8
|
+
end
|
9
|
+
def uncommitted_files
|
10
|
+
singles.map { |x| x.uncommitted_files }.flatten
|
11
|
+
end
|
12
|
+
def needs_push?
|
13
|
+
singles.any? { |x| x.needs_push? }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
module ProjectGroup
|
2
|
+
class Repo
|
3
|
+
include FromHash
|
4
|
+
attr_accessor :path
|
5
|
+
def name
|
6
|
+
raise "name call"
|
7
|
+
end
|
8
|
+
def cmd(str)
|
9
|
+
c = "cd #{path} && #{str}"
|
10
|
+
#puts c
|
11
|
+
res = ProjectGroup.ec(c)
|
12
|
+
#puts res
|
13
|
+
res
|
14
|
+
end
|
15
|
+
def git(*args)
|
16
|
+
raise "no git repo for #{path}" unless FileTest.exist?("#{path}/.git")
|
17
|
+
str = args.join(" ")
|
18
|
+
cmd "git #{str}"
|
19
|
+
end
|
20
|
+
|
21
|
+
fattr(:repo) do
|
22
|
+
Grit::Repo.new(path)
|
23
|
+
end
|
24
|
+
|
25
|
+
def print!
|
26
|
+
puts "Gem: #{name}".color(:white)
|
27
|
+
if !current?
|
28
|
+
changed_files.each do |type,files|
|
29
|
+
files.each do |f|
|
30
|
+
puts "#{type}: #{f}"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
puts "Needs Push #{local_ref} -> #{remote_ref}" unless pushed?
|
34
|
+
else
|
35
|
+
puts "No Changes"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def use_file?(f)
|
40
|
+
return false if %w(build tmp log pkg vendor junk).any? { |x| x == f.split("/").first }
|
41
|
+
return false if f =~ /public\/assets/
|
42
|
+
return false if f.split(".").last == "log"
|
43
|
+
return false if f =~ /testflight_launcher/
|
44
|
+
true
|
45
|
+
end
|
46
|
+
|
47
|
+
fattr(:changed_files) do
|
48
|
+
res = {:modified => [], :added => [], :untracked => []}
|
49
|
+
s = repo.status
|
50
|
+
|
51
|
+
s.changed.each do |path,file|
|
52
|
+
res[:modified] << path if use_file?(path)
|
53
|
+
end
|
54
|
+
|
55
|
+
s.added.each do |path,file|
|
56
|
+
res[:added] << path if use_file?(path)
|
57
|
+
end
|
58
|
+
|
59
|
+
s.untracked.each do |path,file|
|
60
|
+
res[:untracked] << path if use_file?(path)
|
61
|
+
end
|
62
|
+
|
63
|
+
res
|
64
|
+
end
|
65
|
+
|
66
|
+
def changes?
|
67
|
+
changed_files.values.any? { |x| x.size > 0 }
|
68
|
+
end
|
69
|
+
|
70
|
+
fattr(:remote_ref) do
|
71
|
+
remote = repo.remotes.find { |x| x.name == "origin/master" }
|
72
|
+
if remote
|
73
|
+
remote.commit.to_s
|
74
|
+
else
|
75
|
+
nil
|
76
|
+
end
|
77
|
+
end
|
78
|
+
fattr(:local_ref) do
|
79
|
+
repo.commits("master",1).first.sha.to_s
|
80
|
+
end
|
81
|
+
def pushed?
|
82
|
+
remote_ref == local_ref
|
83
|
+
end
|
84
|
+
|
85
|
+
def current?
|
86
|
+
!changes? && pushed?
|
87
|
+
end
|
88
|
+
|
89
|
+
def push_check!
|
90
|
+
repo!; local_ref!
|
91
|
+
return if pushed?
|
92
|
+
print "Push? "
|
93
|
+
resp = STDIN.gets.to_s.strip.downcase
|
94
|
+
if resp == 'y'
|
95
|
+
git "push origin master"
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module ProjectGroup
|
2
|
+
class Single
|
3
|
+
include FromHash
|
4
|
+
|
5
|
+
attr_accessor :path, :name
|
6
|
+
fattr(:name) do
|
7
|
+
File.basename(path)
|
8
|
+
end
|
9
|
+
fattr(:repo) do
|
10
|
+
Repo.new(:path => path)
|
11
|
+
end
|
12
|
+
def uncommitted_files
|
13
|
+
repo.changed_files.values.flatten.map { |x| OpenStruct.new(:relative_path => x) }
|
14
|
+
end
|
15
|
+
def needs_push?
|
16
|
+
!repo.pushed?
|
17
|
+
end
|
18
|
+
|
19
|
+
def status
|
20
|
+
{:committed => !repo.changes?, :pushed => repo.pushed?}
|
21
|
+
end
|
22
|
+
def spec_output
|
23
|
+
`cd #{path} && bundle exec rake spec`
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module ProjectGroup
|
2
|
+
class SublimeProject
|
3
|
+
include FromHash
|
4
|
+
attr_accessor :group
|
5
|
+
def as_json
|
6
|
+
folders = group.singles.map do |proj|
|
7
|
+
{"path" => proj.path, "name" => proj.name}
|
8
|
+
end
|
9
|
+
{"folders" => folders}
|
10
|
+
end
|
11
|
+
def to_json
|
12
|
+
as_json.to_json
|
13
|
+
end
|
14
|
+
|
15
|
+
fattr(:path) do
|
16
|
+
File.expand_path("~/.project_group/sublime_projects/#{group.name}.sublime-project")
|
17
|
+
end
|
18
|
+
|
19
|
+
def write!
|
20
|
+
File.create path, to_json
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "project_group"
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Mike Harris"]
|
12
|
+
s.date = "2013-10-02"
|
13
|
+
s.description = "project_group"
|
14
|
+
s.email = "mharris717@gmail.com"
|
15
|
+
s.executables = ["proj"]
|
16
|
+
s.extra_rdoc_files = [
|
17
|
+
"LICENSE.txt",
|
18
|
+
"README.rdoc"
|
19
|
+
]
|
20
|
+
s.files = [
|
21
|
+
".document",
|
22
|
+
".rspec",
|
23
|
+
"Gemfile",
|
24
|
+
"Gemfile.lock",
|
25
|
+
"Guardfile",
|
26
|
+
"LICENSE.txt",
|
27
|
+
"README.rdoc",
|
28
|
+
"Rakefile",
|
29
|
+
"VERSION",
|
30
|
+
"bin/proj",
|
31
|
+
"lib/project_group.rb",
|
32
|
+
"lib/project_group/command.rb",
|
33
|
+
"lib/project_group/config.rb",
|
34
|
+
"lib/project_group/group.rb",
|
35
|
+
"lib/project_group/repo.rb",
|
36
|
+
"lib/project_group/single.rb",
|
37
|
+
"lib/project_group/sublime_project.rb",
|
38
|
+
"project_group.gemspec",
|
39
|
+
"spec/command_spec.rb",
|
40
|
+
"spec/config_spec.rb",
|
41
|
+
"spec/group_spec.rb",
|
42
|
+
"spec/project_group_spec.rb",
|
43
|
+
"spec/repo_spec.rb",
|
44
|
+
"spec/spec_helper.rb",
|
45
|
+
"spec/sublime_project_spec.rb",
|
46
|
+
"spec/support/ec.rb",
|
47
|
+
"spec/support/make_initial.rb"
|
48
|
+
]
|
49
|
+
s.homepage = "http://github.com/mharris717/project_group"
|
50
|
+
s.licenses = ["MIT"]
|
51
|
+
s.require_paths = ["lib"]
|
52
|
+
s.rubygems_version = "2.0.7"
|
53
|
+
s.summary = "project_group"
|
54
|
+
|
55
|
+
if s.respond_to? :specification_version then
|
56
|
+
s.specification_version = 4
|
57
|
+
|
58
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
59
|
+
s.add_runtime_dependency(%q<mharris_ext>, [">= 0"])
|
60
|
+
s.add_runtime_dependency(%q<andand>, [">= 0"])
|
61
|
+
s.add_runtime_dependency(%q<grit>, [">= 0"])
|
62
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
|
63
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
64
|
+
s.add_development_dependency(%q<bundler>, [">= 1.0"])
|
65
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.7"])
|
66
|
+
s.add_development_dependency(%q<guard>, [">= 0"])
|
67
|
+
s.add_development_dependency(%q<guard-rspec>, [">= 0"])
|
68
|
+
s.add_development_dependency(%q<guard-spork>, [">= 0"])
|
69
|
+
s.add_development_dependency(%q<rb-fsevent>, ["~> 0.9"])
|
70
|
+
s.add_development_dependency(%q<lre>, [">= 0"])
|
71
|
+
s.add_development_dependency(%q<rr>, [">= 0"])
|
72
|
+
else
|
73
|
+
s.add_dependency(%q<mharris_ext>, [">= 0"])
|
74
|
+
s.add_dependency(%q<andand>, [">= 0"])
|
75
|
+
s.add_dependency(%q<grit>, [">= 0"])
|
76
|
+
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
77
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
78
|
+
s.add_dependency(%q<bundler>, [">= 1.0"])
|
79
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.7"])
|
80
|
+
s.add_dependency(%q<guard>, [">= 0"])
|
81
|
+
s.add_dependency(%q<guard-rspec>, [">= 0"])
|
82
|
+
s.add_dependency(%q<guard-spork>, [">= 0"])
|
83
|
+
s.add_dependency(%q<rb-fsevent>, ["~> 0.9"])
|
84
|
+
s.add_dependency(%q<lre>, [">= 0"])
|
85
|
+
s.add_dependency(%q<rr>, [">= 0"])
|
86
|
+
end
|
87
|
+
else
|
88
|
+
s.add_dependency(%q<mharris_ext>, [">= 0"])
|
89
|
+
s.add_dependency(%q<andand>, [">= 0"])
|
90
|
+
s.add_dependency(%q<grit>, [">= 0"])
|
91
|
+
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
92
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
93
|
+
s.add_dependency(%q<bundler>, [">= 1.0"])
|
94
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.7"])
|
95
|
+
s.add_dependency(%q<guard>, [">= 0"])
|
96
|
+
s.add_dependency(%q<guard-rspec>, [">= 0"])
|
97
|
+
s.add_dependency(%q<guard-spork>, [">= 0"])
|
98
|
+
s.add_dependency(%q<rb-fsevent>, ["~> 0.9"])
|
99
|
+
s.add_dependency(%q<lre>, [">= 0"])
|
100
|
+
s.add_dependency(%q<rr>, [">= 0"])
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
describe "Command" do
|
6
|
+
it "smoke" do
|
7
|
+
2.should == 2
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "cycle with name" do
|
11
|
+
let(:full_command) do
|
12
|
+
"cycle -n ezq"
|
13
|
+
end
|
14
|
+
let(:command) do
|
15
|
+
res = ProjectGroup::Command.new
|
16
|
+
res.parse! full_command.split(" ")
|
17
|
+
res
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'group name' do
|
21
|
+
command.group_name.should == 'ezq'
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'cmd' do
|
25
|
+
command.cmd.should == 'cycle'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
end
|
data/spec/config_spec.rb
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
shared_context "config" do
|
4
|
+
let(:configs) do
|
5
|
+
ProjectGroup::Configs.instance
|
6
|
+
end
|
7
|
+
let(:local_config_body) { "" }
|
8
|
+
let(:config_body) { "" }
|
9
|
+
before(:all) do
|
10
|
+
File.create("#{MakeInitial.tmp_dir}/configs/ezq.rb", config_body)
|
11
|
+
File.create("#{MakeInitial.tmp_dir}/tmp1/.project_group.rb", local_config_body)
|
12
|
+
|
13
|
+
Dir.chdir("#{MakeInitial.tmp_dir}/tmp1") do
|
14
|
+
c = ProjectGroup::Configs.instance!
|
15
|
+
c.dir = "#{MakeInitial.tmp_dir}/configs"
|
16
|
+
c.load!
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
let(:group_config) do
|
21
|
+
configs.group_configs.first
|
22
|
+
end
|
23
|
+
let(:group) do
|
24
|
+
configs.groups.first
|
25
|
+
end
|
26
|
+
let(:project) do
|
27
|
+
configs.projects.first
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "ProjectGroup::Config" do
|
32
|
+
describe 'single project' do
|
33
|
+
include_context "config"
|
34
|
+
let(:config_body) do
|
35
|
+
'ProjectGroup::Configs.project "ezq" do |p|
|
36
|
+
p.path "abc"
|
37
|
+
end'
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'created something' do
|
41
|
+
configs.projects.size.should == 1
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'name' do
|
45
|
+
project.name.should == 'ezq'
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'path' do
|
49
|
+
project.path.should == 'abc'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "two projects and a group" do
|
54
|
+
include_context "config"
|
55
|
+
let(:config_body) do
|
56
|
+
'ProjectGroup::Configs.project "ezq" do |p|
|
57
|
+
p.path "/code/orig/ezq"
|
58
|
+
end
|
59
|
+
|
60
|
+
ProjectGroup::Configs.project "ezqweb" do |p|
|
61
|
+
p.path "/code/orig/ezqweb"
|
62
|
+
end
|
63
|
+
|
64
|
+
ProjectGroup::Configs.group "ezq" do |p|
|
65
|
+
p.project "ezq"
|
66
|
+
p.project "ezqweb"
|
67
|
+
end'
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'projects count' do
|
71
|
+
configs.projects.size.should == 2
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'groups count' do
|
75
|
+
configs.groups.count.should == 1
|
76
|
+
configs.group_configs.count.should == 1
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'group project names' do
|
80
|
+
group_config.project_names.sort.should == %w(ezq ezqweb).sort
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'group projects' do
|
84
|
+
group.singles.map { |x| x.path }.sort.should == ["/code/orig/ezq","/code/orig/ezqweb"].sort
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'group projects name' do
|
88
|
+
group.singles.map { |x| x.name }.sort.should == %w(ezq ezqweb).sort
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe "inline project" do
|
93
|
+
include_context "config"
|
94
|
+
let(:config_body) do
|
95
|
+
'ProjectGroup::Configs.group "ezq" do |g|
|
96
|
+
g.project "ezq" do |p|
|
97
|
+
p.path "/code/orig/ezq"
|
98
|
+
end
|
99
|
+
end'
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'project path' do
|
103
|
+
group.singles.map { |x| x.path }.should == ['/code/orig/ezq']
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
describe "local project file" do
|
108
|
+
include_context "config"
|
109
|
+
let(:local_config_body) do
|
110
|
+
'ProjectGroup::Configs.group "ezq" do |g|
|
111
|
+
g.project "ezq" do |p|
|
112
|
+
p.path "/code/orig/ezq"
|
113
|
+
end
|
114
|
+
end'
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'projects count' do
|
118
|
+
configs.projects.size.should == 1
|
119
|
+
end
|
120
|
+
|
121
|
+
it 'local group' do
|
122
|
+
configs.local_group.name.should == 'ezq'
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|
data/spec/group_spec.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "ProjectGroup::Group" do
|
4
|
+
describe "basic" do
|
5
|
+
include_context "project"
|
6
|
+
|
7
|
+
project "foo" do
|
8
|
+
create "a.txt"
|
9
|
+
push
|
10
|
+
end
|
11
|
+
|
12
|
+
project "bar" do
|
13
|
+
create "a.txt"
|
14
|
+
File.create "b.txt","zzz"
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'uncommitted files' do
|
18
|
+
group.uncommitted_files.size.should == 1
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'doesnt need push' do
|
22
|
+
group.should be_needs_push
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'projects size' do
|
26
|
+
group.singles.size.should == 2
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
if false
|
31
|
+
describe "load from file" do
|
32
|
+
include_context "project"
|
33
|
+
|
34
|
+
project "foo" do
|
35
|
+
create "a.txt"
|
36
|
+
push
|
37
|
+
end
|
38
|
+
|
39
|
+
project "bar" do
|
40
|
+
create "a.txt"
|
41
|
+
File.create "b.txt","zzz"
|
42
|
+
end
|
43
|
+
|
44
|
+
before(:all) do
|
45
|
+
str = "abc"
|
46
|
+
File.create "#{MakeInitial.tmp_dir}/groups/ezq.rb", str
|
47
|
+
end
|
48
|
+
|
49
|
+
let(:group) do
|
50
|
+
ProjectGroup::Group.load_by_name("ezq")
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'smoke' do
|
54
|
+
group.singles.size.should == 2
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|