vipergen 0.1.8 → 0.1.9

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: 4c5b8b00f457e6bc03e1f087d82798bb742184a5
4
- data.tar.gz: 70cf5782fba713d3f76f9a519323e5e8159e6265
3
+ metadata.gz: f63d3d600a323f49c0d30b5ce4bffb88d588963f
4
+ data.tar.gz: bb2773bac66525a309dcb13e5e1b9a3d49aaffc9
5
5
  SHA512:
6
- metadata.gz: 19277afe77899d8bbdaa179d3969d6a35603d3f392051480bf1ceb98a90fca25f5671352c8c4be006fb33e075aafa9ade28c2a09e3ca0bbd2d255aacc0d765e4
7
- data.tar.gz: f140b12753d00b2288ca3bfe25875e7e69560a62c5de164c35584c2527f3e67c7b8995146c2d513d77eaf66fa7a66e36f13a37303d0ee17915ddbb464a581970
6
+ metadata.gz: 57a82ac765eede2fe27dbc8cae1d1e8110140bb2c0efc18bba561ae360dfb93d1c2d2752e1c992bd5c5aabc6cd1d81a617f76e962941f79c19e3327e1930b8dd
7
+ data.tar.gz: fe635ff1a3d51544fe87f3209895888899e788f15c67d89ce54a5666ac77334cc9b85c78385a36a9416df2e740c520f67962ff468eebf5800bfdedfeac26e36a
data/lib/vipergen.rb CHANGED
@@ -3,10 +3,4 @@ require 'vipergen/filemanager'
3
3
  require 'vipergen/dirutils'
4
4
  require 'vipergen/version'
5
5
  require 'vipergen/viperthor'
6
- require 'vipergen/templatemanager'
7
-
8
- module Vipergen
9
- # Constants
10
- LANGUAGES = ["swift", "objc"]
11
- REPLACEMENT_KEY = "VIPER"
12
- end
6
+ require 'vipergen/templatemanager'
@@ -1,10 +1,7 @@
1
1
  module Vipergen
2
2
  # File manager class
3
3
  class FileManager
4
- # Constants
5
- LANGUAGES = ["swift", "objc"]
6
- REPLACEMENT_KEY = "VIPER"
7
-
4
+
8
5
  # Returns if the template is valid by the VIPER generator
9
6
  def self.is_template_valid(template)
10
7
  return Vipergen::TemplateManager.templates.include? template
@@ -12,14 +9,14 @@ module Vipergen
12
9
 
13
10
  # Returns if the language is valid by the VIPER generator
14
11
  def self.is_language_valid(language)
15
- return LANGUAGES.include? language
12
+ return (Vipergen::Generator::LANGUAGES).include? language
16
13
  end
17
14
 
18
15
  # Return the path if valid template and language
19
16
  # @return String with valid path
20
17
  def self.path_from(template, language)
21
18
  return nil if !is_language_valid(language) || !is_template_valid(template)
22
- return File.join(Vipergen::TemplatesManager.templates_dir, template, language)
19
+ return File.join(Vipergen::TemplateManager.templates_dir, template, language)
23
20
  end
24
21
 
25
22
  # Returns an array with files in a given path
@@ -1,6 +1,10 @@
1
1
  module Vipergen
2
2
  # Cosntants
3
3
  class Generator
4
+ # Constants
5
+ LANGUAGES = ["swift", "objc"]
6
+ REPLACEMENT_KEY = "VIPER"
7
+
4
8
  # Main method that generate the VIPER files structure
5
9
  def self.generate_viper(template, language, name, path)
6
10
  puts "Generating VIPER-Module"
@@ -20,7 +24,7 @@ module Vipergen
20
24
  # - It renames the content of the file
21
25
  def self.rename_files(files, name)
22
26
  files.each do |file|
23
- raise SyntaxError unless file.include? Vipergen::REPLACEMENT_KEY
27
+ raise SyntaxError unless file.include? (Vipergen::Generator::REPLACEMENT_KEY)
24
28
  rename_file(file, name)
25
29
  end
26
30
  end
@@ -29,7 +33,7 @@ module Vipergen
29
33
  # - It renames the name of the file
30
34
  # - It renames the content of the file
31
35
  def self.rename_file(file, name)
32
- new_path = file.gsub(Vipergen::REPLACEMENT_KEY, name)
36
+ new_path = file.gsub((Vipergen::Generator::REPLACEMENT_KEY), name)
33
37
  Vipergen::FileManager.move(file, new_path)
34
38
  rename_file_content(new_path, name)
35
39
  end
@@ -43,7 +47,7 @@ module Vipergen
43
47
  file.close
44
48
 
45
49
  # Replacing content
46
- content = content.gsub(Vipergen::REPLACEMENT_KEY, name)
50
+ content = content.gsub((Vipergen::Generator::REPLACEMENT_KEY), name)
47
51
 
48
52
  # Saving content with replaced string
49
53
  File.open(filename, "w+") do |file|
@@ -1,4 +1,4 @@
1
1
  module Vipergen
2
2
  NAME = "vipergen"
3
- VERSION = "0.1.8"
3
+ VERSION = "0.1.9"
4
4
  end
@@ -44,7 +44,7 @@ end
44
44
  describe Vipergen::Generator do
45
45
  context "when renaming file content" do
46
46
  before (:each) do
47
- File.open("test.txt", 'w') {|f| f.write("I'm a #{Vipergen::REPLACEMENT_KEY} file") }
47
+ File.open("test.txt", 'w') {|f| f.write("I'm a #{Vipergen::Generator.REPLACEMENT_KEY} file") }
48
48
  end
49
49
 
50
50
  it "should rename every VIPER word to the given name" do
@@ -61,12 +61,12 @@ describe Vipergen::Generator do
61
61
 
62
62
  context "when renaming file" do
63
63
  before (:each) do
64
- File.open("#{Vipergen::REPLACEMENT_KEY}test.txt", 'w') {|f| f.write("I'm a #{Vipergen::REPLACEMENT_KEY} file") }
64
+ File.open("#{Vipergen::Generator.REPLACEMENT_KEY}test.txt", 'w') {|f| f.write("I'm a #{Vipergen::Generator.REPLACEMENT_KEY} file") }
65
65
  end
66
66
 
67
67
  it "every file should be renamed in rename_files" do
68
68
  expect(Vipergen::Generator).to receive(:rename_file)
69
- Vipergen::Generator.rename_files(["#{Vipergen::REPLACEMENT_KEY}file.txt"], "pepito")
69
+ Vipergen::Generator.rename_files(["#{Vipergen::Generator.REPLACEMENT_KEY}file.txt"], "pepito")
70
70
  end
71
71
 
72
72
  it "should raise a SyntaxError exeption if there's a file in the template without the proper name" do
@@ -74,21 +74,21 @@ describe Vipergen::Generator do
74
74
  end
75
75
 
76
76
  it "should rename the VIPER in name to the given name" do
77
- file = "#{Vipergen::REPLACEMENT_KEY}test.txt"
77
+ file = "#{Vipergen::Generator.REPLACEMENT_KEY}test.txt"
78
78
  name = "RENAMED"
79
79
  Vipergen::Generator.rename_file(file, name)
80
80
  expect(File.exist? "RENAMEDtest.txt").to eq(true)
81
81
  end
82
82
 
83
83
  it "should rename the file content after the file name rename" do
84
- file = "#{Vipergen::REPLACEMENT_KEY}test.txt"
84
+ file = "#{Vipergen::Generator.REPLACEMENT_KEY}test.txt"
85
85
  name = "RENAMED"
86
86
  expect(Vipergen::Generator).to receive(:rename_file_content)
87
87
  Vipergen::Generator.rename_file(file, name)
88
88
  end
89
89
 
90
90
  after (:each) do
91
- File.delete "#{Vipergen::REPLACEMENT_KEY}test.txt" if File.exist? "#{Vipergen::REPLACEMENT_KEY}test.txt"
91
+ File.delete "#{Vipergen::Generator.REPLACEMENT_KEY}test.txt" if File.exist? "#{Vipergen::Generator.REPLACEMENT_KEY}test.txt"
92
92
  File.delete "RENAMEDtest.txt" if File.exist? "RENAMEDtest.txt"
93
93
  end
94
94
  end
metadata CHANGED
@@ -1,83 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vipergen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pedro Piñera
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-06 00:00:00.000000000 Z
11
+ date: 2014-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '1.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: byebug
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: thor
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  description: Based on the objc.io post about VIPER. It saves time in the implementation
@@ -122,22 +122,22 @@ licenses:
122
122
  metadata: {}
123
123
  post_install_message:
124
124
  rdoc_options:
125
- - --charset=UTF-8
125
+ - "--charset=UTF-8"
126
126
  require_paths:
127
127
  - lib
128
128
  required_ruby_version: !ruby/object:Gem::Requirement
129
129
  requirements:
130
- - - '>='
130
+ - - ">="
131
131
  - !ruby/object:Gem::Version
132
132
  version: '0'
133
133
  required_rubygems_version: !ruby/object:Gem::Requirement
134
134
  requirements:
135
- - - '>='
135
+ - - ">="
136
136
  - !ruby/object:Gem::Version
137
137
  version: '0'
138
138
  requirements: []
139
139
  rubyforge_project:
140
- rubygems_version: 2.4.1
140
+ rubygems_version: 2.2.2
141
141
  signing_key:
142
142
  specification_version: 4
143
143
  summary: Generates XCode VIPER module controllers structure