geny 2.3.0 → 2.4.0

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: fe20ce2aad56f9d9ea091a83694d9a10704c4841
4
- data.tar.gz: 81021763bcf6b5681f7fb428ce25ba47d9d21a8c
3
+ metadata.gz: 63e0940e39b3fae585bf25fc2203664e3149a9d4
4
+ data.tar.gz: 0ce7235f5553af6c59bee867cda1e5ab19fdd70c
5
5
  SHA512:
6
- metadata.gz: 30433c06880fef7821d918ee93b7e4619c37a344e68817990c34e9a44131e72442c20cefc89c8347c08cd5004dc114f0b5398c654ed3638c4ac967a68810b35f
7
- data.tar.gz: b618741dfd41d3f0fe8780486df2cd43101b7cc7e304cedf0e23831c1686cd287105cda75076b58b0f22a65f2c41ecf03cdfefdb89ff90562a417c7fb4781f82
6
+ metadata.gz: e49631f224c2741b318f7cf9f9a16b6fc857d176a4a156453d95b3729f3055f77b50a98eb37e4a4513198d80fa17a096f257928d118de0d8efbb31c04ad56915
7
+ data.tar.gz: 928ad9248746055f875d874ad19998c57a3185de9774bb4e946bbb8b328e618c1599938672239f5511a60c2d09c661e326e1d45d14f8ea398416d85dcf3bd2c7
@@ -8,6 +8,10 @@ module Geny
8
8
  class Files
9
9
  extend Forwardable
10
10
 
11
+ def initialize(ui:)
12
+ @ui = ui
13
+ end
14
+
11
15
  # @!method create
12
16
  # Create a file
13
17
  # @see TTY::File.create
@@ -68,6 +72,31 @@ module Geny
68
72
  # files.insert("Gemfile", "gem 'geny'", after: /gem 'rails'\n/)
69
73
  def_delegator TTY::File, :safe_inject_into_file, :insert
70
74
 
75
+ # Move a file
76
+ # @param source [String]
77
+ # @param dest [String]
78
+ #
79
+ # @example
80
+ # files.move "Gemfile", "Gemfile.bak"
81
+ def move(source, dest, force: false, verbose: true)
82
+ @ui.status("move", source) if verbose
83
+ FileUtils.mv(source, dest, force: force)
84
+ end
85
+
86
+ # Change directory
87
+ # @param path [String]
88
+ #
89
+ # @example
90
+ # files.chdir "foo" do
91
+ # # do something inside foo/
92
+ # end
93
+ def chdir(path, verbose: true, &block)
94
+ @ui.status("cd", path) if verbose
95
+ Dir.chdir(path, &block)
96
+ ensure
97
+ @ui.status("cd", "-") if verbose
98
+ end
99
+
71
100
  # Change the permissions of a file
72
101
  # @see TTY::File.chmod
73
102
  #
@@ -30,7 +30,7 @@ module Geny
30
30
  # A utility for interacting with files
31
31
  # @return [Actions::Files]
32
32
  def files
33
- Actions::Files.new
33
+ Actions::Files.new(ui: ui)
34
34
  end
35
35
 
36
36
  # A utility for bulk find-and-replace operations
data/lib/geny/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Geny
2
- VERSION = "2.3.0"
2
+ VERSION = "2.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geny
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ray Zane
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-12-22 00:00:00.000000000 Z
11
+ date: 2019-12-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: argy