generamba 0.7.2 → 0.7.3

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
  SHA1:
3
- metadata.gz: b25fd879d1e1ee8d3207d476da127fcb08fcfdd5
4
- data.tar.gz: eed7ef7a0a606908dc0bf9833ab653b9ad74e993
3
+ metadata.gz: 7dc501f252222516eac75ae4ce0111181043e982
4
+ data.tar.gz: 4e4b25ff2df471bd2c4e1daa8261787749cffca2
5
5
  SHA512:
6
- metadata.gz: 7b73f00f33b102a49e4c76cd5a2442533827a5eabb9705d3f9bef6c0a98ab94bd96a52be8a3518921ca8d803e8b81f15647e10741eb4a898cc26dde8de191942
7
- data.tar.gz: a81ba5d21f02796dd6ef4f20baa93538325fee01f9afcc7eb90208509506f8ece559badb1b82d271a36a18ccaa702ea22235f8f57374d92df1ba74d63ffe8bc6
6
+ metadata.gz: d865768cd0dc64bf901bce59b128acea1fb44d3540c6c0eb9b85093b52bc7a1a78428650d5bdf954733cd9a37ebb30d6117f3b34d2aa0622ff077e2330e2a745
7
+ data.tar.gz: b663fa970dd38613403b5ae00e5923275123455a985874700c8be232d0ca459d9b6eaf4e95399c806f7f56095e9df30442d0dc8ddf5a050189404d7e4108e602
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- generamba (0.7.1)
4
+ generamba (0.7.2)
5
+ cocoapods-core (= 0.39.0)
5
6
  git (= 1.2.9.1)
6
7
  liquid (= 3.0.6)
7
8
  thor (= 0.19.1)
@@ -18,14 +19,20 @@ GEM
18
19
  thread_safe (~> 0.3, >= 0.3.4)
19
20
  tzinfo (~> 1.1)
20
21
  claide (0.9.1)
22
+ cocoapods-core (0.39.0)
23
+ activesupport (>= 4.0.2)
24
+ fuzzy_match (~> 2.0.4)
25
+ nap (~> 1.0)
21
26
  colored (1.2)
22
27
  diff-lcs (1.2.5)
23
28
  fakefs (0.6.7)
29
+ fuzzy_match (2.0.4)
24
30
  git (1.2.9.1)
25
31
  i18n (0.7.0)
26
32
  json (1.8.3)
27
33
  liquid (3.0.6)
28
- minitest (5.8.3)
34
+ minitest (5.8.4)
35
+ nap (1.0.0)
29
36
  rake (10.4.2)
30
37
  rspec (3.3.0)
31
38
  rspec-core (~> 3.3.0)
@@ -25,6 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.add_runtime_dependency 'liquid', '3.0.6'
26
26
  spec.add_runtime_dependency 'tilt', '2.0.1'
27
27
  spec.add_runtime_dependency 'git', '1.2.9.1'
28
+ spec.add_runtime_dependency 'cocoapods-core', '0.39.0'
28
29
 
29
30
  spec.add_development_dependency 'bundler', '~> 1.10'
30
31
  spec.add_development_dependency 'rake', '~> 10.0'
@@ -1,5 +1,3 @@
1
- require 'xcodeproj'
2
-
3
1
  module Generamba
4
2
  require 'generamba/constants/constants.rb'
5
3
  require 'generamba/constants/rambafile_constants.rb'
@@ -1,6 +1,7 @@
1
1
  require 'thor'
2
2
  require 'generamba/helpers/rambafile_validator.rb'
3
3
  require 'generamba/helpers/xcodeproj_helper.rb'
4
+ require 'generamba/helpers/dependency_checker.rb'
4
5
 
5
6
  module Generamba::CLI
6
7
  class Application < Thor
@@ -40,6 +41,8 @@ module Generamba::CLI
40
41
  template = ModuleTemplate.new(template_name)
41
42
  code_module = CodeModule.new(module_name, module_description, rambafile, options)
42
43
 
44
+ DependencyChecker.check_all_required_dependencies_has_in_podfile(template.dependencies, code_module.podfile_path)
45
+
43
46
  project = XcodeprojHelper.obtain_project(code_module.xcodeproj_path)
44
47
  module_group_already_exists = XcodeprojHelper.module_with_group_path_already_exists(project, code_module.module_group_path)
45
48
 
@@ -1,4 +1,5 @@
1
- require 'generamba/template/helpers/catalog_downloader.rb'
1
+ require 'generamba/template/helpers/catalog_downloader'
2
+ require 'generamba/template/helpers/catalog_template_list_helper'
2
3
 
3
4
  module Generamba::CLI
4
5
  class Template < Thor
@@ -7,15 +8,18 @@ module Generamba::CLI
7
8
  desc 'list', 'Prints out the list of all templates available in the shared GitHub catalog'
8
9
  def list
9
10
  downloader = CatalogDownloader.new
10
- generamba_catalog_path = downloader.download_catalog(GENERAMBA_CATALOG_NAME, RAMBLER_CATALOG_REPO)
11
+ catalog_template_list_helper = CatalogTemplateListHelper.new
11
12
 
12
- generamba_catalog_path.children.select { |child|
13
- child.directory? && child.split.last.to_s[0] != '.'
14
- }.map { |template_path|
15
- template_path.split.last.to_s
16
- }.each { |template_name|
13
+ templates = []
14
+ catalog_paths = downloader.update_all_catalogs_and_return_filepaths
15
+ catalog_paths.each do |path|
16
+ templates += catalog_template_list_helper.obtain_all_templates_from_a_catalog(path)
17
+ templates = templates.uniq
18
+ end
19
+
20
+ templates.each do |template_name|
17
21
  puts(template_name)
18
- }
22
+ end
19
23
  end
20
24
  end
21
25
  end
@@ -1,4 +1,5 @@
1
1
  require 'generamba/template/helpers/catalog_downloader.rb'
2
+ require 'generamba/template/helpers/catalog_template_search_helper'
2
3
 
3
4
  module Generamba::CLI
4
5
  class Template < Thor
@@ -7,15 +8,17 @@ module Generamba::CLI
7
8
  desc 'search [SEARCH_STRING]', 'Searches a template with a given name in the shared GitHub catalog'
8
9
  def search(term)
9
10
  downloader = CatalogDownloader.new
10
- generamba_catalog_path = downloader.download_catalog(GENERAMBA_CATALOG_NAME, RAMBLER_CATALOG_REPO)
11
+ catalog_template_search_helper = CatalogTemplateSearchHelper.new
11
12
 
12
- generamba_catalog_path.children.select { |child|
13
- child.directory? && child.split.last.to_s[0] != '.'
14
- }.map { |template_path|
15
- template_path.split.last.to_s
16
- }.select { |template_name|
17
- template_name.include?(term)
18
- }.map { |template_name|
13
+ catalog_paths = downloader.update_all_catalogs_and_return_filepaths
14
+
15
+ templates = []
16
+ catalog_paths.each do |path|
17
+ templates += catalog_template_search_helper.search_templates_in_a_catalog(path, term)
18
+ templates = templates.uniq
19
+ end
20
+
21
+ templates.map { |template_name|
19
22
  keywords = term.squeeze.strip.split(' ').compact.uniq
20
23
  matcher = Regexp.new('(' + keywords.join('|') + ')')
21
24
  template_name.gsub(matcher) { |match| "#{match}".yellow }
@@ -15,7 +15,8 @@ module Generamba
15
15
  :test_file_path,
16
16
  :test_group_path,
17
17
  :project_targets,
18
- :test_targets
18
+ :test_targets,
19
+ :podfile_path
19
20
 
20
21
  def initialize(name, description, rambafile, options)
21
22
  # Base initialization
@@ -56,6 +57,8 @@ module Generamba
56
57
  @module_group_path = Pathname.new(options[:module_path]).join(@name) if options[:module_path]
57
58
  @test_file_path = Pathname.new(options[:test_path]).join(@name) if options[:test_path]
58
59
  @test_group_path = Pathname.new(options[:test_path]).join(@name) if options[:test_path]
60
+
61
+ @podfile_path = rambafile[PODFILE_PATH_KEY] if rambafile[PODFILE_PATH_KEY] != nil
59
62
  end
60
63
  end
61
64
  end
@@ -4,16 +4,17 @@ module Generamba
4
4
 
5
5
  # Represents a single Generamba module template
6
6
  class ModuleTemplate
7
- attr_reader :template_name, :template_path, :code_files, :test_files
7
+ attr_reader :template_name, :template_path, :code_files, :test_files, :dependencies
8
8
 
9
9
  def initialize(name)
10
10
  spec_path = TemplateHelper.obtain_spec(name)
11
11
  spec = YAML.load_file(spec_path)
12
-
12
+
13
13
  @code_files = spec[TEMPLATE_CODE_FILES_KEY]
14
14
  @test_files = spec[TEMPLATE_TEST_FILES_KEY]
15
15
  @template_name = spec[TEMPLATE_NAME_KEY]
16
16
  @template_path = TemplateHelper.obtain_path(name)
17
+ @dependencies = spec[TEMPLATE_DEPENDENCIES_KEY]
17
18
  end
18
19
  end
19
20
  end
@@ -0,0 +1,36 @@
1
+ require 'cocoapods-core'
2
+
3
+ module Generamba
4
+
5
+ # Provides methods for check dependencies from rambaspec in podfile
6
+ class DependencyChecker
7
+
8
+ # Check podfile for dependencies
9
+ # @param dependencies [Array] Array of dependencies name
10
+ # @param podfile_path [String] String of Podfile path
11
+ #
12
+ # @return [void]
13
+ def self.check_all_required_dependencies_has_in_podfile(dependencies, podfile_path)
14
+ return if !dependencies or dependencies.count == 0 or !podfile_path
15
+
16
+ dependencies_names = []
17
+ Pod::Podfile.from_file(Pathname.new(podfile_path)).dependencies.each do |dependency|
18
+ dependencies_names.push(dependency.name.gsub(/ .*/, ''))
19
+ end
20
+
21
+ not_existing_dependency = []
22
+
23
+ dependencies.each do |dependency_name|
24
+ unless dependencies_names.include?(dependency_name)
25
+ not_existing_dependency.push(dependency_name)
26
+ end
27
+ end
28
+
29
+ if not_existing_dependency.count > 0
30
+ puts "[Warning] Dependencies #{not_existing_dependency} missed in Podfile".yellow
31
+ end
32
+ end
33
+
34
+ end
35
+
36
+ end
@@ -5,6 +5,33 @@ module Generamba
5
5
  # Provides the functionality to download template catalogs from the remote repository
6
6
  class CatalogDownloader
7
7
 
8
+ # Updates all of the template catalogs and returns their filepaths.
9
+ # If there is a Rambafile in the current directory, it also updates all of the catalogs specified there.
10
+ #
11
+ # @return [Array] An array of filepaths to downloaded catalogs
12
+ def update_all_catalogs_and_return_filepaths
13
+ does_rambafile_exist = Dir[RAMBAFILE_NAME].count > 0
14
+
15
+ if does_rambafile_exist
16
+ rambafile = YAML.load_file(RAMBAFILE_NAME)
17
+ catalogs = rambafile[CATALOGS_KEY]
18
+ end
19
+
20
+ terminator = CatalogTerminator.new
21
+ terminator.remove_all_catalogs
22
+
23
+ catalog_paths = [download_catalog(GENERAMBA_CATALOG_NAME, RAMBLER_CATALOG_REPO)]
24
+
25
+ if catalogs != nil && catalogs.count > 0
26
+ catalogs.each do |catalog_url|
27
+ catalog_name = catalog_url.split('://').last
28
+ catalog_name = catalog_name.gsub('/', '-');
29
+ catalog_paths.push(download_catalog(catalog_name, catalog_url))
30
+ end
31
+ end
32
+ return catalog_paths
33
+ end
34
+
8
35
  # Clones a template catalog from a remote repository
9
36
  #
10
37
  # @param name [String] The name of the template catalog
@@ -18,7 +45,12 @@ module Generamba
18
45
  current_catalog_path = catalogs_local_path
19
46
  .join(name)
20
47
 
21
- Git.clone(url, name, :path => catalogs_local_path)
48
+ if File.exists?(current_catalog_path)
49
+ g = Git.open(current_catalog_path)
50
+ g.pull
51
+ else
52
+ Git.clone(url, name, :path => catalogs_local_path)
53
+ end
22
54
 
23
55
  return current_catalog_path
24
56
  end
@@ -0,0 +1,23 @@
1
+ module Generamba
2
+
3
+ # Provides the functionality to list all of the templates, available in the catalog
4
+ class CatalogTemplateListHelper
5
+
6
+ # Finds out all of the templates located in a catalog
7
+ #
8
+ # @param catalog_path [Pathname] The path to a template catalog
9
+ #
10
+ # @return [Array] An array with template names
11
+ def obtain_all_templates_from_a_catalog(catalog_path)
12
+ template_names = []
13
+ catalog_path.children.select { |child|
14
+ File.directory?(child) && child.split.last.to_s[0] != '.'
15
+ }.map { |template_path|
16
+ template_path.split.last.to_s
17
+ }.each { |template_name|
18
+ template_names.push(template_name)
19
+ }
20
+ return template_names
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,27 @@
1
+ module Generamba
2
+
3
+ # Provides the functionality to search templates, in catalogs
4
+ class CatalogTemplateSearchHelper
5
+
6
+ # Finds out all of the templates located in a catalog
7
+ #
8
+ # @param catalog_path [Pathname] The path to a template catalog
9
+ #
10
+ # @return [Array] An array with template names
11
+ def search_templates_in_a_catalog(catalog_path, search_term)
12
+ template_names = []
13
+
14
+ catalog_path.children.select { |child|
15
+ File.directory?(child) && child.split.last.to_s[0] != '.'
16
+ }.map { |template_path|
17
+ template_path.split.last.to_s
18
+ }.select { |template_name|
19
+ template_name.include?(search_term)
20
+ }.each { |template_name|
21
+ template_names.push(template_name)
22
+ }
23
+
24
+ return template_names
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,21 @@
1
+ module Generamba
2
+
3
+ # Provides a functionality to terminate all previously installed catalogs
4
+ #
5
+ # @return [Void]
6
+ class CatalogTerminator
7
+ def remove_all_catalogs
8
+ catalogs_path = Pathname.new(ENV['HOME'])
9
+ .join(GENERAMBA_HOME_DIR)
10
+ .join(CATALOGS_DIR)
11
+ if Dir.exist?(catalogs_path) == false
12
+ FileUtils.mkdir_p catalogs_path
13
+ end
14
+ catalogs_path.children.select { |child|
15
+ child.directory? && child.split.last.to_s[0] != '.'
16
+ }.each { |catalog_path|
17
+ FileUtils.rm_rf(catalog_path)
18
+ }
19
+ end
20
+ end
21
+ end
@@ -3,6 +3,7 @@ require 'generamba/template/installer/local_installer.rb'
3
3
  require 'generamba/template/installer/remote_installer.rb'
4
4
  require 'generamba/template/installer/catalog_installer.rb'
5
5
  require 'generamba/template/helpers/catalog_downloader.rb'
6
+ require 'generamba/template/helpers/catalog_terminator'
6
7
  require 'git'
7
8
 
8
9
  module Generamba
@@ -56,7 +57,8 @@ module Generamba
56
57
 
57
58
  return unless needs_update
58
59
 
59
- remove_all_catalogs
60
+ terminator = CatalogTerminator.new
61
+ terminator.remove_all_catalogs
60
62
  puts('Updating shared generamba-catalog specs...')
61
63
  @catalog_downloader.download_catalog(GENERAMBA_CATALOG_NAME, RAMBLER_CATALOG_REPO)
62
64
 
@@ -69,19 +71,5 @@ module Generamba
69
71
  @catalog_downloader.download_catalog(catalog_name, catalog_url)
70
72
  end
71
73
  end
72
-
73
- def remove_all_catalogs
74
- catalogs_path = Pathname.new(ENV['HOME'])
75
- .join(GENERAMBA_HOME_DIR)
76
- .join(CATALOGS_DIR)
77
- if Dir.exist?(catalogs_path) == false
78
- FileUtils.mkdir_p catalogs_path
79
- end
80
- catalogs_path.children.select { |child|
81
- child.directory? && child.split.last.to_s[0] != '.'
82
- }.each { |catalog_path|
83
- FileUtils.rm_rf(catalog_path)
84
- }
85
- end
86
74
  end
87
75
  end
@@ -1,3 +1,3 @@
1
1
  module Generamba
2
- VERSION = '0.7.2'
2
+ VERSION = '0.7.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: generamba
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Egor Tolstoy
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-01-10 00:00:00.000000000 Z
12
+ date: 2016-01-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
@@ -81,6 +81,20 @@ dependencies:
81
81
  - - '='
82
82
  - !ruby/object:Gem::Version
83
83
  version: 1.2.9.1
84
+ - !ruby/object:Gem::Dependency
85
+ name: cocoapods-core
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - '='
89
+ - !ruby/object:Gem::Version
90
+ version: 0.39.0
91
+ type: :runtime
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - '='
96
+ - !ruby/object:Gem::Version
97
+ version: 0.39.0
84
98
  - !ruby/object:Gem::Dependency
85
99
  name: bundler
86
100
  requirement: !ruby/object:Gem::Requirement
@@ -180,6 +194,7 @@ files:
180
194
  - lib/generamba/constants/rambafile_constants.rb
181
195
  - lib/generamba/constants/rambaspec_constants.rb
182
196
  - lib/generamba/constants/user_preferences_constants.rb
197
+ - lib/generamba/helpers/dependency_checker.rb
183
198
  - lib/generamba/helpers/rambafile_validator.rb
184
199
  - lib/generamba/helpers/template_helper.rb
185
200
  - lib/generamba/helpers/xcodeproj_helper.rb
@@ -190,6 +205,9 @@ files:
190
205
  - lib/generamba/template/creator/new_template/template.rambaspec.liquid
191
206
  - lib/generamba/template/creator/template_creator.rb
192
207
  - lib/generamba/template/helpers/catalog_downloader.rb
208
+ - lib/generamba/template/helpers/catalog_template_list_helper.rb
209
+ - lib/generamba/template/helpers/catalog_template_search_helper.rb
210
+ - lib/generamba/template/helpers/catalog_terminator.rb
193
211
  - lib/generamba/template/helpers/rambaspec_validator.rb
194
212
  - lib/generamba/template/installer/abstract_installer.rb
195
213
  - lib/generamba/template/installer/catalog_installer.rb