yjncopycat 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 113a1c12379294b8672d8859f3ef38647b1d2826050772b6f724f68e464e54ed
4
- data.tar.gz: 79b59f1e2aa7c66b71e442995e7d564269b51e6df522d39b37f9d7fb91b2a5d3
3
+ metadata.gz: 39fad83311c20c7aa00c6bf4cdc08428d92967b64e82cad9b06a345765ab8a2f
4
+ data.tar.gz: e9c1832c894efc0e5b63e31356ee62ed64089c54657260cf17bc26118f994f85
5
5
  SHA512:
6
- metadata.gz: 01ee7d45d914cbf1437b8ad8779845b2a335dd40967173787d65c4eda372d737a6214cd3f33950c5dcab3ab9ee08adb1196b4896db7bd40c99855e3b27abdc0e
7
- data.tar.gz: c9b5c8e03145a665154448206535497fd97881d74c36c0c89b2345451ca5eac6220b5adf80e9cd748b546fec8a19d2e603e54bbf50112f0cc1e76cf09f9bc9de
6
+ metadata.gz: 70e9d8dbcb98e8b6adf5bf8bc1bb903d41c598a9d9f23a2b9ba4aa6cc65288734eca46cfa33524b067ab5b73740d50c962321277e9f3627749515ee51591a37d
7
+ data.tar.gz: 7d4f77a50a7aecb62f85d4abfc55e1171828602fe6f48df59cd575d2e68d88374e7053ab84d03fab8c0bd2a2431a479ef4612ec80d48aa364d68a08795d54cdb
data/bin/yjncopycat CHANGED
@@ -4,12 +4,18 @@ require 'colored2'
4
4
  require 'yjncopycat/commandparser.rb'
5
5
  require 'yjncopycat/xcodeprojectcloner.rb'
6
6
  require 'yjncopycat/version.rb'
7
+ require 'yjncopycat/specfileparser.rb'
7
8
 
8
9
  module YJNCopycat
9
10
  USAGE = 'USAGE: $ yjncopycat --url <iOS_project_github_url> --name <new_project_name>'.yellow
11
+ SPEC_FILE_NAME = 'Copyfile'
10
12
  end
11
13
 
12
- options = YJNCopycat::CommandParser.parse(ARGV)
14
+ if ARGV.length == 1 && ARGV.first == 'run'
15
+ options = YJNCopycat::SpecFileParser.run
16
+ else
17
+ options = YJNCopycat::CommandParser.parse(ARGV)
18
+ end
13
19
  puts ''
14
20
  YJNCopycat::XcodeProjectCloner.new(options).createClone
15
21
  puts ''
@@ -1,6 +1,7 @@
1
1
  require 'optparse'
2
2
  require 'colored2'
3
3
  require 'uri'
4
+ require 'pp'
4
5
 
5
6
  module YJNCopycat
6
7
  class CommandParser
@@ -22,12 +23,16 @@ module YJNCopycat
22
23
  end
23
24
  parser.on_tail('-v', '--version', 'Shows version') do
24
25
  puts YJNCopycat::VERSION
25
- exit
26
+ exit 0
26
27
  end
27
28
  parser.on_tail('-h', '--help', 'Shows simple usage instructions.') do
28
29
  puts YJNCopycat::USAGE
29
30
  exit 0
30
31
  end
32
+ parser.on_tail('copy', '--copy', "Start copying project based on a spec file.") do
33
+ options = YJNCopycat::SpecFileParser.run
34
+ pp = options
35
+ end
31
36
  end
32
37
 
33
38
  begin
@@ -59,6 +64,11 @@ module YJNCopycat
59
64
  exit 1
60
65
  end
61
66
 
67
+ unless options[:name] =~ /\w/
68
+ puts "ERROR: Make sure there's no whitespace in --name parameter.".red
69
+ exit 0
70
+ end
71
+
62
72
  options
63
73
  end
64
74
  end
@@ -0,0 +1,55 @@
1
+ require 'colored2'
2
+ require 'uri'
3
+
4
+ module YJNCopycat
5
+ class SpecFileParser
6
+ PARSER_ERROR_MESSAGE = "Invalid spec file format."
7
+
8
+ def self.run
9
+ puts "Reading from #{YJNCopycat::SPEC_FILE_NAME} in current directory...".yellow
10
+ unless File.file?("./#{YJNCopycat::SPEC_FILE_NAME}")
11
+ puts "ERROR: Unable to locate #{YJNCopycat::SPEC_FILE_NAME}!".red
12
+ exit 0
13
+ end
14
+ contents = File.open("./#{YJNCopycat::SPEC_FILE_NAME}").read
15
+ lines = contents.split("\n")
16
+
17
+ for line in lines
18
+ if line =~ /name (.*)/
19
+ name = line.gsub(' ', '').sub('name', '')
20
+ end
21
+
22
+ if line =~ /url (.*)/
23
+ url = line.gsub(' ', '').sub('url', '')
24
+ end
25
+ end
26
+
27
+ if name.nil?
28
+ puts "#{PARSER_ERROR_MESSAGE} Missing 'name' parameter.".red
29
+ exit 0
30
+ end
31
+
32
+ if name.length < 3
33
+ puts "#{PARSER_ERROR_MESSAGE} Make sure 'name' is at least 3 characters.".red
34
+ exit 0
35
+ end
36
+
37
+ unless name =~ /\w/
38
+ puts "#{PARSER_ERROR_MESSAGE} Make sure there's no whitespace in 'name' parameter.".red
39
+ exit 0
40
+ end
41
+
42
+ if url.nil?
43
+ puts "#{PARSER_ERROR_MESSAGE} Missing 'url' parameter.".red
44
+ exit 0
45
+ end
46
+
47
+ unless url =~ URI::regexp
48
+ puts "#{PARSER_ERROR_MESSAGE} Incorrect value for 'url' parameter. \nMake sure it is a valid git repo for your iOS project.".red
49
+ exit 0
50
+ end
51
+
52
+ { :name => name, :url => url}
53
+ end
54
+ end
55
+ end
@@ -1,3 +1,3 @@
1
1
  module YJNCopycat
2
- VERSION = "0.1.3"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yjncopycat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Feb Dela Cruz
@@ -56,6 +56,7 @@ files:
56
56
  - bin/setup
57
57
  - bin/yjncopycat
58
58
  - lib/yjncopycat/commandparser.rb
59
+ - lib/yjncopycat/specfileparser.rb
59
60
  - lib/yjncopycat/version.rb
60
61
  - lib/yjncopycat/xcodeprojectcloner.rb
61
62
  - yjncopycat.gemspec