rename 1.0.0 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 155ecb453a28d3b078737371377490c7c8800a69
4
+ data.tar.gz: b5a517bf0b0e6d32c9754b99b067f0fe79e70c34
5
+ SHA512:
6
+ metadata.gz: f17b0a28d5fb6adb411adeb2053e746d382ff3ccdc9801ef662bc6b9d0ad45e0be0de24e390ad4891ada86686808bef88fbe3861acc7662138e30b082ace5528
7
+ data.tar.gz: c0ddcf0dcb21fc7d48b88b46b13a1d2f8279edb3a7e3487cc26f2bfdf0b7e2c151d32c6330d0c6810f28031cd71108159f6ba685ba9e1d81d9b073ba66fc315d
@@ -0,0 +1 @@
1
+ == Rename github repository using API
@@ -0,0 +1,67 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'rails/all'
4
+
5
+ if defined?(Bundler)
6
+ # If you precompile assets before deploying to production, use this line
7
+ Bundler.require(*Rails.groups(:assets => %w(development test)))
8
+ # If you want your assets lazily compiled in production, use this line
9
+ # Bundler.require(:default, :assets, Rails.env)
10
+ end
11
+
12
+ Codelodge22222::Application.initialize!
13
+
14
+ #Secret token
15
+ Codelodge22222::Application.config.secret_token = '3544fef8fa99bb5c1939f786a3f8efd3dd7c5bac2081632368a97836b9d338c6d499d548641086ebf507b36c45db69f2b9ccaf98b981010ab2efbe3745d5bba6'
16
+
17
+ module Codelodge222
18
+ class Application < Rails::Application
19
+ # Settings in config/environments/* take precedence over those specified here.
20
+ # Application configuration should go into files in config/initializers
21
+ # -- all .rb files in that directory are automatically loaded.
22
+
23
+ # Custom directories with classes and modules you want to be autoloadable.
24
+ # config.autoload_paths += %W(#{config.root}/extras)
25
+
26
+ # Only load the plugins named here, in the order given (default is alphabetical).
27
+ # :all can be used as a placeholder for all plugins not explicitly named.
28
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
29
+
30
+ # Activate observers that should always be running.
31
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
32
+
33
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
34
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
35
+ # config.time_zone = 'Central Time (US & Canada)'
36
+
37
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
38
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
39
+ # config.i18n.default_locale = :de
40
+
41
+ # Configure the default encoding used in templates for Ruby 1.9.
42
+ config.encoding = "utf-8"
43
+
44
+ # Configure sensitive parameters which will be filtered from the log file.
45
+ config.filter_parameters += [:password]
46
+
47
+ # Enable escaping HTML in JSON.
48
+ config.active_support.escape_html_entities_in_json = true
49
+
50
+ # Use SQL instead of Active Record's schema dumper when creating the database.
51
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
52
+ # like if you have constraints or database-specific column types
53
+ # config.active_record.schema_format = :sql
54
+
55
+ # Enforce whitelist mode for mass assignment.
56
+ # This will create an empty whitelist of attributes available for mass-assignment for all models
57
+ # in your app. As such, your models will need to explicitly whitelist or blacklist accessible
58
+ # parameters by using an attr_accessible or attr_protected declaration.
59
+ config.active_record.whitelist_attributes = true
60
+
61
+ # Enable the asset pipeline
62
+ config.assets.enabled = true
63
+
64
+ # Version of your assets, change this if you want to expire all your assets
65
+ config.assets.version = '1.0'
66
+ end
67
+ end
@@ -1,83 +1,116 @@
1
1
  module Rename
2
2
  module Generators
3
+ class Error < Thor::Error
4
+ end
5
+
3
6
  class AppToGenerator < Rails::Generators::Base
4
- argument :new_name, :type => :string
7
+ desc 'Rename rails application'
8
+
9
+ argument :new_name, :type => :string, :default => ''
5
10
 
6
11
  def app_to
7
- return if !valid_app_name?
8
- new_module_name()
9
- new_basename()
12
+ valid?
13
+ new_app_module
14
+ new_app_directory
15
+ end
16
+
17
+ protected
18
+
19
+ def app_name
20
+ @app_name = new_name.gsub(/\W/, '_').squeeze('_').camelize
10
21
  end
11
22
 
12
- private
13
-
14
- def valid_app_name?
15
- if new_name.to_s.strip.blank?
16
- puts "Please enter new application name"
17
- return false
18
- elsif new_name.match(/^[A-Za-z]/).nil?
19
- puts "Invalid application name"
20
- return false
21
- elsif new_name.size < 3
22
- puts "New application name too short"
23
- return false
24
- elsif new_name.scan(/[0-9A-Za-z]/).size < 3
25
- puts "Name should have minimum 3 alphanumeric characters"
26
- return false
23
+ def app_key
24
+ @app_key = new_name.gsub(/\W/, '_').downcase
25
+ end
26
+
27
+ def app_dir
28
+ @app_dir = new_name.gsub(/[&%*@()!{}\[\]'\\\/"]+/, '')
29
+ end
30
+
31
+ def app_path
32
+ @app_path = Rails.root.to_s.split('/')[0...-1].push(app_dir).join('/')
33
+ end
34
+
35
+ def reserved_names
36
+ @reserved_names = %w[application destroy benchmarker profiler plugin runner test]
37
+ end
38
+
39
+ def valid?
40
+ if new_name.blank?
41
+ raise Error, "Application name can't be blank."
42
+ elsif new_name =~ /^\d/
43
+ raise Error, "Invalid application name #{new_name}. Please give a name which does not start with numbers."
44
+ end
45
+
46
+ valid_new_app_name?
47
+ valid_new_app_dir?
48
+ end
49
+
50
+ def valid_new_app_name?
51
+ if app_name.size < 1
52
+ raise Error, "Invalid application name #{app_name}. Please enter at least one alphabet."
53
+ elsif reserved_names.include?(app_name.downcase)
54
+ raise Error, "Invalid application name #{app_name}. Please give a name which does not match one of the reserved rails words."
55
+ elsif Object.const_defined?(app_name)
56
+ raise Error, "Invalid application name #{app_name}, constant #{app_name} is already in use. Please choose another application name."
27
57
  end
58
+ end
28
59
 
29
- return true
60
+ def valid_new_app_dir?
61
+ if File.exists?(app_path)
62
+ raise Error, "Invalid application name #{app_dir}, already in use. Please choose another application name."
63
+ end
30
64
  end
31
65
 
32
- def new_module_name()
33
- search_exp = /(#{Regexp.escape("#{Rails.application.class.parent}")})/m
34
- module_name = new_name.gsub(/[^0-9A-Za-z]/, ' ').split(' ').map { |w| w.capitalize }.join('')
66
+ # rename_app_to_new_app_module
67
+ def new_app_module
68
+ mod = "#{Rails.application.class.parent}"
35
69
 
36
70
  in_root do
37
- puts "Search and Replace Module in to..."
71
+ puts 'Search and replace module in to...'
38
72
 
39
73
  #Search and replace module in to file
40
- Dir["*", "config/**/**/*.rb", ".{rvmrc}"].each do |file|
41
- replace_into_file(file, search_exp, module_name)
74
+ Dir['*', 'config/**/**/*.rb', '.{rvmrc}'].each do |file|
75
+ replace_into_file(file, /(#{mod}*)/m, app_name)
42
76
  end
43
77
 
44
78
  #Rename session key
45
79
  session_key_file = 'config/initializers/session_store.rb'
46
- search_exp = /((\'|\")_.*_session(\'|\"))/i
47
- session_key = "'_#{module_name.gsub(/[^0-9A-Za-z_]/, '_').downcase}_session'"
80
+ search_exp = /(('|")_.*_session('|"))/i
81
+ session_key = "'_#{app_key}_session'"
48
82
  replace_into_file(session_key_file, search_exp, session_key)
49
83
  end
50
84
  end
51
85
 
52
- def new_basename()
53
- basename = new_name.gsub(/[^0-9A-Za-z_]/, '-')
54
- change_basename(basename)
55
- change_directory_name(basename)
86
+ # rename_app_to_new_app_directory
87
+ def new_app_directory
88
+ rename_references
89
+ rename_directory
56
90
  end
57
91
 
58
- def change_basename(basename)
59
- puts "Renaming basename..."
60
-
92
+ def rename_references
93
+ puts 'Renaming references...'
61
94
  old_basename = File.basename(Dir.getwd)
62
95
 
63
96
  in_root do
64
- Dir.glob(".idea/*", File::FNM_DOTMATCH).each do |file|
65
- replace_into_file(file, old_basename, basename)
97
+ Dir.glob('.idea/*', File::FNM_DOTMATCH).each do |file|
98
+ replace_into_file(file, old_basename, app_dir)
66
99
  end
67
100
 
68
- gemset_file = ".ruby-gemset"
69
- replace_into_file(gemset_file, old_basename, basename) if File.exist?(gemset_file)
101
+ gem_set_file = '.ruby-gemset'
102
+ replace_into_file(gem_set_file, old_basename, app_dir) if File.exist?(gem_set_file)
70
103
  end
71
104
  end
72
105
 
73
- def change_directory_name(basename)
106
+ def rename_directory
107
+ print 'Renaming directory...'
74
108
  begin
75
- print "Renaming directory..."
76
- new_path = Rails.root.to_s.split('/')[0...-1].push(basename).join('/')
77
- File.rename(Rails.root.to_s, new_path)
78
- puts "Done!"
109
+ File.rename(Rails.root.to_s, app_path)
110
+ puts 'Done!'
111
+ puts "New application path is '#{app_path}'"
79
112
  rescue Exception => ex
80
- puts "Error:#{ex.message}"
113
+ puts "Error:#{ex.inspect}"
81
114
  end
82
115
  end
83
116
 
@@ -1,3 +1,3 @@
1
1
  module Rename
2
- VERSION = "1.0.0"
2
+ VERSION = '1.0.2'
3
3
  end
@@ -2,18 +2,18 @@
2
2
  require File.expand_path('../lib/rename/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
- gem.name = "rename"
5
+ gem.name = 'rename'
6
6
  gem.version = Rename::VERSION
7
- gem.authors = ["Morshed Alam"]
8
- gem.email = ["morshed201@gmail.com"]
9
- gem.homepage = "https://github.com/morshedalam/rename"
10
- gem.description = 'This library allows you to rename Rails3 application by using a single command'
7
+ gem.authors = ['Morshed Alam']
8
+ gem.email = %w(morshed201@gmail.com)
9
+ gem.homepage = 'https://github.com/morshedalam/rename'
10
+ gem.description = 'This library allows you to rename rails application using a single command'
11
11
  gem.summary = 'A library to rename your rails3 application'
12
12
 
13
- gem.add_dependency "rails", ">= 3.0.0"
14
- gem.rubyforge_project = "rename"
13
+ gem.add_dependency 'rails','>= 3.0.0'
14
+ gem.rubyforge_project = 'rename'
15
15
 
16
16
  gem.files = `git ls-files`.split("\n")
17
17
  gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
- gem.require_paths = ["lib"]
18
+ gem.require_paths = %w(lib)
19
19
  end
metadata CHANGED
@@ -1,29 +1,30 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rename
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
5
- prerelease:
4
+ version: 1.0.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Morshed Alam
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-06-25 00:00:00.000000000Z
11
+ date: 2013-09-30 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rails
16
- requirement: &72799420 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: 3.0.0
22
20
  type: :runtime
23
21
  prerelease: false
24
- version_requirements: *72799420
25
- description: This library allows you to rename Rails3 application by using a single
26
- command
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 3.0.0
27
+ description: This library allows you to rename rails application using a single command
27
28
  email:
28
29
  - morshed201@gmail.com
29
30
  executables: []
@@ -35,6 +36,8 @@ files:
35
36
  - LICENSE
36
37
  - README.md
37
38
  - Rakefile
39
+ - TO DO
40
+ - application.rb
38
41
  - lib/generators/rename/app_to/USAGE
39
42
  - lib/generators/rename/app_to/app_to_generator.rb
40
43
  - lib/rename.rb
@@ -44,26 +47,25 @@ files:
44
47
  - tests/test_helper.rb
45
48
  homepage: https://github.com/morshedalam/rename
46
49
  licenses: []
50
+ metadata: {}
47
51
  post_install_message:
48
52
  rdoc_options: []
49
53
  require_paths:
50
54
  - lib
51
55
  required_ruby_version: !ruby/object:Gem::Requirement
52
- none: false
53
56
  requirements:
54
- - - ! '>='
57
+ - - '>='
55
58
  - !ruby/object:Gem::Version
56
59
  version: '0'
57
60
  required_rubygems_version: !ruby/object:Gem::Requirement
58
- none: false
59
61
  requirements:
60
- - - ! '>='
62
+ - - '>='
61
63
  - !ruby/object:Gem::Version
62
64
  version: '0'
63
65
  requirements: []
64
66
  rubyforge_project: rename
65
- rubygems_version: 1.7.2
67
+ rubygems_version: 2.0.7
66
68
  signing_key:
67
- specification_version: 3
69
+ specification_version: 4
68
70
  summary: A library to rename your rails3 application
69
71
  test_files: []