generamba 0.7.0 → 0.7.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 86031870069f4fd70b4aab732b9cd8b3b148bd73
4
- data.tar.gz: 5cfaf9db6ee20956d3ca39a3540ed60ca1680437
3
+ metadata.gz: fa6d08c063acbc143e6bb207b57f3ff29335003f
4
+ data.tar.gz: 75be1fd6927e0a08bf3d9dc122925166abbfb654
5
5
  SHA512:
6
- metadata.gz: 5e11bd68fe9b713a03773084ff0aaf91584fb6fae2ec01eba3136b8ff8dda3d9b1d8c348f7d11ba4a4988570c9009c6be8a0247c6d8c299321aeb7d1926de349
7
- data.tar.gz: 6488c2d30051969a72b09eca9da7c99f9382b13dee0c642d5cbb70be0791863f021719e51559e3ffb1a3edda8db4c26303aed04c8588e02bbff78d5143874100
6
+ metadata.gz: 0c532fd9d76a7714fae9d7083849b41516bab539554195cb4e9a3f69dbceb3d63b076950732fd2a37676c564d73a7e0e4aebcb1d49f0ea6b2ef7ef6d68cdad95
7
+ data.tar.gz: 2b4bfa45e3fcc56debd966132ff98b09c239a52472a3fbdcc5113e816c977425133aeb2b1b50779ee67e6d8f313959866b5813ab100fcb0446036a5bd6468fb3
data/generamba.gemspec CHANGED
@@ -24,7 +24,6 @@ Gem::Specification.new do |spec|
24
24
  spec.add_runtime_dependency 'xcodeproj', '0.28.2'
25
25
  spec.add_runtime_dependency 'liquid', '3.0.6'
26
26
  spec.add_runtime_dependency 'tilt', '2.0.1'
27
- spec.add_runtime_dependency 'settingslogic', '2.0.9'
28
27
  spec.add_runtime_dependency 'git', '1.2.9.1'
29
28
 
30
29
  spec.add_development_dependency 'bundler', '~> 1.10'
@@ -34,8 +34,10 @@ module Generamba::CLI
34
34
  default_module_description = "#{module_name} module"
35
35
  module_description = options[:description] ? options[:description] : default_module_description
36
36
 
37
+ rambafile = YAML.load_file(RAMBAFILE_NAME)
38
+
37
39
  template = ModuleTemplate.new(template_name)
38
- code_module = CodeModule.new(module_name, module_description, options)
40
+ code_module = CodeModule.new(module_name, module_description, rambafile, options)
39
41
 
40
42
  generator = Generamba::ModuleGenerator.new()
41
43
  generator.generate_module(module_name, code_module, template)
@@ -24,17 +24,11 @@ module Generamba::CLI
24
24
  properties[PROJECT_NAME_KEY] = is_right_project_name ? project_name : ask_non_empty_string('The project name:', 'Project name should not be empty')
25
25
  properties[PROJECT_PREFIX_KEY] = ask('The project prefix (if any):')
26
26
 
27
- project_files = Dir['*.xcodeproj']
28
- count = project_files.count
29
- if count == 1
30
- is_right_path = yes?("The path to a .xcodeproj file of the project is #{project_files[0]}. Do you want to use it? (yes/no)")
31
- xcode_path = is_right_path ? project_files[0] : ask('The path to a .xcodeproj file of the project:')
32
- else
33
- xcode_path = ask('The path to a .xcodeproj file of the project:')
34
- end
27
+ xcodeproj_path = ask_file_with_path('*.xcodeproj',
28
+ '.xcodeproj file of the project')
35
29
 
36
- properties[XCODEPROJ_PATH_KEY] = xcode_path
37
- project = Xcodeproj::Project.open(xcode_path)
30
+ properties[XCODEPROJ_PATH_KEY] = xcodeproj_path
31
+ project = Xcodeproj::Project.open(xcodeproj_path)
38
32
 
39
33
  targets_prompt = ''
40
34
  project.targets.each_with_index { |element, i| targets_prompt += ("#{i}. #{element.name}" + "\n") }
@@ -56,8 +50,17 @@ module Generamba::CLI
56
50
  test_file_path = ask('The default path for creating tests (in the filesystem):')
57
51
  end
58
52
 
59
- properties[PODFILE_PATH_KEY] = ask('The Podfile path (if any):')
60
- properties[CARTFILE_PATH_KEY] = ask('The Cartfile path (if any):')
53
+ using_pods = yes?('Are you using Cocoapods? (yes/no)')
54
+ if using_pods
55
+ properties[PODFILE_PATH_KEY] = ask_file_with_path('Podfile',
56
+ 'Podfile')
57
+ end
58
+
59
+ using_carthage = yes?('Are you using Carthage? (yes/no)')
60
+ if using_carthage
61
+ properties[CARTFILE_PATH_KEY] = ask_file_with_path('Cartfile',
62
+ 'Cartfile')
63
+ end
61
64
 
62
65
  properties[PROJECT_TARGET_KEY] = project_target.name
63
66
  properties[PROJECT_FILE_PATH_KEY] = project_file_path
@@ -29,6 +29,19 @@ module Generamba::CLI
29
29
  puts(description.red)
30
30
  end
31
31
  end
32
+
33
+ def ask_file_with_path(pattern, message_file_name)
34
+ project_files = Dir[pattern]
35
+ count = project_files.count
36
+ default_message = "The path to a #{message_file_name}:"
37
+ if count == 1
38
+ is_right_path = yes?"The path to a #{message_file_name} is '#{project_files[0]}'. Do you want to use it? (yes/no)"
39
+ xcode_path = is_right_path ? project_files[0] : ask(default_message)
40
+ else
41
+ xcode_path = ask(default_message)
42
+ end
43
+ return xcode_path
44
+ end
32
45
  end
33
46
  end
34
47
  end
@@ -26,9 +26,9 @@ test_file_path: {{ test_file_path }}{% endif %}
26
26
  {% if test_group_path != "" %}# The Xcode group path to new tests
27
27
  test_group_path: {{ test_group_path }}{% endif %}
28
28
 
29
- {% if podfile_path != "" or cartfile_path != "" %}### Dependencies settings section{% endif %}
30
- {% if podfile_path != "" %}podfile_path: {{ podfile_path }}{% endif %}
31
- {% if cartfile_path != "" %}cartfile_path: {{ cartfile_path }}{% endif %}
29
+ {% if podfile_path != nil or cartfile_path != nil %}### Dependencies settings section{% endif %}
30
+ {% if podfile_path != nil %}podfile_path: {{ podfile_path }}{% endif %}
31
+ {% if cartfile_path != nil %}cartfile_path: {{ cartfile_path }}{% endif %}
32
32
 
33
33
  ### Templates
34
34
  templates:
@@ -4,6 +4,12 @@ module Generamba
4
4
  class CodeModule
5
5
  attr_reader :name,
6
6
  :description,
7
+ :author,
8
+ :company,
9
+ :year,
10
+ :prefix,
11
+ :project_name,
12
+ :xcodeproj_path,
7
13
  :module_file_path,
8
14
  :module_group_path,
9
15
  :test_file_path,
@@ -11,115 +17,45 @@ module Generamba
11
17
  :project_targets,
12
18
  :test_targets
13
19
 
14
- def initialize(name, description, options)
20
+ def initialize(name, description, rambafile, options)
21
+ # Base initialization
15
22
  @name = name
16
23
  @description = description
17
24
 
18
- @project_targets = options[:module_targets].split(',') if options[:module_targets]
19
- @test_targets = options[:test_targets].split(',') if options[:test_targets]
20
-
21
- @module_file_path = Pathname.new(options[:module_file_path]) if options[:module_file_path]
22
- @module_group_path = Pathname.new(options[:module_group_path]) if options[:module_group_path]
23
- @test_file_path = Pathname.new(options[:test_file_path]) if options[:test_file_path]
24
- @test_group_path = Pathname.new(options[:test_group_path]) if options[:test_group_path]
25
-
26
- # The priority is given to `module_path` and 'test_path' options
27
- @module_file_path = Pathname.new(options[:module_path]) if options[:module_path]
28
- @module_group_path = Pathname.new(options[:module_path]) if options[:module_path]
29
- @test_file_path = Pathname.new(options[:test_path]) if options[:test_path]
30
- @test_group_path = Pathname.new(options[:test_path]) if options[:test_path]
31
- end
32
-
33
- def author
34
- Generamba::UserPreferences.obtain_username
35
- end
36
-
37
- def company
38
- ProjectConfiguration.company
39
- end
40
-
41
- def year
42
- Time.now.year.to_s
43
- end
44
-
45
- def prefix
46
- ProjectConfiguration.prefix
47
- end
48
-
49
- def project_name
50
- ProjectConfiguration.project_name
51
- end
52
-
53
- def module_file_path
54
- return @module_file_path != nil ?
55
- @module_file_path :
56
- Pathname.new(ProjectConfiguration.project_file_path)
57
- .join(@name)
58
- end
59
-
60
- def module_group_path
61
- return @module_group_path != nil ?
62
- @module_group_path :
63
- Pathname.new(ProjectConfiguration.project_group_path)
64
- .join(@name)
65
- end
66
-
67
- def test_file_path
68
- if @test_file_path == nil
69
- if ProjectConfiguration.test_file_path == nil
70
- return nil
71
- end
25
+ @author = UserPreferences.obtain_username
26
+ @company = rambafile[COMPANY_KEY]
27
+ @year = Time.now.year.to_s
72
28
 
73
- return Pathname.new(ProjectConfiguration.test_file_path)
74
- .join(@name)
75
- end
76
- return @test_file_path
77
- end
29
+ @prefix = rambafile[PROJECT_PREFIX_KEY]
30
+ @project_name = rambafile[PROJECT_NAME_KEY]
31
+ @xcodeproj_path = rambafile[XCODEPROJ_PATH_KEY]
78
32
 
79
- def test_group_path
80
- if @test_group_path == nil
81
- if ProjectConfiguration.test_group_path == nil
82
- return nil
83
- end
33
+ @module_file_path = Pathname.new(rambafile[PROJECT_FILE_PATH_KEY]).join(@name)
34
+ @module_group_path = Pathname.new(rambafile[PROJECT_GROUP_PATH_KEY]).join(@name)
84
35
 
85
- return Pathname.new(ProjectConfiguration.test_group_path)
86
- .join(@name)
87
- end
88
- return @test_group_path
89
- end
36
+ @test_file_path = Pathname.new(rambafile[TEST_FILE_PATH_KEY]).join(@name) if rambafile[TEST_FILE_PATH_KEY] != nil
37
+ @test_group_path = Pathname.new(rambafile[TEST_GROUP_PATH_KEY]).join(@name) if rambafile[TEST_GROUP_PATH_KEY] != nil
90
38
 
91
- def project_targets
92
- targets = Array.new
93
- if ProjectConfiguration.project_target != nil
94
- targets = [ProjectConfiguration.project_target]
95
- end
39
+ @project_targets = [rambafile[PROJECT_TARGET_KEY]] if rambafile[PROJECT_TARGET_KEY] != nil
40
+ @project_targets = rambafile[PROJECT_TARGETS_KEY] if rambafile[PROJECT_TARGETS_KEY] != nil
96
41
 
97
- if ProjectConfiguration.project_targets != nil
98
- targets = ProjectConfiguration.project_targets
99
- end
42
+ @test_targets = [rambafile[TEST_TARGET_KEY]] if rambafile[TEST_TARGET_KEY] != nil
43
+ @test_targets = rambafile[TEST_TARGETS_KEY] if rambafile[TEST_TARGETS_KEY] != nil
100
44
 
101
- if @project_targets != nil
102
- targets = @project_targets
103
- end
104
-
105
- return targets
106
- end
107
-
108
- def test_targets
109
- targets = Array.new
110
- if ProjectConfiguration.test_target != nil
111
- targets = [ProjectConfiguration.test_target]
112
- end
113
-
114
- if ProjectConfiguration.test_targets != nil
115
- targets = ProjectConfiguration.test_targets
116
- end
45
+ # Options adaptation
46
+ @project_targets = options[:module_targets].split(',') if options[:module_targets]
47
+ @test_targets = options[:test_targets].split(',') if options[:test_targets]
117
48
 
118
- if @test_targets != nil
119
- targets = @test_targets
120
- end
49
+ @module_file_path = Pathname.new(options[:module_file_path]).join(@name) if options[:module_file_path]
50
+ @module_group_path = Pathname.new(options[:module_group_path]).join(@name) if options[:module_group_path]
51
+ @test_file_path = Pathname.new(options[:test_file_path]).join(@name) if options[:test_file_path]
52
+ @test_group_path = Pathname.new(options[:test_group_path]).join(@name) if options[:test_group_path]
121
53
 
122
- return targets
54
+ # The priority is given to `module_path` and 'test_path' options
55
+ @module_file_path = Pathname.new(options[:module_path]).join(@name) if options[:module_path]
56
+ @module_group_path = Pathname.new(options[:module_path]).join(@name) if options[:module_path]
57
+ @test_file_path = Pathname.new(options[:test_path]).join(@name) if options[:test_path]
58
+ @test_group_path = Pathname.new(options[:test_path]).join(@name) if options[:test_path]
123
59
  end
124
60
  end
125
61
  end
@@ -1,5 +1,4 @@
1
1
  require 'generamba/helpers/template_helper.rb'
2
- require 'settingslogic'
3
2
 
4
3
  module Generamba
5
4
 
@@ -9,11 +8,11 @@ module Generamba
9
8
 
10
9
  def initialize(name)
11
10
  spec_path = TemplateHelper.obtain_spec(name)
12
- spec = Settingslogic.new(spec_path)
11
+ spec = YAML.load_file(spec_path)
13
12
 
14
13
  @code_files = spec[TEMPLATE_CODE_FILES_KEY]
15
14
  @test_files = spec[TEMPLATE_TEST_FILES_KEY]
16
- @template_name = spec.name
15
+ @template_name = spec[TEMPLATE_NAME_KEY]
17
16
  @template_path = TemplateHelper.obtain_path(name)
18
17
  end
19
18
  end
@@ -9,7 +9,7 @@ module Generamba
9
9
 
10
10
  def generate_module(name, code_module, template)
11
11
  # Setting up Xcode objects
12
- project = XcodeprojHelper.obtain_project(ProjectConfiguration.xcodeproj_path)
12
+ project = XcodeprojHelper.obtain_project(code_module.xcodeproj_path)
13
13
 
14
14
  # Configuring file paths
15
15
  FileUtils.mkdir_p code_module.module_file_path
@@ -62,7 +62,7 @@ module Generamba
62
62
  # The target file's name consists of three parameters: project prefix, module name and template file name.
63
63
  # E.g. RDS + Authorization + Presenter.h = RDSAuthorizationPresenter.h
64
64
  file_basename = name + File.basename(file[TEMPLATE_NAME_KEY])
65
- prefix = ProjectConfiguration.prefix
65
+ prefix = code_module.prefix
66
66
  file_name = prefix ? prefix + file_basename : file_basename
67
67
 
68
68
  file_group = File.dirname(file[TEMPLATE_NAME_KEY])
@@ -1,5 +1,3 @@
1
- require 'settingslogic'
2
-
3
1
  module Generamba
4
2
 
5
3
  # Provides methods that validate .rambaspec file existance and structure
@@ -13,7 +11,7 @@ module Generamba
13
11
  # @return [Bool]
14
12
  def self.validate_spec_existance(template_name, template_path)
15
13
  local_spec_path = self.obtain_spec_path(template_name, template_path)
16
- rambaspec_exist = File.file?(local_spec_path)
14
+ File.file?(local_spec_path)
17
15
  end
18
16
 
19
17
  # Validates the structure of a .rambaspec file for a given template
@@ -24,9 +22,13 @@ module Generamba
24
22
  # @return [Bool]
25
23
  def self.validate_spec(template_name, template_path)
26
24
  spec_path = self.obtain_spec_path(template_name, template_path)
27
- spec = Settingslogic.new(spec_path)
25
+ spec = YAML.load_file(spec_path)
28
26
 
29
- is_spec_valid = spec.name != nil && spec.author != nil && spec.version != nil && spec.code_files != nil
27
+ is_spec_valid =
28
+ spec[TEMPLATE_NAME_KEY] != nil &&
29
+ spec[TEMPLATE_AUTHOR_KEY] != nil &&
30
+ spec[TEMPLATE_VERSION_KEY] != nil &&
31
+ spec[TEMPLATE_CODE_FILES_KEY] != nil
30
32
  return is_spec_valid
31
33
  end
32
34
 
@@ -40,8 +42,8 @@ module Generamba
40
42
  # @return [Bool]
41
43
  def self.obtain_spec_path(template_name, template_path)
42
44
  spec_filename = template_name + RAMBASPEC_EXTENSION
43
- full_path = Pathname.new(template_path)
44
- .join(spec_filename)
45
+ Pathname.new(template_path)
46
+ .join(spec_filename)
45
47
  end
46
48
  end
47
49
  end
@@ -1,3 +1,3 @@
1
1
  module Generamba
2
- VERSION = '0.7.0'
2
+ VERSION = '0.7.1'
3
3
  end
data/lib/generamba.rb CHANGED
@@ -7,7 +7,6 @@ module Generamba
7
7
  require 'generamba/cli/cli.rb'
8
8
  require 'generamba/code_generation/code_module.rb'
9
9
  require 'generamba/code_generation/module_template.rb'
10
- require 'generamba/configuration/project_configuration'
11
10
  require 'generamba/code_generation/content_generator.rb'
12
11
  require 'generamba/code_generation/rambafile_generator.rb'
13
12
  require 'generamba/module_generator.rb'
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.0
4
+ version: 0.7.1
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: 2015-12-13 00:00:00.000000000 Z
12
+ date: 2015-12-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
@@ -67,20 +67,6 @@ dependencies:
67
67
  - - '='
68
68
  - !ruby/object:Gem::Version
69
69
  version: 2.0.1
70
- - !ruby/object:Gem::Dependency
71
- name: settingslogic
72
- requirement: !ruby/object:Gem::Requirement
73
- requirements:
74
- - - '='
75
- - !ruby/object:Gem::Version
76
- version: 2.0.9
77
- type: :runtime
78
- prerelease: false
79
- version_requirements: !ruby/object:Gem::Requirement
80
- requirements:
81
- - - '='
82
- - !ruby/object:Gem::Version
83
- version: 2.0.9
84
70
  - !ruby/object:Gem::Dependency
85
71
  name: git
86
72
  requirement: !ruby/object:Gem::Requirement
@@ -173,7 +159,6 @@ files:
173
159
  - lib/generamba/code_generation/content_generator.rb
174
160
  - lib/generamba/code_generation/module_template.rb
175
161
  - lib/generamba/code_generation/rambafile_generator.rb
176
- - lib/generamba/configuration/project_configuration.rb
177
162
  - lib/generamba/configuration/user_preferences.rb
178
163
  - lib/generamba/constants/constants.rb
179
164
  - lib/generamba/constants/rambafile_constants.rb
@@ -1,10 +0,0 @@
1
- require 'settingslogic'
2
-
3
- module Generamba
4
-
5
- # A singletone class representing a Rambafile of the current project
6
- class ProjectConfiguration < Settingslogic
7
- source Dir.getwd + '/' + RAMBAFILE_NAME
8
- suppress_errors(true)
9
- end
10
- end