app_copyr 0.0.4 → 0.0.6

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: acd488732f87c5e671ba93facd3f6f7dab09ac59
4
- data.tar.gz: 1351cdb9143c7481f09102c00738f57888e0f325
3
+ metadata.gz: f7500b6d3707d045a99b6c5be74fc2a09ea99cbf
4
+ data.tar.gz: d83ac49a7108b07f4be419d866187b9a406fe3e4
5
5
  SHA512:
6
- metadata.gz: b472b90536c729fe4c4e2adf1426797ab7b13163003394426f170584e4f54431921a9a172cd3bf8a6afee4f9221d26df1974048adadb38c46827097a2388db41
7
- data.tar.gz: 67d2f54eb3a78536fa0b3e35076cb8fb2b9133581a927d47d5a6ea9fd7d89c6cd43a334ffd0acaec5144291f71c3bfb5579390343d33f58babf4485f8a39e969
6
+ metadata.gz: 7fcac02a0c974b715b22bd5f5687963b11fe3e8c722b0951621f938a6e2a2a0e2b168e653ae9978df435342d47f40eb9b64f15dc2f45ffcab5a12161a44ef1c4
7
+ data.tar.gz: 79817d96dc7882decb9e3e0e8222b24dec7b5278fb32cd0d2cc49e7cd180d0f1f854a8aaa07ae2c0a1cd7aacaf4abe923dbbc441733e8752fe9cc0dfee471afc
@@ -79,12 +79,20 @@ module AppCopyr
79
79
  puts "Running file copies..."
80
80
  build_structure unless structure_built
81
81
  files = all_files.select { |f| File.file?(f) && !binary?(f) }
82
+ bin_files = all_files.select { |f| File.file?(f) && binary?(f) }
83
+ bin_files.each do |bin_file|
84
+ # get rid of the old path
85
+ new_name = bin_file.gsub(/#{old_app_name}/, new_app_name)
86
+ unless File.exists?(new_name)
87
+ FileUtils.cp(bin_file, new_name)
88
+ end
89
+ end
82
90
  files.each do |source_file|
83
91
  next if source_file =~ /\.log\z/
84
92
  _new_file = source_file.gsub(build_source, build_dest)
85
93
  # make the directory only and next if dir
86
94
  _dest_file = File.open(_new_file, 'w+')
87
- log "Writing #{source_file}"
95
+ log "Searching #{source_file}"
88
96
  if File.size(source_file) == 0
89
97
  # skip empty files, but still create them
90
98
  FileUtils.touch(_new_file)
@@ -96,7 +104,7 @@ module AppCopyr
96
104
  log "Removing #{old_app_name} from #{_new_file}"
97
105
  line = line.gsub(old_app_name, new_app_name)
98
106
  log "Removing #{old_app_name.underscore} from #{_new_file}"
99
- line = line.gsub(/(^|\s|_)#{old_app_name.underscore}/, new_app_name.underscore)
107
+ line = line.gsub(/#{old_app_name.underscore}/, "#{new_app_name.underscore}")
100
108
  _dest_file.print line
101
109
  else
102
110
  _dest_file.print line
@@ -108,14 +116,14 @@ module AppCopyr
108
116
  end
109
117
 
110
118
  def all_files
111
- @all_files ||= Dir.glob(File.join(options[:source], "/**/**/*")).reject{|f| f.match(/\/vendor\/bundle\//)}
119
+ @all_files ||= Dir.glob(File.join(options[:source], "/**/**/*")).reject { |f| f.match(/\/vendor\/bundle\//) }
112
120
  end
113
121
 
114
122
  def binary?(filename)
115
123
  return false if File.size(filename) == 0
116
124
  begin
117
- fm= FileMagic.new(FileMagic::MAGIC_MIME)
118
- !(fm.file(filename)=~ /^text\//)
125
+ fm = FileMagic.new(FileMagic::MAGIC_MIME)
126
+ !(fm.file(filename)=~ /^text\/|^application\/(xml|json)/)
119
127
  ensure
120
128
  fm.close
121
129
  end
@@ -1,3 +1,3 @@
1
1
  module AppCopyr
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -40,10 +40,19 @@ describe AppCopyr do
40
40
  # Capture output to stdout, otherwise it goes to stderr, works on a mac...
41
41
  output = `bin/app-copyr copy --source #{$final_test_dir} --dest #{$final_test_out_dir} > /dev/stdout 2>&1`
42
42
  refute_match(/No value provided for required options/, output)
43
+ assert_equal($?.exitstatus, 0)
44
+ end
45
+
46
+ it 'creates a functional rails app when done' do
47
+ `rails new #{$final_test_dir}`
48
+ `bin/app-copyr copy --source=#{$final_test_dir} --dest=#{$final_test_out_dir} > /dev/stdout 2>&1`
49
+ Dir.chdir($final_test_out_dir){
50
+ `rake -T`
51
+ assert_equal($?.exitstatus, 0)
52
+ }
43
53
  end
44
54
 
45
55
  def teardown
46
- # puts "Finished!"
47
56
  `rm -rf #{$good_dest_dir}`
48
57
  `rm -rf #{$already_exists_dir}`
49
58
  `rm -rf #{$final_test_dir}`
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: app_copyr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Quinn
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  version: '0'
126
126
  requirements: []
127
127
  rubyforge_project:
128
- rubygems_version: 2.2.2
128
+ rubygems_version: 2.4.3
129
129
  signing_key:
130
130
  specification_version: 4
131
131
  summary: Copies a functional app that you like, to a new app name