checklister 0.1.1 → 0.9.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,58 @@
1
+ require "yaml"
2
+
3
+ module Checklister
4
+ class ConfigurationFile
5
+ attr_reader :services
6
+
7
+ def initialize(path)
8
+ @path = path
9
+ @file = load_file
10
+ @services = load_services
11
+ end
12
+
13
+ def exist?
14
+ File.exist?(@path)
15
+ end
16
+
17
+ def add_service(service)
18
+ symbolized_service = Checklister::Sanitizer.symbolize(service)
19
+ remove_service symbolized_service[:endpoint]
20
+ @services << symbolized_service
21
+ end
22
+
23
+ def remove_service(endpoint)
24
+ @services.delete_if { |h| h[:endpoint].to_s == endpoint.to_s }
25
+ end
26
+
27
+ def persist
28
+ File.open(@path, "w") do |f|
29
+ namespaced_services = { services: @services }
30
+ f.write namespaced_services.to_yaml
31
+ end
32
+ reload!
33
+ end
34
+
35
+ def reload!
36
+ @file = load_file
37
+ @services = load_services
38
+ end
39
+
40
+ private
41
+
42
+ def load_file
43
+ if exist?
44
+ Checklister::Sanitizer.symbolize YAML::load_file(@path)
45
+ else
46
+ {}
47
+ end
48
+ end
49
+
50
+ def load_services
51
+ if @file && @file[:services]
52
+ @file[:services]
53
+ else
54
+ []
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,14 @@
1
+ module Checklister
2
+ module Gitlab
3
+ class Issue
4
+ def initialize(client)
5
+ @client = client
6
+ end
7
+
8
+ def create(project_id, attributes = {})
9
+ issue = Checklister::Issue.new(attributes.merge(project_id: project_id))
10
+ @client.create_issue(issue.project_id, issue.title, description: issue.description)
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,26 @@
1
+ module Checklister
2
+ module Gitlab
3
+ class Project
4
+ DEFAULT_OPTIONS = { order_by: "id", sort: "asc", per_page: "10" }
5
+ ATTRIBUTES = %w(id name description) # NOTE: For information
6
+
7
+ def initialize(client)
8
+ @client = client
9
+ end
10
+
11
+ def get(project_id)
12
+ Checklister::Sanitizer.symbolize @client.project(project_id).to_hash
13
+ end
14
+
15
+ def all(options = {})
16
+ query_options = DEFAULT_OPTIONS.merge options
17
+ Checklister::Sanitizer.symbolize @client.projects(query_options).map(&:to_hash)
18
+ end
19
+
20
+ def filtered_by_name(name, options = {})
21
+ query_options = DEFAULT_OPTIONS.merge options
22
+ Checklister::Sanitizer.symbolize @client.project_search(name, query_options).map(&:to_hash)
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,14 @@
1
+ module Checklister
2
+ class Issue
3
+ # - project_id (required) - The ID of a project
4
+ # - title (required) - The title of an issue
5
+ # - description (required) - The description of an issue
6
+ attr_reader :project_id, :title, :description
7
+
8
+ def initialize(attributes = {})
9
+ @project_id = attributes.fetch(:project_id) { raise ArgumentError, "Missing project_id" }
10
+ @title = attributes.fetch(:title) { raise ArgumentError, "Missing title" }
11
+ @description = attributes.fetch(:body) { raise ArgumentError, "Missing description" }
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,38 @@
1
+ module Checklister
2
+ # Parse a markdown file and return a hash of params.
3
+ #
4
+ # @example
5
+ # {
6
+ # title: "Title",
7
+ # body: "## Mardown Body context\n## Checklist\nMardown Body checklist"
8
+ # }
9
+ #
10
+ class Parser
11
+ # @param [String] file_path the path of the markdown file to parse
12
+ def initialize(file_path)
13
+ @file_content = File.open(file_path).read
14
+ end
15
+
16
+ # @return [Hash] a hash of params
17
+ def to_params
18
+ title = ""
19
+ checklist = []
20
+
21
+ @file_content.each_line do |line|
22
+ # Extract a title, when we find the first <h1> header
23
+ if title == "" && line.start_with?("# ")
24
+ title = line.sub("# ", "").sub("\n", "")
25
+ else
26
+ # Then, keep the text intact until the end of the file
27
+ checklist << line
28
+ end
29
+ end
30
+
31
+ # Default title, if no <H1> header found
32
+ title = "Checklist" if title == ""
33
+
34
+ # Return the parsed text as an object
35
+ { title: title, body: checklist.join }
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,16 @@
1
+ module Checklister
2
+ class Sanitizer
3
+ def self.symbolize(obj)
4
+ return obj.inject({}) do |memo, (k, v)|
5
+ memo.tap { |m| m[k.to_sym] = symbolize(v) }
6
+ end if obj.is_a? Hash
7
+
8
+ return obj.inject([]) do |memo, v|
9
+ memo << symbolize(v)
10
+ memo
11
+ end if obj.is_a? Array
12
+
13
+ obj
14
+ end
15
+ end
16
+ end
@@ -1,3 +1,3 @@
1
1
  module Checklister
2
- VERSION = "0.1.1"
2
+ VERSION = "0.9.0"
3
3
  end
File without changes
data/script/doc ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -e
4
+
5
+ echo "===> Starting the documentation server..."
6
+ bundle exec yard server --port 8808 --reload
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: checklister
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benjamin Thouret
@@ -9,8 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-08-18 00:00:00.000000000 Z
12
+ date: 2015-09-23 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: gitlab
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: 3.4.0
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: 3.4.0
14
28
  - !ruby/object:Gem::Dependency
15
29
  name: gli
16
30
  requirement: !ruby/object:Gem::Requirement
@@ -39,6 +53,20 @@ dependencies:
39
53
  - - "~>"
40
54
  - !ruby/object:Gem::Version
41
55
  version: '1.10'
56
+ - !ruby/object:Gem::Dependency
57
+ name: coveralls
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: 0.8.2
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: 0.8.2
42
70
  - !ruby/object:Gem::Dependency
43
71
  name: guard
44
72
  requirement: !ruby/object:Gem::Requirement
@@ -95,6 +123,34 @@ dependencies:
95
123
  - - "~>"
96
124
  - !ruby/object:Gem::Version
97
125
  version: '3.3'
126
+ - !ruby/object:Gem::Dependency
127
+ name: yard
128
+ requirement: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - "~>"
131
+ - !ruby/object:Gem::Version
132
+ version: '0.8'
133
+ type: :development
134
+ prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - "~>"
138
+ - !ruby/object:Gem::Version
139
+ version: '0.8'
140
+ - !ruby/object:Gem::Dependency
141
+ name: webmock
142
+ requirement: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - "~>"
145
+ - !ruby/object:Gem::Version
146
+ version: '1.21'
147
+ type: :development
148
+ prerelease: false
149
+ version_requirements: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - "~>"
152
+ - !ruby/object:Gem::Version
153
+ version: '1.21'
98
154
  description: |-
99
155
  NOT READY!
100
156
  Checklister is a CLI packaged as a Ruby gem giving you the power to transform any markdown file or url checklist into an actionable gitlab (and soon github) issue.
@@ -106,8 +162,10 @@ extensions: []
106
162
  extra_rdoc_files: []
107
163
  files:
108
164
  - ".gitignore"
165
+ - ".hound.yml"
109
166
  - ".rspec"
110
167
  - ".travis.yml"
168
+ - ".yardopts"
111
169
  - CHANGELOG.md
112
170
  - CONTRIBUTING.md
113
171
  - Gemfile
@@ -115,12 +173,24 @@ files:
115
173
  - LICENSE
116
174
  - README.md
117
175
  - Rakefile
118
- - bin/console
176
+ - bin/checklister
119
177
  - checklister.gemspec
178
+ - config/checklister.example.yml
179
+ - examples/basic-checklist.md
120
180
  - examples/simple-checklist.md
121
181
  - lib/checklister.rb
182
+ - lib/checklister/client.rb
183
+ - lib/checklister/configuration.rb
184
+ - lib/checklister/configuration_file.rb
185
+ - lib/checklister/gitlab/issue.rb
186
+ - lib/checklister/gitlab/project.rb
187
+ - lib/checklister/issue.rb
188
+ - lib/checklister/parser.rb
189
+ - lib/checklister/sanitizer.rb
122
190
  - lib/checklister/version.rb
123
191
  - script/bootstrap
192
+ - script/console
193
+ - script/doc
124
194
  - script/package
125
195
  - script/release
126
196
  - script/test
@@ -141,7 +211,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
141
211
  requirements:
142
212
  - - ">="
143
213
  - !ruby/object:Gem::Version
144
- version: '0'
214
+ version: '1.9'
145
215
  requirements: []
146
216
  rubyforge_project:
147
217
  rubygems_version: 2.2.2
@@ -149,3 +219,4 @@ signing_key:
149
219
  specification_version: 4
150
220
  summary: Markdown checklists to gitlab or github issue.
151
221
  test_files: []
222
+ has_rdoc: