thrifty_file_applier 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.idea/.gitignore +8 -0
- data/.idea/inspectionProfiles/Project_Default.xml +6 -0
- data/.idea/modules.xml +8 -0
- data/.idea/untitled3.iml +72 -0
- data/.idea/vcs.xml +6 -0
- data/.rspec +3 -0
- data/.rubocop.yml +15 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +56 -0
- data/LICENSE.txt +21 -0
- data/README.md +44 -0
- data/Rakefile +12 -0
- data/lib/thrifty_file_applier/version.rb +5 -0
- data/lib/thrifty_file_applier.rb +65 -0
- data/sample/sample.rb +14 -0
- data/sig/update_watcher.rbs +4 -0
- metadata +62 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 58b42a98514fbbff94d3e6ccba1c76911823da29916f3679fa069314f936c6a3
|
4
|
+
data.tar.gz: af23d20cddb15c5dbd36faf8944b9521ae4b9d935bb309e0c2f53d1af4a2094b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3b60306546dbb495d4d625e5af866d85793a4c9683316a75d75af81cabaf0bd071e2cd1ef50321e884b18bb359d0bc8f671f98d479f542c4bc7120c97110a401
|
7
|
+
data.tar.gz: 44bca0172cb783cad89490afd9cdcaf2a174c00fb0cba092af990fd15905c82aa05039e3fdfd571319bbada861cbe20845f3fd2e5bfaab522cddf1f9362c54ef
|
data/.idea/.gitignore
ADDED
data/.idea/modules.xml
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project version="4">
|
3
|
+
<component name="ProjectModuleManager">
|
4
|
+
<modules>
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/untitled3.iml" filepath="$PROJECT_DIR$/.idea/untitled3.iml" />
|
6
|
+
</modules>
|
7
|
+
</component>
|
8
|
+
</project>
|
data/.idea/untitled3.iml
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<module type="RUBY_MODULE" version="4">
|
3
|
+
<component name="ModuleRunConfigurationManager">
|
4
|
+
<shared />
|
5
|
+
</component>
|
6
|
+
<component name="NewModuleRootManager">
|
7
|
+
<content url="file://$MODULE_DIR$">
|
8
|
+
<sourceFolder url="file://$MODULE_DIR$/features" isTestSource="true" />
|
9
|
+
<sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
|
10
|
+
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
|
11
|
+
</content>
|
12
|
+
<orderEntry type="jdk" jdkName="ruby-3.1.1-p18 (2)" jdkType="RUBY_SDK" />
|
13
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
14
|
+
<orderEntry type="library" scope="PROVIDED" name="ast (v2.4.2, ruby-3.1.1-p18 (2)) [gem]" level="application" />
|
15
|
+
<orderEntry type="library" scope="PROVIDED" name="bundler (v2.3.7, ruby-3.1.1-p18 (2)) [gem]" level="application" />
|
16
|
+
<orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.5.0, ruby-3.1.1-p18 (2)) [gem]" level="application" />
|
17
|
+
<orderEntry type="library" scope="PROVIDED" name="parallel (v1.22.1, ruby-3.1.1-p18 (2)) [gem]" level="application" />
|
18
|
+
<orderEntry type="library" scope="PROVIDED" name="parser (v3.1.2.0, ruby-3.1.1-p18 (2)) [gem]" level="application" />
|
19
|
+
<orderEntry type="library" scope="PROVIDED" name="rainbow (v3.1.1, ruby-3.1.1-p18 (2)) [gem]" level="application" />
|
20
|
+
<orderEntry type="library" scope="PROVIDED" name="rake (v13.0.6, ruby-3.1.1-p18 (2)) [gem]" level="application" />
|
21
|
+
<orderEntry type="library" scope="PROVIDED" name="regexp_parser (v2.5.0, ruby-3.1.1-p18 (2)) [gem]" level="application" />
|
22
|
+
<orderEntry type="library" scope="PROVIDED" name="rexml (v3.2.5, ruby-3.1.1-p18 (2)) [gem]" level="application" />
|
23
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec (v3.11.0, ruby-3.1.1-p18 (2)) [gem]" level="application" />
|
24
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.11.0, ruby-3.1.1-p18 (2)) [gem]" level="application" />
|
25
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.11.0, ruby-3.1.1-p18 (2)) [gem]" level="application" />
|
26
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.11.1, ruby-3.1.1-p18 (2)) [gem]" level="application" />
|
27
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.11.0, ruby-3.1.1-p18 (2)) [gem]" level="application" />
|
28
|
+
<orderEntry type="library" scope="PROVIDED" name="rubocop (v1.30.0, ruby-3.1.1-p18 (2)) [gem]" level="application" />
|
29
|
+
<orderEntry type="library" scope="PROVIDED" name="rubocop-ast (v1.18.0, ruby-3.1.1-p18 (2)) [gem]" level="application" />
|
30
|
+
<orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.11.0, ruby-3.1.1-p18 (2)) [gem]" level="application" />
|
31
|
+
<orderEntry type="library" scope="PROVIDED" name="unicode-display_width (v2.1.0, ruby-3.1.1-p18 (2)) [gem]" level="application" />
|
32
|
+
</component>
|
33
|
+
<component name="RakeTasksCache">
|
34
|
+
<option name="myRootTask">
|
35
|
+
<RakeTaskImpl id="rake">
|
36
|
+
<subtasks>
|
37
|
+
<RakeTaskImpl description="Build thrifty_file_applier-0.1.0.gem into the pkg directory" fullCommand="build" id="build" />
|
38
|
+
<RakeTaskImpl id="build">
|
39
|
+
<subtasks>
|
40
|
+
<RakeTaskImpl description="Generate SHA512 checksum if thrifty_file_applier-0.1.0.gem into the checksums directory" fullCommand="build:checksum" id="checksum" />
|
41
|
+
</subtasks>
|
42
|
+
</RakeTaskImpl>
|
43
|
+
<RakeTaskImpl description="Remove any temporary products" fullCommand="clean" id="clean" />
|
44
|
+
<RakeTaskImpl description="Remove any generated files" fullCommand="clobber" id="clobber" />
|
45
|
+
<RakeTaskImpl description="Build and install thrifty_file_applier-0.1.0.gem into system gems" fullCommand="install" id="install" />
|
46
|
+
<RakeTaskImpl id="install">
|
47
|
+
<subtasks>
|
48
|
+
<RakeTaskImpl description="Build and install thrifty_file_applier-0.1.0.gem into system gems without network access" fullCommand="install:local" id="local" />
|
49
|
+
</subtasks>
|
50
|
+
</RakeTaskImpl>
|
51
|
+
<RakeTaskImpl description="Create tag v0.1.0 and build and push thrifty_file_applier-0.1.0.gem to rubygems.org" fullCommand="release[remote]" id="release[remote]" />
|
52
|
+
<RakeTaskImpl description="Run RuboCop" fullCommand="rubocop" id="rubocop" />
|
53
|
+
<RakeTaskImpl id="rubocop">
|
54
|
+
<subtasks>
|
55
|
+
<RakeTaskImpl description="Autocorrect RuboCop offenses" fullCommand="rubocop:auto_correct" id="auto_correct" />
|
56
|
+
</subtasks>
|
57
|
+
</RakeTaskImpl>
|
58
|
+
<RakeTaskImpl description="Run RSpec code examples" fullCommand="spec" id="spec" />
|
59
|
+
<RakeTaskImpl description="" fullCommand="default" id="default" />
|
60
|
+
<RakeTaskImpl description="" fullCommand="release" id="release" />
|
61
|
+
<RakeTaskImpl id="release">
|
62
|
+
<subtasks>
|
63
|
+
<RakeTaskImpl description="" fullCommand="release:guard_clean" id="guard_clean" />
|
64
|
+
<RakeTaskImpl description="" fullCommand="release:rubygem_push" id="rubygem_push" />
|
65
|
+
<RakeTaskImpl description="" fullCommand="release:source_control_push" id="source_control_push" />
|
66
|
+
</subtasks>
|
67
|
+
</RakeTaskImpl>
|
68
|
+
</subtasks>
|
69
|
+
</RakeTaskImpl>
|
70
|
+
</option>
|
71
|
+
</component>
|
72
|
+
</module>
|
data/.idea/vcs.xml
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.6
|
3
|
+
|
4
|
+
Style/StringLiterals:
|
5
|
+
Enabled: true
|
6
|
+
EnforcedStyle: double_quotes
|
7
|
+
|
8
|
+
Style/StringLiteralsInInterpolation:
|
9
|
+
Enabled: true
|
10
|
+
EnforcedStyle: double_quotes
|
11
|
+
|
12
|
+
Layout/LineLength:
|
13
|
+
Max: 120
|
14
|
+
Style/EndOfLine:
|
15
|
+
EnforcedStyle: lf
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
+
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
8
|
+
|
9
|
+
## Our Standards
|
10
|
+
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
12
|
+
|
13
|
+
* Demonstrating empathy and kindness toward other people
|
14
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
15
|
+
* Giving and gracefully accepting constructive feedback
|
16
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
17
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
18
|
+
|
19
|
+
Examples of unacceptable behavior include:
|
20
|
+
|
21
|
+
* The use of sexualized language or imagery, and sexual attention or
|
22
|
+
advances of any kind
|
23
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
24
|
+
* Public or private harassment
|
25
|
+
* Publishing others' private information, such as a physical or email
|
26
|
+
address, without their explicit permission
|
27
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
28
|
+
professional setting
|
29
|
+
|
30
|
+
## Enforcement Responsibilities
|
31
|
+
|
32
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
33
|
+
|
34
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
35
|
+
|
36
|
+
## Scope
|
37
|
+
|
38
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
39
|
+
|
40
|
+
## Enforcement
|
41
|
+
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at TODO: Write your email address. All complaints will be reviewed and investigated promptly and fairly.
|
43
|
+
|
44
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
45
|
+
|
46
|
+
## Enforcement Guidelines
|
47
|
+
|
48
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
49
|
+
|
50
|
+
### 1. Correction
|
51
|
+
|
52
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
53
|
+
|
54
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
55
|
+
|
56
|
+
### 2. Warning
|
57
|
+
|
58
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
59
|
+
|
60
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
61
|
+
|
62
|
+
### 3. Temporary Ban
|
63
|
+
|
64
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
65
|
+
|
66
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
67
|
+
|
68
|
+
### 4. Permanent Ban
|
69
|
+
|
70
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
71
|
+
|
72
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
73
|
+
|
74
|
+
## Attribution
|
75
|
+
|
76
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
77
|
+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
78
|
+
|
79
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
80
|
+
|
81
|
+
[homepage]: https://www.contributor-covenant.org
|
82
|
+
|
83
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
84
|
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
thrifty_file_applier (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ast (2.4.2)
|
10
|
+
diff-lcs (1.5.0)
|
11
|
+
parallel (1.22.1)
|
12
|
+
parser (3.1.2.0)
|
13
|
+
ast (~> 2.4.1)
|
14
|
+
rainbow (3.1.1)
|
15
|
+
rake (13.0.6)
|
16
|
+
regexp_parser (2.5.0)
|
17
|
+
rexml (3.2.5)
|
18
|
+
rspec (3.11.0)
|
19
|
+
rspec-core (~> 3.11.0)
|
20
|
+
rspec-expectations (~> 3.11.0)
|
21
|
+
rspec-mocks (~> 3.11.0)
|
22
|
+
rspec-core (3.11.0)
|
23
|
+
rspec-support (~> 3.11.0)
|
24
|
+
rspec-expectations (3.11.0)
|
25
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
26
|
+
rspec-support (~> 3.11.0)
|
27
|
+
rspec-mocks (3.11.1)
|
28
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
29
|
+
rspec-support (~> 3.11.0)
|
30
|
+
rspec-support (3.11.0)
|
31
|
+
rubocop (1.30.0)
|
32
|
+
parallel (~> 1.10)
|
33
|
+
parser (>= 3.1.0.0)
|
34
|
+
rainbow (>= 2.2.2, < 4.0)
|
35
|
+
regexp_parser (>= 1.8, < 3.0)
|
36
|
+
rexml (>= 3.2.5, < 4.0)
|
37
|
+
rubocop-ast (>= 1.18.0, < 2.0)
|
38
|
+
ruby-progressbar (~> 1.7)
|
39
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
40
|
+
rubocop-ast (1.18.0)
|
41
|
+
parser (>= 3.1.1.0)
|
42
|
+
ruby-progressbar (1.11.0)
|
43
|
+
unicode-display_width (2.1.0)
|
44
|
+
|
45
|
+
PLATFORMS
|
46
|
+
x64-mingw-ucrt
|
47
|
+
x86_64-linux
|
48
|
+
|
49
|
+
DEPENDENCIES
|
50
|
+
rake (~> 13.0)
|
51
|
+
rspec (~> 3.0)
|
52
|
+
rubocop (~> 1.21)
|
53
|
+
thrifty_file_applier!
|
54
|
+
|
55
|
+
BUNDLED WITH
|
56
|
+
2.3.7
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2022 TODO: Write your name
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# ThriftyFileApplier
|
2
|
+
This program can thrift applications of files.
|
3
|
+
It applies the specified file and records the time. In the second or after execution time, it compares the last applied time and the modification time of target files.
|
4
|
+
It it applies file again if the last modification time is newer than the last applied time.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Install the gem and add to the application's Gemfile by executing:
|
9
|
+
|
10
|
+
$ bundle add thrifty_file_applier
|
11
|
+
|
12
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
13
|
+
|
14
|
+
$ gem install thrifty_file_applier
|
15
|
+
|
16
|
+
## Usage
|
17
|
+
`ThiriftyFileApplier.applier` method generates the applier.
|
18
|
+
The first argument is a file path to record the last applied time, and the second argument is the source file or directory.
|
19
|
+
It needs to be passed the block.
|
20
|
+
`#apply` method will apply the given block if needed.
|
21
|
+
```ruby
|
22
|
+
require "thrifty_file_applier"
|
23
|
+
|
24
|
+
applier = ThriftyFileApplier.applier("tmp/last_application_time", "source") do
|
25
|
+
puts "compile"
|
26
|
+
end
|
27
|
+
FileUtils.touch "source/file"
|
28
|
+
applier.apply # => compile
|
29
|
+
applier.apply # => nil
|
30
|
+
FileUtils.touch "source/file"
|
31
|
+
applier.apply # => compile
|
32
|
+
FileUtils.rm "source/file"
|
33
|
+
applier.apply # => compile
|
34
|
+
```
|
35
|
+
|
36
|
+
## Development
|
37
|
+
|
38
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
39
|
+
|
40
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
41
|
+
|
42
|
+
## License
|
43
|
+
|
44
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "thrifty_file_applier/version"
|
4
|
+
require "fileutils"
|
5
|
+
|
6
|
+
# Executes specified block only if source file had been updated.
|
7
|
+
module ThriftyFileApplier
|
8
|
+
class Error < StandardError; end
|
9
|
+
|
10
|
+
def self.applier(last_execution_log_path, source_path, &executor)
|
11
|
+
Applier.new(last_execution_log_path, source_path, &executor)
|
12
|
+
end
|
13
|
+
|
14
|
+
# Actual applier class.
|
15
|
+
class Applier
|
16
|
+
def initialize(last_execution_log_path, source_path, &executor)
|
17
|
+
@last_execution_log_path = Pathname.new last_execution_log_path
|
18
|
+
@update_source_path = Pathname.new source_path
|
19
|
+
@executor = executor
|
20
|
+
end
|
21
|
+
|
22
|
+
def apply
|
23
|
+
exec_if_needed(&@executor)
|
24
|
+
end
|
25
|
+
|
26
|
+
def exec_if_needed(&block)
|
27
|
+
return if last_execution_time >= last_update_time
|
28
|
+
|
29
|
+
log_execution(&block)
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def log_execution
|
35
|
+
execution_time = Time.now.to_f
|
36
|
+
result = yield
|
37
|
+
FileUtils.mkdir_p(@last_execution_log_path.dirname)
|
38
|
+
@last_execution_log_path.open("wb") { |f| f.write(execution_time) }
|
39
|
+
result
|
40
|
+
end
|
41
|
+
|
42
|
+
def last_update_time
|
43
|
+
if @update_source_path.directory? && @update_source_path.children.size.positive?
|
44
|
+
newest_mtime path
|
45
|
+
else
|
46
|
+
@update_source_path.mtime
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def last_execution_time
|
51
|
+
time_float = if @last_execution_log_path.exist?
|
52
|
+
@last_execution_log_path.read.to_f
|
53
|
+
else
|
54
|
+
0.0
|
55
|
+
end
|
56
|
+
Time.at time_float
|
57
|
+
end
|
58
|
+
|
59
|
+
def newest_mtime(path)
|
60
|
+
path.each_child
|
61
|
+
.map { File.mtime(_1) }
|
62
|
+
.max
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
data/sample/sample.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "thrifty_file_applier"
|
4
|
+
|
5
|
+
applier = ThriftyFileApplier.applier("tmp/last_application_time", "source") do
|
6
|
+
puts "compile"
|
7
|
+
end
|
8
|
+
FileUtils.touch "source/file"
|
9
|
+
applier.apply # => compile
|
10
|
+
applier.apply # => nil
|
11
|
+
FileUtils.touch "source/file"
|
12
|
+
applier.apply # => compile
|
13
|
+
FileUtils.rm "source/file"
|
14
|
+
applier.apply # => compile
|
metadata
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: thrifty_file_applier
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yudai Tanaka
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-05-30 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email:
|
15
|
+
- ytnk531@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- ".idea/.gitignore"
|
21
|
+
- ".idea/inspectionProfiles/Project_Default.xml"
|
22
|
+
- ".idea/modules.xml"
|
23
|
+
- ".idea/untitled3.iml"
|
24
|
+
- ".idea/vcs.xml"
|
25
|
+
- ".rspec"
|
26
|
+
- ".rubocop.yml"
|
27
|
+
- CODE_OF_CONDUCT.md
|
28
|
+
- Gemfile
|
29
|
+
- Gemfile.lock
|
30
|
+
- LICENSE.txt
|
31
|
+
- README.md
|
32
|
+
- Rakefile
|
33
|
+
- lib/thrifty_file_applier.rb
|
34
|
+
- lib/thrifty_file_applier/version.rb
|
35
|
+
- sample/sample.rb
|
36
|
+
- sig/update_watcher.rbs
|
37
|
+
homepage: https://github.com/ytnk531/thirifty_file_appiler
|
38
|
+
licenses:
|
39
|
+
- MIT
|
40
|
+
metadata:
|
41
|
+
homepage_uri: https://github.com/ytnk531/thirifty_file_appiler
|
42
|
+
source_code_uri: https://github.com/ytnk531/thirifty_file_appiler
|
43
|
+
post_install_message:
|
44
|
+
rdoc_options: []
|
45
|
+
require_paths:
|
46
|
+
- lib
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: 2.6.0
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
requirements: []
|
58
|
+
rubygems_version: 3.3.7
|
59
|
+
signing_key:
|
60
|
+
specification_version: 4
|
61
|
+
summary: Applies files if needed.
|
62
|
+
test_files: []
|