insert_from_file 0.0.0 → 0.0.1

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: 99a8acc683b2d5e35699c95d3b9d98021af089e9
4
- data.tar.gz: 1c44547fde74a31d71e613e3c6f4d7f534fc739d
3
+ metadata.gz: 4a3e5433855d3c01e01b30769cc529f44d9c6958
4
+ data.tar.gz: 80ba299ea659ec3ac30383916f1c8d8d8fba0bd3
5
5
  SHA512:
6
- metadata.gz: 2ea1b9539b5c20d7db21b6cea68e2d8aa74682a92047a51ad928ced6a14547438f9aaea47198a6125314f040b5a0a12b6e72ada8269a2796b4d6eb8fb71ca2b6
7
- data.tar.gz: 7971fc9a355f4cbd409711ada68c4ae2ab9f356cb031ffa9c132acfdb58c48c411bd73b1887ae9c664dcbcf48373ae5479fc5457e7bd5f887197a5ea38706f0d
6
+ metadata.gz: 95c2bb25a5865409e5920d2e31ee887985ff1ab78d4a03d798a9aac0cf0c9963fd9328d330b6cbe70bacdc07db783b9c4c9baed84604415bd07ffe35ee64377a
7
+ data.tar.gz: 87040f4b3bd62b3fbcf78f0e7af6714fd1f237bd410c9b899d56b5dc9ee66da444510b2e8425915eabface536e31081231e0a3447d188355330df207cccf0116
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # InsertFromFile
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/insert_from_file.svg)](https://badge.fury.io/rb/insert_from_file)
3
4
  [![Build Status](https://travis-ci.org/jhsu802701/insert_from_file.svg?branch=master)](https://travis-ci.org/jhsu802701/insert_from_file)
4
5
  [![security](https://hakiri.io/github/jhsu802701/insert_from_file/master.svg)](https://hakiri.io/github/jhsu802701/insert_from_file/master)
5
6
  [![Dependency Status](https://gemnasium.com/badges/github.com/jhsu802701/insert_from_file.svg)](https://gemnasium.com/github.com/jhsu802701/insert_from_file)
@@ -1,4 +1,4 @@
1
1
  #
2
2
  module InsertFromFile
3
- VERSION = '0.0.0'.freeze
3
+ VERSION = '0.0.1'.freeze
4
4
  end
@@ -1,3 +1,4 @@
1
+ # rubocop:disable Metrics/MethodLength
1
2
  require 'insert_from_file/version'
2
3
  require 'line_containing'
3
4
  require 'string_in_file'
@@ -23,5 +24,36 @@ module InsertFromFile
23
24
  LineContaining.delete_between(str1, str2, file_dest)
24
25
  InsertFromFile.add_after(file_source, file_dest, str1)
25
26
  end
27
+
28
+ def self.add_beginning(file_source, file_dest)
29
+ path_old = file_dest
30
+ path_new = "#{path_old}.new"
31
+ file_w = open(path_new, 'w')
32
+ File.readlines(file_source).each do |line|
33
+ file_w.write(line)
34
+ end
35
+ File.readlines(path_old).each do |line|
36
+ file_w.write(line)
37
+ end
38
+ file_w.close
39
+ system("rm #{path_old}")
40
+ system("mv #{path_new} #{path_old}")
41
+ end
42
+
43
+ def self.add_end(file_source, file_dest)
44
+ path_old = file_dest
45
+ path_new = "#{path_old}.new"
46
+ file_w = open(path_new, 'w')
47
+ File.readlines(path_old).each do |line|
48
+ file_w.write(line)
49
+ end
50
+ File.readlines(file_source).each do |line|
51
+ file_w.write(line)
52
+ end
53
+ file_w.close
54
+ system("rm #{path_old}")
55
+ system("mv #{path_new} #{path_old}")
56
+ end
26
57
  end
27
58
  # Your new gem is a module by default. You may wish to use a class instead.
59
+ # rubocop:enable Metrics/MethodLength
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: insert_from_file
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Hsu