skap 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b24eb7212466fb9d393d5d3847d279bf502c6ea798d5b6169443df4c704949e8
4
- data.tar.gz: 5c45d5fd262e0b9ef739f8d4145ca6aab80ada327e2c211b6d7aa0449a2d19c7
3
+ metadata.gz: f7487b2bdb15b4a94bf5e9f5862eeebaf20f6a23b9e7c3aae850fdf6350283c3
4
+ data.tar.gz: 55c46f71dd2c1bdf6a04c0160c9cbf378c14ae13dd244606d0c0cd170ff0defb
5
5
  SHA512:
6
- metadata.gz: cf53061aa0925dbc45a03068bf4565f7c6de5fa1033ea946a209667cec3194e16791bd0af89001f1bf66281b811eebe5515bf31eecd605f6071dea4ed05977f8
7
- data.tar.gz: 4dff3e1661ea6a77720be3c600add6a5af121c25490f579b1c66f34e7a129a627d4e44928b7ee75bd91da14459d43fb339afde31a7e16b1f0f035fbd0f612cc7
6
+ metadata.gz: 849759daeaffebc05744d58df836f6a7da9e703c48d3d273a0180449a0bd82fc911782a7ee1f2df1ad9f6694361e364f5bd6b3704a20d85e778100c72cb98e96
7
+ data.tar.gz: dc7359b30974a0844520c45c858b178319f5d660e0fe5846de49a1c71c9dd30a69a26f6150462e62edeb459b56173a8962c6db1bd887bf0a683db55e8ec7aaa3
@@ -32,11 +32,7 @@ module Skap
32
32
 
33
33
  return unless shell("git submodule add -b #{branch} --depth 3 -- #{repo} #{dir}")
34
34
 
35
- sources_data = load_file(SOURCES)
36
- sources_data[dir] = {"file-extensions" => [], "ignored" => [], "indexed" => []}
37
-
38
- sources_data = sources_data.sort_by(&:first).to_h
39
- File.write(SOURCES, Psych.dump(sources_data, line_width: 100))
35
+ Files::Sources.new.add_source(dir)
40
36
  end
41
37
 
42
38
  # @param dir [String]
@@ -46,6 +42,8 @@ module Skap
46
42
  assert_empty_options(rest)
47
43
 
48
44
  shell("git submodule deinit -f -- #{dir} && git rm -f #{dir} && rm -rf .git/modules/#{dir}")
45
+
46
+ Files::Sources.new.delete_source(dir)
49
47
  end
50
48
 
51
49
  # @param dirs [Array<String>]
@@ -53,7 +51,12 @@ module Skap
53
51
  def update(*dirs)
54
52
  path_arg = dirs.empty? ? "" : "-- #{dirs.join(" ")}"
55
53
 
56
- shell("git submodule update --checkout --single-branch --recursive #{path_arg}")
54
+ commands = [
55
+ "git submodule init",
56
+ "git submodule update --checkout --single-branch --recursive #{path_arg}",
57
+ ]
58
+
59
+ shell(commands.join(" && "))
57
60
  end
58
61
  end
59
62
  end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Skap
4
+ module CLI::Version
5
+ include Command
6
+ extend self
7
+
8
+ # @return [void]
9
+ def start
10
+ puts "Skap, v#{Skap::VERSION}"
11
+ end
12
+ end
13
+ end
data/lib/skap/cli.rb CHANGED
@@ -6,6 +6,7 @@ require "io/console"
6
6
  require "psych"
7
7
 
8
8
  require_relative "command"
9
+ require_relative "string_utils"
9
10
  require_relative "yaml_file"
10
11
 
11
12
  require_relative "files/menu"
@@ -20,10 +21,11 @@ module Skap
20
21
  section, command, *rest = argv
21
22
 
22
23
  case section
23
- when "works" then CLI::Works.start(command, rest)
24
24
  when "help", "--help", "-h", nil then CLI::Help.start
25
25
  when "init" then CLI::Init.start(command, rest)
26
26
  when "sources" then CLI::Sources.start(command, rest)
27
+ when "version", "--version", "-v" then CLI::Version.start
28
+ when "works" then CLI::Works.start(command, rest)
27
29
  else
28
30
  raise ArgumentError, "Unknown section: #{section}"
29
31
  end
@@ -37,4 +39,5 @@ end
37
39
  require_relative "cli/help"
38
40
  require_relative "cli/init"
39
41
  require_relative "cli/sources"
42
+ require_relative "cli/version"
40
43
  require_relative "cli/works"
@@ -5,6 +5,22 @@ module Skap
5
5
  class Sources < YAMLFile
6
6
  self.file_name = "sources.yaml"
7
7
 
8
+ # @param dir [String]
9
+ # @return [void]
10
+ def add_source(dir)
11
+ file[dir] = {"file-extensions" => [], "ignored" => [], "indexed" => []}
12
+ @file = file.sort_by(&:first).to_h
13
+
14
+ update_file
15
+ end
16
+
17
+ # @param dir [String]
18
+ # @return [void]
19
+ def delete_source(dir)
20
+ file.delete(dir)
21
+ update_file
22
+ end
23
+
8
24
  # @param key [String]
9
25
  # @param dirs [Array<String>]
10
26
  # @return [Hash<String, Array<String>>]
@@ -12,7 +12,7 @@ module Skap
12
12
  file[document_path] = document
13
13
  @file = file.sort_by(&:first).to_h
14
14
 
15
- File.write(self.class.file_name, Psych.dump(file, line_width: 100))
15
+ update_file
16
16
  end
17
17
 
18
18
  # @return [Set<String>]
data/lib/skap/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Skap
4
- VERSION = "1.0.0"
4
+ VERSION = "1.0.2"
5
5
  end
@@ -20,5 +20,10 @@ module Skap
20
20
  def load_file
21
21
  Psych.load_file(self.class.file_name, symbolize_names: false) || {}
22
22
  end
23
+
24
+ # @return [void]
25
+ def update_file
26
+ File.write(self.class.file_name, Psych.dump(file, line_width: 100))
27
+ end
23
28
  end
24
29
  end
data/menu.yaml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
- - cmd: help
2
+ - cmd: ["help", "--help", "-h"]
3
3
  text: "Show help message about supported commands."
4
4
  - cmd: ["init", "init DIRECTORY_PATH"]
5
5
  text: "Create configuration files in current directory or in DIRECTORY_PATH."
@@ -14,6 +14,8 @@
14
14
  Update git submodule from upstream in DIRECTORY or in all git submodules if DIRECTORY
15
15
  is not specified. You may pass one or more directory paths (DIRECTORY ...) to update
16
16
  their contents.
17
+ - cmd: ["version", "--version", "-v"]
18
+ text: "Show program version"
17
19
  - cmd: works
18
20
  children:
19
21
  - cmd: ["covered", "covered DIRECTORY ..."]
@@ -31,8 +33,8 @@
31
33
  - cmd: ["publish DOCUMENT", "publish DOCUMENT FILE_PATH ..."]
32
34
  text:
33
35
  - >
34
- Save record about abstract (DOCUMENT) and pass list of file paths of sources
35
- (FILE_PATH ...) which relate to this abstract. You should prepend minus sign to file path
36
+ Save record about work (DOCUMENT) and pass list of file paths of sources
37
+ (FILE_PATH ...) which relate to this work. You should prepend minus sign to file path
36
38
  to exclude it from list of related sources. Examples:
37
39
  - >
38
40
  works publish _/docker/compose.md docs.docker.com/content/manuals/compose/**/*.md
data/skap.gemspec CHANGED
@@ -22,10 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.metadata["homepage_uri"] = spec.homepage
23
23
  spec.metadata["source_code_uri"] = spec.homepage
24
24
 
25
- spec.files =
26
- Dir.chdir(File.expand_path(__dir__)) do
27
- `git ls-files -z`.split("\x0").grep_v(%r{^spec/})
28
- end
25
+ spec.files = %w[Gemfile menu.yaml skap.gemspec] + Dir.glob("{exe,lib}/**/*", base: __dir__)
29
26
 
30
27
  spec.bindir = "exe"
31
28
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skap
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evgeniy Nochevnov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-09-28 00:00:00.000000000 Z
11
+ date: 2024-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec-core
@@ -87,20 +87,14 @@ executables:
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
- - ".bundle/config.template"
91
- - ".gitignore"
92
- - ".rubocop.yml"
93
90
  - Gemfile
94
- - Gemfile.lock
95
- - README.md
96
- - bin/rubocop
97
- - bin/yard
98
91
  - exe/skap
99
92
  - lib/skap.rb
100
93
  - lib/skap/cli.rb
101
94
  - lib/skap/cli/help.rb
102
95
  - lib/skap/cli/init.rb
103
96
  - lib/skap/cli/sources.rb
97
+ - lib/skap/cli/version.rb
104
98
  - lib/skap/cli/works.rb
105
99
  - lib/skap/command.rb
106
100
  - lib/skap/files/menu.rb
@@ -132,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
126
  - !ruby/object:Gem::Version
133
127
  version: '0'
134
128
  requirements: []
135
- rubygems_version: 3.5.19
129
+ rubygems_version: 3.5.18
136
130
  signing_key:
137
131
  specification_version: 4
138
132
  summary: ''
@@ -1,7 +0,0 @@
1
- ---
2
- BUNDLE_GLOBAL_GEM_CACHE: true
3
- BUNDLE_IGNORE_FUNDING_REQUESTS: true
4
- BUNDLE_IGNORE_MESSAGES: true
5
- BUNDLE_SHEBANG: ruby
6
- BUNDLE_SILENCE_DEPRECATIONS: false
7
- BUNDLE_SILENCE_ROOT_WARNING: false
data/.gitignore DELETED
@@ -1,3 +0,0 @@
1
- .bundle/config
2
- .yardoc
3
- *.gem
data/.rubocop.yml DELETED
@@ -1,20 +0,0 @@
1
- inherit_gem:
2
- rubocop-configs:
3
- - _all_cops.yml
4
- - _ruby.yml
5
- - gemspec.yml
6
- - performance.yml
7
-
8
- AllCops:
9
- TargetRubyVersion: 3.3
10
-
11
- Gemspec/DevelopmentDependencies:
12
- Enabled: false
13
-
14
- Lint/Debugger:
15
- DebuggerMethods:
16
- # Exclude "puts" from this list.
17
- Kernel: [warn, binding.irb, p, Kernel.binding.irb]
18
-
19
- Style/ClassAndModuleChildren:
20
- Enabled: false
data/Gemfile.lock DELETED
@@ -1,75 +0,0 @@
1
- GIT
2
- remote: https://github.com/crosspath/rubocop-configs.git
3
- revision: ef433c9f20720610194773a31ca1b89a7888e5e7
4
- specs:
5
- rubocop-configs (0.17.0)
6
- rake (>= 13.0)
7
-
8
- PATH
9
- remote: .
10
- specs:
11
- skap (1.0.0)
12
-
13
- GEM
14
- remote: https://rubygems.org/
15
- specs:
16
- ast (2.4.2)
17
- diff-lcs (1.5.1)
18
- json (2.7.2)
19
- language_server-protocol (3.17.0.3)
20
- parallel (1.26.3)
21
- parser (3.3.4.2)
22
- ast (~> 2.4.1)
23
- racc
24
- prism (1.0.0)
25
- psych (5.1.2)
26
- stringio
27
- racc (1.8.1)
28
- rainbow (3.1.1)
29
- rake (13.2.1)
30
- rdoc (6.7.0)
31
- psych (>= 4.0.0)
32
- regexp_parser (2.9.2)
33
- rspec-core (3.13.1)
34
- rspec-support (~> 3.13.0)
35
- rspec-expectations (3.13.2)
36
- diff-lcs (>= 1.2.0, < 2.0)
37
- rspec-support (~> 3.13.0)
38
- rspec-support (3.13.1)
39
- rubocop (1.66.1)
40
- json (~> 2.3)
41
- language_server-protocol (>= 3.17.0)
42
- parallel (~> 1.10)
43
- parser (>= 3.3.0.2)
44
- rainbow (>= 2.2.2, < 4.0)
45
- regexp_parser (>= 2.4, < 3.0)
46
- rubocop-ast (>= 1.32.2, < 2.0)
47
- ruby-progressbar (~> 1.7)
48
- unicode-display_width (>= 2.4.0, < 3.0)
49
- rubocop-ast (1.32.2)
50
- parser (>= 3.3.1.0)
51
- rubocop-performance (1.22.1)
52
- rubocop (>= 1.48.1, < 2.0)
53
- rubocop-ast (>= 1.31.1, < 2.0)
54
- ruby-progressbar (1.13.0)
55
- stringio (3.1.1)
56
- unicode-display_width (2.5.0)
57
- yard (0.9.37)
58
-
59
- PLATFORMS
60
- ruby
61
- x86_64-linux-gnu
62
-
63
- DEPENDENCIES
64
- prism
65
- rdoc
66
- rspec-core (~> 3.13)
67
- rspec-expectations (~> 3.13)
68
- rubocop (~> 1.66)
69
- rubocop-configs!
70
- rubocop-performance (~> 1.22)
71
- skap!
72
- yard (~> 0.9)
73
-
74
- BUNDLED WITH
75
- 2.5.19
data/README.md DELETED
@@ -1,119 +0,0 @@
1
- # Skap — document management system
2
-
3
- Word "skap" is a variation of Germanic words "skab"/"schap"/"schaf".
4
- Here it means storage closet with documents or books.
5
-
6
- Skap manages local copy of source documents published in git repositories.
7
- You may use Skap to track changes in source documents and to store revisions (versions)
8
- of your works based on these source documents, for example abstracts.
9
-
10
- ## Available commands
11
-
12
- ```plain
13
- help
14
- Show help message about supported commands.
15
- init
16
- init DIRECTORY_PATH
17
- Create configuration files in current directory or in DIRECTORY_PATH.
18
- sources
19
- add DIRECTORY REPO BRANCH
20
- Add git submodule into DIRECTORY from REPO and track BRANCH by default.
21
- delete DIRECTORY
22
- Delete git submodule from DIRECTORY.
23
- update
24
- update DIRECTORY ...
25
- Update git submodule from upstream in DIRECTORY or in all git submodules if DIRECTORY
26
- is not specified. You may pass one or more directory paths (DIRECTORY ...) to update their
27
- contents.
28
- works
29
- covered
30
- List files of sources which have been used for published works.
31
- ignored
32
- List ignored files.
33
- outdated
34
- List documents which may contain outdated information.
35
- publish DOCUMENT
36
- publish DOCUMENT FILE_PATH ...
37
- Save record about abstract (DOCUMENT) and pass list of file paths of sources (FILE_PATH ...)
38
- which relate to this abstract. You should prepend minus sign to file path to exclude it from
39
- list of related sources. Examples:
40
- works publish _/docker/compose.md docs.docker.com/content/manuals/compose/**/*.md
41
- works publish _/docker/compose.md -docs.docker.com/**/*.md
42
- uncovered
43
- List files of sources which have NOT been used for published works.
44
- unknown
45
- List files of sources which may be used for works or ignored.
46
- ```
47
-
48
- ## Suggested workflow
49
-
50
- 1. Install Skap: `gem install skap`
51
- 2. Initialize storage: `skap init ~/docs` (pass any path to storage)
52
- 3. Add sources: `skap sources add docker https://github.com/docker/docs.git main`
53
- (see command description in "Available commands")
54
- 4. Look into downloaded source files and fill entries in file "sources.yaml" in your storage.
55
- 5. Create file with your text (here it's known as "work") that relates somehow to source documents.
56
- 6. Save revision of source documents with current state of "work":
57
- `skap works publish _/docker/overview.md docker/content/get-started/docker-overview.md`
58
- (here "_/docker/overview.md" is path to your "work")
59
- 7. Commit changes into current git repository in your storage: `git commit ...` (see manual for git)
60
-
61
- Additionally you may push your changes into remote repository — see manual for git:
62
- git remote, git push.
63
-
64
- ## Additional files in storage
65
-
66
- You should store changes in these files with "git commit".
67
-
68
- Schema of file "sources.yaml":
69
-
70
- ```yaml
71
- %directory-name%:
72
- file-extensions: [%ext%, %ext%]
73
- ignored:
74
- - %file-path-pattern-in-this-directory%
75
- indexed:
76
- - %file-path-pattern-in-this-directory%
77
- ```
78
-
79
- Example of file "sources.yaml":
80
-
81
- ```yaml
82
- docker:
83
- file-extensions: [md, yaml]
84
- ignored:
85
- - "*.md"
86
- - compose.yaml
87
- indexed:
88
- - content/get-started/**/*.md
89
- ```
90
-
91
- Schema of file "versions.yaml":
92
-
93
- ```yaml
94
- %work-file-path%:
95
- date: %iso-date%
96
- sources:
97
- %source-file-path%:
98
- date: %iso-date%
99
- sha: %commit-sha%
100
- ```
101
-
102
- Example of file "versions.yaml":
103
-
104
- ```yaml
105
- _/docker/overview.md:
106
- date: 2024-12-31
107
- sources:
108
- docker/content/get-started/docker-overview.md:
109
- date: 2024-12-31
110
- sha: fc77b05ffe69070796a6a8630802e62b75304455
111
- ```
112
-
113
- ## Development
114
-
115
- ```shell
116
- bin/rubocop -A --only Style/FrozenStringLiteralComment,Layout/EmptyLineAfterMagicComment
117
- bin/rubocop -a
118
- bin/build
119
- ```
data/bin/rubocop DELETED
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require "rubygems"
5
- require "bundler/setup"
6
-
7
- load(Gem.bin_path("rubocop", "rubocop"))
data/bin/yard DELETED
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require "rubygems"
5
- require "bundler/setup"
6
-
7
- load(Gem.bin_path("yard", "yard"))