dev_context 1.0.0

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.
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DevContext
4
+ class ShellSetup
5
+ DEFAULT_PATH = File.expand_path("~/.dx.sh").freeze
6
+ MANAGED_MARKER = "DevContext shell integration generated by `dx init`".freeze
7
+
8
+ attr_reader :path
9
+
10
+ def initialize(path: ENV.fetch("DX_SHELL_PATH", DEFAULT_PATH))
11
+ @path = path
12
+ end
13
+
14
+ # Returns :created, :updated, or :unchanged.
15
+ def install!
16
+ unless File.exist?(path)
17
+ File.write(path, shell_script)
18
+ return :created
19
+ end
20
+
21
+ current = File.read(path)
22
+ return :unchanged if current == shell_script
23
+ return :unchanged unless managed_file?(current)
24
+
25
+ File.write(path, shell_script)
26
+ :updated
27
+ end
28
+
29
+ private
30
+
31
+ def managed_file?(content)
32
+ content.include?(MANAGED_MARKER)
33
+ end
34
+
35
+ def shell_script
36
+ <<~SH
37
+ #!/usr/bin/env sh
38
+ # #{MANAGED_MARKER}
39
+ # shellcheck shell=sh
40
+
41
+ dx() {
42
+ case "$1" in
43
+ cd|activate|pushd|popd)
44
+ local out
45
+ out="$(DX_SHELL_WRAPPED=1 command dev_context.rb "$@")" || return $?
46
+ case "$out" in
47
+ "# DX_SHELL_EVAL"*) eval "$out" ;;
48
+ *) printf "%s\\n" "$out" ;;
49
+ esac
50
+ ;;
51
+ *)
52
+ command dev_context.rb "$@"
53
+ ;;
54
+ esac
55
+ }
56
+ SH
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DevContext
4
+ class Status
5
+ def initialize(repo_path:)
6
+ @repo_path = repo_path
7
+ end
8
+
9
+ def counts
10
+ lines = porcelain_lines
11
+ result = { m: 0, u: 0, n: 0, d: 0, r: 0 }
12
+
13
+ lines.each do |line|
14
+ x = line[0]
15
+ y = line[1]
16
+
17
+ if line.start_with?("??")
18
+ result[:n] += 1
19
+ next
20
+ end
21
+
22
+ result[:m] += 1 if x == "M"
23
+ result[:u] += 1 if y == "M"
24
+ result[:n] += 1 if x == "A"
25
+ result[:d] += 1 if x == "D" || y == "D"
26
+ result[:r] += 1 if x == "R" || y == "R"
27
+ end
28
+
29
+ result
30
+ end
31
+
32
+ def one_line
33
+ c = counts
34
+ return "Up to date" if c.values.all?(&:zero?)
35
+
36
+ "m:#{c[:m]} u:#{c[:u]} n:#{c[:n]} d:#{c[:d]} r:#{c[:r]}"
37
+ end
38
+
39
+ private
40
+
41
+ attr_reader :repo_path
42
+
43
+ def porcelain_lines
44
+ cmd = %(git -C "#{repo_path}" status --porcelain 2>/dev/null)
45
+ out = `#{cmd}`
46
+ return [] unless $?.success?
47
+
48
+ out.lines.map(&:chomp)
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DevContext
4
+ RELEASES = [
5
+ ["1.0.0", '2026-05-12']
6
+ ].freeze
7
+ VERSION = RELEASES.last.first
8
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "dev_context/version"
4
+ require_relative "dev_context/config"
5
+ require_relative "dev_context/matcher"
6
+ require_relative "dev_context/commands/init"
7
+ require_relative "dev_context/commands/help"
8
+ require_relative "dev_context/commands/support"
9
+ require_relative "dev_context/commands/context_lifecycle"
10
+ require_relative "dev_context/commands/git_ops"
11
+ require_relative "dev_context/commands/find"
12
+ require_relative "dev_context/commands/search_helpers"
13
+ require_relative "dev_context/commands/repos"
14
+ require_relative "dev_context/commands/stashes"
15
+ require_relative "dev_context/commands/status"
16
+ require_relative "dev_context/commands/remove"
17
+ require_relative "dev_context/shell_emitter"
18
+ require_relative "dev_context/shell_setup"
19
+ require_relative "dev_context/status"
20
+ require_relative "dev_context/cli"
21
+
22
+ module DevContext
23
+ class Error < StandardError; end
24
+ end
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dev_context
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Alan Stebbens
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: fuubar
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '0'
19
+ type: :development
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '0'
26
+ - !ruby/object:Gem::Dependency
27
+ name: rake
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '13.0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '13.0'
40
+ - !ruby/object:Gem::Dependency
41
+ name: rspec
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '3.0'
47
+ type: :development
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '3.0'
54
+ description: |
55
+ DevContext (aka `dx`) is a developer context manager that unifies directory-level context
56
+ switching, multi-repo awareness, and Git-aware introspection. It helps you manage multiple
57
+ active projects with an activation stack.
58
+ email:
59
+ - aks@stebbens.org
60
+ executables:
61
+ - dev_context.rb
62
+ extensions: []
63
+ extra_rdoc_files: []
64
+ files:
65
+ - CHANGELOG.md
66
+ - CODE_OF_CONDUCT.md
67
+ - DESIGN.md
68
+ - LICENSE.txt
69
+ - README.md
70
+ - bin/console
71
+ - bin/dev_context.rb
72
+ - bin/setup
73
+ - lib/dev_context.rb
74
+ - lib/dev_context/cli.rb
75
+ - lib/dev_context/commands/context_lifecycle.rb
76
+ - lib/dev_context/commands/find.rb
77
+ - lib/dev_context/commands/git_ops.rb
78
+ - lib/dev_context/commands/help.rb
79
+ - lib/dev_context/commands/init.rb
80
+ - lib/dev_context/commands/remove.rb
81
+ - lib/dev_context/commands/repos.rb
82
+ - lib/dev_context/commands/search_helpers.rb
83
+ - lib/dev_context/commands/stashes.rb
84
+ - lib/dev_context/commands/status.rb
85
+ - lib/dev_context/commands/support.rb
86
+ - lib/dev_context/config.rb
87
+ - lib/dev_context/matcher.rb
88
+ - lib/dev_context/shell_emitter.rb
89
+ - lib/dev_context/shell_setup.rb
90
+ - lib/dev_context/status.rb
91
+ - lib/dev_context/version.rb
92
+ homepage: https://github.com/aks/dev_context
93
+ licenses:
94
+ - MIT
95
+ metadata:
96
+ allowed_push_host: https://rubygems.org
97
+ source_code_uri: https://github.com/aks/dev_context
98
+ changelog_uri: https://github.com/aks/dev_context/blob/main/CHANGELOG.md
99
+ rdoc_options: []
100
+ require_paths:
101
+ - lib
102
+ required_ruby_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: 3.2.0
107
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ requirements: []
113
+ rubygems_version: 4.0.11
114
+ specification_version: 4
115
+ summary: A developer context manager for multi-repo workflows
116
+ test_files: []