mirror of
https://github.com/zhigang1992/synx.git
synced 2026-01-12 17:52:53 +08:00
rename synxronize to synx
This commit is contained in:
2
Gemfile
2
Gemfile
@@ -1,4 +1,4 @@
|
||||
source 'https://rubygems.org'
|
||||
|
||||
# Specify your gem's dependencies in synxronize.gemspec
|
||||
# Specify your gem's dependencies in synx.gemspec
|
||||
gemspec
|
||||
|
||||
10
README.md
10
README.md
@@ -1,4 +1,4 @@
|
||||
# Synxronize
|
||||
# Synx
|
||||
|
||||
A command-line tool that reorganizes your project files into folders that match Xcode's group structure.
|
||||
|
||||
@@ -6,7 +6,7 @@ A command-line tool that reorganizes your project files into folders that match
|
||||
|
||||
Add this line to your application's Gemfile:
|
||||
|
||||
gem 'synxronize'
|
||||
gem 'synx'
|
||||
|
||||
And then execute:
|
||||
|
||||
@@ -14,13 +14,13 @@ And then execute:
|
||||
|
||||
Or install it yourself as:
|
||||
|
||||
$ gem install synxronize
|
||||
$ gem install synx
|
||||
|
||||
## Usage
|
||||
|
||||
Execute the command on yor project to have it reorganize the files on the file system:
|
||||
|
||||
$ synxronize path/to/my/project.xcodeproj
|
||||
$ synx path/to/my/project.xcodeproj
|
||||
|
||||
It may have confused cocoapods. Pod install, if you use them:
|
||||
|
||||
@@ -31,7 +31,7 @@ You're good to go!
|
||||
|
||||
## Contributing
|
||||
|
||||
1. Fork it ( https://github.com/[my-github-username]/synxronize/fork )
|
||||
1. Fork it ( https://github.com/[my-github-username]/synx/fork )
|
||||
2. Create your feature branch (`git checkout -b my-new-feature`)
|
||||
3. Commit your changes (`git commit -am 'Add some feature'`)
|
||||
4. Push to the branch (`git push origin my-new-feature`)
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require 'clamp'
|
||||
require File.join(File.dirname(__FILE__), '..', 'lib', 'synxronize')
|
||||
require File.join(File.dirname(__FILE__), '..', 'lib', 'synx')
|
||||
|
||||
Clamp do
|
||||
|
||||
parameter "xcodeproj", "Path to the xcodeproj", :attribute_name => :xcodeproj_path
|
||||
|
||||
def execute
|
||||
Synxronize::Project.open(xcodeproj_path).sync
|
||||
Synx::Project.open(xcodeproj_path).sync
|
||||
end
|
||||
|
||||
end
|
||||
13
lib/synx.rb
Normal file
13
lib/synx.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
require "synx/version"
|
||||
require "synx/project"
|
||||
require "synx/pbx_file_reference"
|
||||
require "synx/pbx_group"
|
||||
require "synx/abstract_object"
|
||||
require "synx/pbx_native_target"
|
||||
require "synx/pbx_variant_group"
|
||||
require "synx/tabber"
|
||||
|
||||
require "colored"
|
||||
|
||||
module Synx
|
||||
end
|
||||
@@ -21,7 +21,7 @@ module Xcodeproj
|
||||
|
||||
output
|
||||
else
|
||||
Synxronize::Tabber.puts "skipped #{basename}".red
|
||||
Synx::Tabber.puts "skipped #{basename}".red
|
||||
end
|
||||
end
|
||||
|
||||
@@ -30,7 +30,7 @@ module Xcodeproj
|
||||
removed_from_groups = "(had multiple parent groups, removed from groups: #{@removed_from_groups.join(", ")})" if @removed_from_groups.count > 0
|
||||
str_output = "#{basename} #{build_settings_ammended} #{removed_from_groups}"
|
||||
str_output = str_output.yellow if removed_from_groups || build_settings_ammended
|
||||
Synxronize::Tabber.puts str_output
|
||||
Synx::Tabber.puts str_output
|
||||
end
|
||||
|
||||
def should_sync?
|
||||
@@ -7,15 +7,15 @@ module Xcodeproj
|
||||
|
||||
def sync
|
||||
unless excluded_from_sync?
|
||||
Synxronize::Tabber.puts "#{basename}/".green
|
||||
Synxronize::Tabber.increase
|
||||
Synx::Tabber.puts "#{basename}/".green
|
||||
Synx::Tabber.increase
|
||||
|
||||
work_pathname.mkpath
|
||||
files.each { |pbx_file| pbx_file.sync(self) }
|
||||
all_groups.each { |group| group.sync }
|
||||
sync_path
|
||||
|
||||
Synxronize::Tabber.decrease
|
||||
Synx::Tabber.decrease
|
||||
end
|
||||
end
|
||||
|
||||
@@ -25,8 +25,8 @@ module Xcodeproj
|
||||
|
||||
def move_entries_not_in_xcodeproj
|
||||
unless excluded_from_sync?
|
||||
Synxronize::Tabber.increase
|
||||
Synxronize::Tabber.puts "#{basename}/".green
|
||||
Synx::Tabber.increase
|
||||
Synx::Tabber.puts "#{basename}/".green
|
||||
Dir[real_path.to_s + "/*"].each do |entry|
|
||||
entry_pathname = real_path + entry
|
||||
unless has_entry?(entry_pathname)
|
||||
@@ -36,7 +36,7 @@ module Xcodeproj
|
||||
end
|
||||
end
|
||||
all_groups.each(&:move_entries_not_in_xcodeproj)
|
||||
Synxronize::Tabber.decrease
|
||||
Synx::Tabber.decrease
|
||||
end
|
||||
end
|
||||
|
||||
@@ -70,7 +70,7 @@ module Xcodeproj
|
||||
output = "#{output} (source file that is not included in Xcode project)".yellow
|
||||
end
|
||||
|
||||
Synxronize::Tabber.puts output
|
||||
Synx::Tabber.puts output
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,10 +1,10 @@
|
||||
require 'fileutils'
|
||||
require 'xcodeproj'
|
||||
|
||||
module Synxronize
|
||||
module Synx
|
||||
class Project < Xcodeproj::Project
|
||||
|
||||
SYNXRONIZE_DIR = File.join(ENV["HOME"], '.synxronize')
|
||||
SYNXRONIZE_DIR = File.join(ENV["HOME"], '.synx')
|
||||
private_constant :SYNXRONIZE_DIR
|
||||
|
||||
DEFAULT_EXCLUSIONS = %W(/Libraries /Frameworks /Products)
|
||||
@@ -19,14 +19,14 @@ module Synxronize
|
||||
end
|
||||
|
||||
def sync
|
||||
Synxronize::Tabber.increase
|
||||
Synxronize::Tabber.puts "Syncing files that are included in Xcode project...".bold.white
|
||||
Synx::Tabber.increase
|
||||
Synx::Tabber.puts "Syncing files that are included in Xcode project...".bold.white
|
||||
main_group.all_groups.each(&:sync)
|
||||
puts "\n\n"
|
||||
Synxronize::Tabber.puts "Syncing files that are not included in Xcode project..".bold.white
|
||||
Synx::Tabber.puts "Syncing files that are not included in Xcode project..".bold.white
|
||||
main_group.all_groups.each(&:move_entries_not_in_xcodeproj)
|
||||
transplant_work_project
|
||||
Synxronize::Tabber.decrease
|
||||
Synx::Tabber.decrease
|
||||
save
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module Synxronize
|
||||
module Synx
|
||||
class Tabber
|
||||
|
||||
@@tabbing = ""
|
||||
@@ -1,3 +1,3 @@
|
||||
module Synxronize
|
||||
module Synx
|
||||
VERSION = "0.0.1"
|
||||
end
|
||||
@@ -1,13 +0,0 @@
|
||||
require "synxronize/version"
|
||||
require "synxronize/project"
|
||||
require "synxronize/pbx_file_reference"
|
||||
require "synxronize/pbx_group"
|
||||
require "synxronize/abstract_object"
|
||||
require "synxronize/pbx_native_target"
|
||||
require "synxronize/pbx_variant_group"
|
||||
require "synxronize/tabber"
|
||||
|
||||
require "colored"
|
||||
|
||||
module Synxronize
|
||||
end
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'bundler/setup'
|
||||
Bundler.setup
|
||||
|
||||
require 'synxronize'
|
||||
require 'synx'
|
||||
require 'pry'
|
||||
|
||||
RSpec.configure do |config|
|
||||
|
||||
@@ -5,7 +5,7 @@ require 'pathname'
|
||||
require 'yaml'
|
||||
|
||||
|
||||
describe Synxronize::Project do
|
||||
describe Synx::Project do
|
||||
|
||||
DUMMY_SYNX_PATH = File.join(File.dirname(__FILE__), '..', 'dummy')
|
||||
DUMMY_SYNX_TEST_PATH = File.join(File.dirname(__FILE__), '..', 'test_dummy')
|
||||
@@ -14,7 +14,7 @@ describe Synxronize::Project do
|
||||
before(:all) do
|
||||
FileUtils.rm_rf(DUMMY_SYNX_TEST_PATH)
|
||||
FileUtils.cp_r(DUMMY_SYNX_PATH, DUMMY_SYNX_TEST_PATH)
|
||||
DUMMY_SYNX_TEST_PROJECT = Synxronize::Project.open(DUMMY_SYNX_TEST_PROJECT_PATH)
|
||||
DUMMY_SYNX_TEST_PROJECT = Synx::Project.open(DUMMY_SYNX_TEST_PROJECT_PATH)
|
||||
end
|
||||
|
||||
after(:all) do
|
||||
@@ -96,7 +96,7 @@ describe Synxronize::Project do
|
||||
before(:each) { DUMMY_SYNX_TEST_PROJECT.instance_variable_set("@work_root_pathname", nil) }
|
||||
|
||||
it "should return the pathname to the directory synxchronize will do its work in" do
|
||||
expected = Pathname(Synxronize::Project.const_get(:SYNXRONIZE_DIR)) + "test_dummy"
|
||||
expected = Pathname(Synx::Project.const_get(:SYNXRONIZE_DIR)) + "test_dummy"
|
||||
DUMMY_SYNX_TEST_PROJECT.send(:work_root_pathname).realpath.should eq(expected.realpath)
|
||||
end
|
||||
|
||||
64
spec/synx/tabber_spec.rb
Normal file
64
spec/synx/tabber_spec.rb
Normal file
@@ -0,0 +1,64 @@
|
||||
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
||||
|
||||
describe Synx::Tabber do
|
||||
|
||||
after(:each) do
|
||||
Synx::Tabber.reset
|
||||
end
|
||||
|
||||
describe "::increase" do
|
||||
it "should default to increasing tabbing by 1" do
|
||||
Synx::Tabber.increase
|
||||
expect(Synx::Tabber.current).to eq 1
|
||||
Synx::Tabber.increase
|
||||
expect(Synx::Tabber.current).to eq 2
|
||||
end
|
||||
|
||||
it "should indent by the amount passed in" do
|
||||
Synx::Tabber.increase(3)
|
||||
expect(Synx::Tabber.current).to eq 3
|
||||
Synx::Tabber.increase(5)
|
||||
expect(Synx::Tabber.current).to eq 8
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "::decrease" do
|
||||
it "should default to decreasing tabbing by 1" do
|
||||
Synx::Tabber.increase
|
||||
Synx::Tabber.increase
|
||||
expect(Synx::Tabber.current).to eq 2
|
||||
Synx::Tabber.decrease
|
||||
expect(Synx::Tabber.current).to eq 1
|
||||
end
|
||||
|
||||
it "should not do any more decreasing past 0 tabbing" do
|
||||
Synx::Tabber.increase
|
||||
Synx::Tabber.increase
|
||||
expect(Synx::Tabber.current).to eq 2
|
||||
Synx::Tabber.decrease
|
||||
expect(Synx::Tabber.current).to eq 1
|
||||
Synx::Tabber.decrease
|
||||
expect(Synx::Tabber.current).to eq 0
|
||||
Synx::Tabber.decrease
|
||||
expect(Synx::Tabber.current).to eq 0
|
||||
Synx::Tabber.increase
|
||||
expect(Synx::Tabber.current).to eq 1
|
||||
end
|
||||
end
|
||||
|
||||
describe "::puts" do
|
||||
it "should call system's puts on the string, appending the appropraite indentation" do
|
||||
Synx::Tabber.increase(3)
|
||||
expect(Kernel).to receive(:puts).with(" Hello, world.")
|
||||
Synx::Tabber.puts("Hello, world.")
|
||||
end
|
||||
end
|
||||
|
||||
describe "::a_single_tab" do
|
||||
it "should be two spaces" do
|
||||
expect(Synx::Tabber.send(:a_single_tab)).to eq " "
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,64 +0,0 @@
|
||||
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
||||
|
||||
describe Synxronize::Tabber do
|
||||
|
||||
after(:each) do
|
||||
Synxronize::Tabber.reset
|
||||
end
|
||||
|
||||
describe "::increase" do
|
||||
it "should default to increasing tabbing by 1" do
|
||||
Synxronize::Tabber.increase
|
||||
expect(Synxronize::Tabber.current).to eq 1
|
||||
Synxronize::Tabber.increase
|
||||
expect(Synxronize::Tabber.current).to eq 2
|
||||
end
|
||||
|
||||
it "should indent by the amount passed in" do
|
||||
Synxronize::Tabber.increase(3)
|
||||
expect(Synxronize::Tabber.current).to eq 3
|
||||
Synxronize::Tabber.increase(5)
|
||||
expect(Synxronize::Tabber.current).to eq 8
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "::decrease" do
|
||||
it "should default to decreasing tabbing by 1" do
|
||||
Synxronize::Tabber.increase
|
||||
Synxronize::Tabber.increase
|
||||
expect(Synxronize::Tabber.current).to eq 2
|
||||
Synxronize::Tabber.decrease
|
||||
expect(Synxronize::Tabber.current).to eq 1
|
||||
end
|
||||
|
||||
it "should not do any more decreasing past 0 tabbing" do
|
||||
Synxronize::Tabber.increase
|
||||
Synxronize::Tabber.increase
|
||||
expect(Synxronize::Tabber.current).to eq 2
|
||||
Synxronize::Tabber.decrease
|
||||
expect(Synxronize::Tabber.current).to eq 1
|
||||
Synxronize::Tabber.decrease
|
||||
expect(Synxronize::Tabber.current).to eq 0
|
||||
Synxronize::Tabber.decrease
|
||||
expect(Synxronize::Tabber.current).to eq 0
|
||||
Synxronize::Tabber.increase
|
||||
expect(Synxronize::Tabber.current).to eq 1
|
||||
end
|
||||
end
|
||||
|
||||
describe "::puts" do
|
||||
it "should call system's puts on the string, appending the appropraite indentation" do
|
||||
Synxronize::Tabber.increase(3)
|
||||
expect(Kernel).to receive(:puts).with(" Hello, world.")
|
||||
Synxronize::Tabber.puts("Hello, world.")
|
||||
end
|
||||
end
|
||||
|
||||
describe "::a_single_tab" do
|
||||
it "should be two spaces" do
|
||||
expect(Synxronize::Tabber.send(:a_single_tab)).to eq " "
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,11 +1,11 @@
|
||||
# coding: utf-8
|
||||
lib = File.expand_path('../lib', __FILE__)
|
||||
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
||||
require 'synxronize/version'
|
||||
require 'synx/version'
|
||||
|
||||
Gem::Specification.new do |spec|
|
||||
spec.name = "synxronize"
|
||||
spec.version = Synxronize::VERSION
|
||||
spec.name = "synx"
|
||||
spec.version = Synx::VERSION
|
||||
spec.authors = ["Mark Larsen"]
|
||||
spec.email = ["mark@venmo.com"]
|
||||
spec.summary = %q{A command-line tool that reorganizes your project files into folders that match Xcode's group structure.}
|
||||
Reference in New Issue
Block a user