mistilteinn 0.1.1 → 0.1.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.
@@ -8,27 +8,28 @@ OVERVIEW
8
8
  Mistilteinn for shell is a comamnd to support a development style for
9
9
  using git and redmine.
10
10
 
11
- Prerequires
11
+ Prerequisites
12
12
  ------------------------------
13
13
 
14
14
  * Ruby 1.8.7
15
15
  * RubyGems 1.4.2 or later
16
16
  * git subcommands https://github.com/mistilteinn/git-tools
17
+ * Git Hooks https://github.com/bleis-tift/Git-Hooks
17
18
 
18
19
  Install
19
20
  ------------------------------
20
21
 
21
- $ gem install mistilteinn
22
+ $ gem install mistilteinn
22
23
 
23
24
  Setup for each project
24
25
  ------------------------------
25
26
 
26
27
  To use mistilteinn, run `mistilteinn init` at each project dirctory.
27
28
 
28
- $ cd /path/to/project
29
- $ git init
30
- $ mistilteinn init
31
- $ vim .mistilteinn/config.yaml
29
+ $ cd /path/to/project
30
+ $ git init
31
+ $ mistilteinn init
32
+ $ vim .mistilteinn/config.yaml
32
33
 
33
34
  Usage
34
35
  ------------------------------
@@ -37,24 +38,24 @@ Usage
37
38
 
38
39
  Check if miltilteinn works:
39
40
 
40
- $ mistilteinn self-check
41
+ $ mistilteinn self-check
41
42
 
42
43
  ### init
43
44
 
44
45
  Initialize working directory for mistilteinn:
45
46
 
46
- $ mistilteinn init
47
- $ vim .mistilteinn/config.yaml
47
+ $ mistilteinn init
48
+ $ vim .mistilteinn/config.yaml
48
49
 
49
50
  ### list ticket
50
51
 
51
- $ mistilteinn list
52
+ $ mistilteinn list
52
53
 
53
54
  ### create ticket
54
55
 
55
- $ mistilteinn create hoge
56
+ $ mistilteinn create hoge
56
57
 
57
- Build(developper only)
58
+ Build(developer only)
58
59
  ------------------------------
59
60
 
60
61
  ### Prerequires
@@ -84,6 +85,8 @@ AUTHOR
84
85
 
85
86
  * @mzp
86
87
  * @suer
88
+ * @shimomura1004
89
+ * @mallowlabs
87
90
 
88
91
  License
89
92
  -----------------------
@@ -1,6 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  # -*- mode:ruby; coding:utf-8 -*-
3
- require 'pp'
4
3
  require 'subcommand'
5
4
  require 'mistilteinn/config'
6
5
  require 'mistilteinn/git'
@@ -7,7 +7,7 @@ module Mistilteinn
7
7
 
8
8
  def initialize(obj)
9
9
  obj.command name do|opts|
10
- opts.description = 'show current ticket list'
10
+ opts.description = desc
11
11
  end
12
12
  end
13
13
 
@@ -0,0 +1,11 @@
1
+ module Mistilteinn::Cli
2
+ class Edit < ::Mistilteinn::Cli::Command
3
+ name :edit
4
+ desc 'edit specified ticket'
5
+
6
+ def action
7
+ its.edit args
8
+ end
9
+ end
10
+ end
11
+
@@ -23,8 +23,8 @@ module Mistilteinn::Cli
23
23
  path = Pathname(::Mistilteinn::Git.root) + name
24
24
  path.tap {
25
25
  unless path.exist?
26
- puts "mkdir -p #{config}"
27
- config.mkpath
26
+ puts "mkdir -p #{path.to_s}"
27
+ path.mkpath
28
28
  end
29
29
  }
30
30
  end
@@ -4,8 +4,8 @@
4
4
  module Mistilteinn
5
5
  module Git
6
6
  class << self
7
- def config(name)
8
- cmd "git config #{name}"
7
+ def config(name, value=nil)
8
+ cmd "git config #{name} #{value or ''}"
9
9
  end
10
10
 
11
11
  def root
@@ -1,156 +1,98 @@
1
1
  # -*- mode:ruby; coding:utf-8 -*-
2
2
  require 'tempfile'
3
3
 
4
+ class Tempfile
5
+ def edit(editor=nil)
6
+ mtime_before_edit = self.mtime
7
+ self.close
8
+ system "#{editor || ENV["EDITOR"]} #{self.path}"
9
+ self.open
10
+ return self.mtime != mtime_before_edit
11
+ end
12
+ def content=(content)
13
+ self.rewind
14
+ self.write content
15
+ end
16
+ end
17
+
4
18
  module Mistilteinn
5
19
  module Ticket
6
- class Config
7
- def initialize(config_hash, path)
8
- @config = config_hash
9
- @path = path
10
- end
11
- attr_reader :config
12
-
13
- def has_key?(key)
14
- @config.has_key?(key) || @config.has_key?(key.to_s)
15
- end
16
-
17
- def []=(*args)
18
- assignment(args[0], args[1])
19
- end
20
-
21
- def [](key)
22
- key = key.to_s if key.class == Symbol
23
- method_missing(key)
20
+ class GitConfig
21
+ def initialize(config)
24
22
  end
25
23
 
26
- def method_missing(name, *args)
27
- name = name.to_s
28
- is_assignment = create_if_nil = false
29
- if name[-1..-1] == '=' then
30
- is_assignment = true
31
- name.slice! -1
32
- end
33
- if name[-1..-1] == '_' then
34
- create_if_nil = true
35
- name.slice! -1
36
- end
37
-
38
- return assignment(name, args[0]) if is_assignment
39
-
40
- config_object = get_config_object(@path+[name.to_s])
41
- return nil if config_object.config.empty? and not create_if_nil
42
-
43
- if config_object.config.class == Hash then
44
- config_object
45
- else
46
- config_object.config
47
- end
24
+ def check
25
+ 'ok'
48
26
  end
49
27
 
50
- private
51
- def get_config_object(path)
52
- return @@config_objects[path] if @@config_objects.has_key? path
53
-
54
- if @config.has_key? path[-1] then
55
- @@config_objects[path] = Config::new(@config[path[-1]], path)
56
- else
57
- @config[path[-1]] = {}
58
- @@config_objects[path] = Config::new({}, path)
28
+ def tickets
29
+ last_ticket_id = ::Mistilteinn::Git.config "ticket.last"
30
+ (1...last_ticket_id.to_i).map do |id|
31
+ subject = ::Mistilteinn::Git.config "ticket.id/#{id}.subject"
32
+ status = ::Mistilteinn::Git.config "ticket.id/#{id}.status"
33
+ ::Mistilteinn::Ticket::Entry.new(id, subject, status)
59
34
  end
60
35
  end
61
36
 
62
- def Config::init
63
- @@config_objects = {[] => Config::parse_config}
64
- @@config_objects[[]]
65
- end
66
-
67
- def Config::parse_config
68
- config_hash = {}
69
- get_by_regexp('".*"').each do |path,value|
70
- subconfig = config_hash
71
- elems = path.split '.'
72
- elems[0..-2].each do |path|
73
- subconfig[path] = {} if subconfig[path].nil?
74
- subconfig = subconfig[path]
75
- end
76
- subconfig[elems[-1]] = value
77
- end
78
- Config::new(config_hash, [])
79
- end
37
+ def create(title = "")
38
+ tmpfile = Tempfile.new 'tmp'
39
+ tmpfile.content = ticket_format({
40
+ :subject => title,
41
+ :author => ::Mistilteinn::Git::config("user.name"),
42
+ :date => Time.now,
43
+ :status => "new"
44
+ })
45
+ tmpfile.edit default_editor
80
46
 
81
- def Config::get_by_regexp(regex)
82
- %x(git config --get-regexp #{regex}).split(/\n/).map do |line|
83
- line.match(/(.+?) (.*)/)[1..2]
84
- end
85
- end
47
+ ticket_id = (::Mistilteinn::Git.config("ticket.last") || "1").to_i
48
+ issue_ticket(tmpfile, ticket_id)
49
+ ::Mistilteinn::Git.config("ticket.last", (ticket_id+1).to_s)
86
50
 
87
- def Config::set(name, value)
88
- %x(git config #{name} "#{value}")
51
+ tmpfile.unlink
89
52
  end
90
53
 
91
- def assignment(key, value)
92
- Config::set("#{@path.join('.')}.#{key}", value)
93
- end
94
- end
54
+ def edit(ticket_id)
55
+ tmpfile = Tempfile.new 'tmp'
56
+ tmpfile.content = ticket_format({
57
+ :subject => ::Mistilteinn::Git.config("ticket.id/#{ticket_id}.subject"),
58
+ :author => ::Mistilteinn::Git.config("ticket.id/#{ticket_id}.author"),
59
+ :date => ::Mistilteinn::Git.config("ticket.id/#{ticket_id}.date"),
60
+ :status => ::Mistilteinn::Git.config("ticket.id/#{ticket_id}.status"),
61
+ :description => ::Mistilteinn::Git.config("ticket.id/#{ticket_id}.description")
62
+ })
63
+ modified = tmpfile.edit default_editor
95
64
 
96
- class GitConfig
97
- class ConfigError < StandardError; end
65
+ issue_ticket(tmpfile, ticket_id) if modified
98
66
 
99
- def initialize(config)
100
- @config = Config::init
67
+ tmpfile.unlink
101
68
  end
102
69
 
103
- def tickets
104
- lastTicketNo = @config.ticket.ticketno.to_i
105
- (1...lastTicketNo).map do |id|
106
- data = @config.ticket["id/#{id}"]
107
- ::Mistilteinn::Ticket::Entry.new(id, data.subject, data.status)
108
- end
70
+ private
71
+ def default_editor
72
+ ::Mistilteinn::Git.config "core.editor"
109
73
  end
110
74
 
111
- def create(title = "")
112
- ticketFormat = <<END
113
- Subject: #{title}
114
- Author: #{@config.user.name}
115
- Date: #{Time.now}
116
- Status: new
75
+ def ticket_format(data = {})
76
+ <<END
77
+ Subject: #{data[:subject]}
78
+ Author: #{data[:author]}
79
+ Date: #{data[:date]}
80
+ Status: #{data[:status]}
117
81
  Description: |-
118
-
82
+ #{data[:description]}
119
83
  END
84
+ end
120
85
 
121
- editTempFile(ticketFormat) do |f, modified|
122
- return if not modified and title.empty?
123
-
124
- ticket = @config.ticket
125
- ticketNo = (ticket.ticketno || "1").to_i
126
-
86
+ def issue_ticket(datafile, ticket_id)
87
+ File::open(datafile.path) do |f|
127
88
  YAML.load_documents(f) do |yaml|
128
89
  yaml.each do |key, value|
129
- ticket["id/#{ticketNo}_"][key] = value
90
+ ::Mistilteinn::Git.config("ticket.id/#{ticket_id}.#{key}", "\"#{value}\"")
130
91
  end
131
92
  end
132
- ticket.ticketno = (ticketNo+1).to_s
133
93
  end
134
94
  end
135
95
 
136
- def edit(id)
137
- end
138
-
139
- private
140
- def editTempFile(initialString, &proc)
141
- tmp = Tempfile.new("tmp")
142
- tmp.write initialString
143
- tmp.close
144
-
145
- editor = @config.core_.editor || ENV["EDITOR"]
146
- system "#{editor} #{tmp.path}"
147
- File.open(tmp.path) do |f|
148
- modified = f.read != initialString
149
- f.rewind
150
- proc.call(f, modified)
151
- end
152
- tmp.unlink
153
- end
154
96
  end
155
97
  end
156
98
  end
@@ -2,5 +2,5 @@
2
2
  # -*- mode:ruby; coding:utf-8 -*-
3
3
 
4
4
  module Mistilteinn
5
- VERSION = '0.1.1'
5
+ VERSION = '0.1.2'
6
6
  end
@@ -9,7 +9,10 @@ Gem::Specification.new do |gem|
9
9
  gem.homepage = "https://github.com/mistilteinn/mistilteinn-shell"
10
10
 
11
11
  gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
- gem.files = `git ls-files`.split("\n")
12
+ exclude_from_gem = File::read('.excluded_from_gem').split("\n")
13
+ gem.files = `git ls-files`.split("\n").reject do |file|
14
+ exclude_from_gem.include? file
15
+ end
13
16
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
17
  gem.name = "mistilteinn"
15
18
  gem.require_paths = ["lib"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mistilteinn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-15 00:00:00.000000000 Z
12
+ date: 2012-03-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
16
- requirement: &70162460090560 !ruby/object:Gem::Requirement
16
+ requirement: &78282030 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70162460090560
24
+ version_requirements: *78282030
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: subcommand
27
- requirement: &70162460089900 !ruby/object:Gem::Requirement
27
+ requirement: &78281770 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70162460089900
35
+ version_requirements: *78281770
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &70162460089320 !ruby/object:Gem::Requirement
38
+ requirement: &78281510 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70162460089320
46
+ version_requirements: *78281510
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rake
49
- requirement: &70162460088620 !ruby/object:Gem::Requirement
49
+ requirement: &78281240 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70162460088620
57
+ version_requirements: *78281240
58
58
  description: Mistilteinn is a command to support a development with git and redmine.
59
59
  email:
60
60
  - mzp.ppp@gmail.com
@@ -63,17 +63,15 @@ executables:
63
63
  extensions: []
64
64
  extra_rdoc_files: []
65
65
  files:
66
- - .gitignore
67
- - .mistilteinn/config.yaml
68
66
  - .rspec
69
67
  - Gemfile
70
68
  - README.markdown
71
69
  - Rakefile
72
- - bin/.gitkeep
73
70
  - bin/mistilteinn
74
71
  - lib/mistilteinn/cli.rb
75
72
  - lib/mistilteinn/cli/command.rb
76
73
  - lib/mistilteinn/cli/create.rb
74
+ - lib/mistilteinn/cli/edit.rb
77
75
  - lib/mistilteinn/cli/hooks/commit-msg
78
76
  - lib/mistilteinn/cli/hooks/common.sh
79
77
  - lib/mistilteinn/cli/hooks/pre-commit
@@ -92,7 +90,6 @@ files:
92
90
  - lib/mistilteinn/ticket/redmine.rb
93
91
  - lib/mistilteinn/version.rb
94
92
  - mistilteinn.gemspec
95
- - spec/.gitkeep
96
93
  - spec/config_spec.rb
97
94
  - spec/spec_helper.rb
98
95
  - spec/ticket/redmine_spec.rb
@@ -116,11 +113,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
113
  version: '0'
117
114
  requirements: []
118
115
  rubyforge_project:
119
- rubygems_version: 1.8.16
116
+ rubygems_version: 1.8.17
120
117
  signing_key:
121
118
  specification_version: 3
122
119
  summary: Mistilteinn is a command to support a development with git and redmine.
123
- test_files:
124
- - spec/config_spec.rb
125
- - spec/spec_helper.rb
126
- - spec/ticket/redmine_spec.rb
120
+ test_files: []
data/.gitignore DELETED
@@ -1,7 +0,0 @@
1
- *~
2
- .gem
3
- .bundle
4
- Gemfile.lock
5
- pkg/
6
- vendor/
7
- *.gem
@@ -1,9 +0,0 @@
1
- ticket:
2
- source: redmine
3
-
4
- redmine:
5
- url: https://codefirst.org/redmine/
6
- project: mistilteinn-shell
7
-
8
- github:
9
- url: https://github.com/mistilteinn/mistilteinn-shell
File without changes
File without changes