release_dove 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 41fd840eac471b8770900d540bc81a7744e0c5d9
4
+ data.tar.gz: 09b2a6004a6ccc128b0281350caacf9ae2d23ef8
5
+ SHA512:
6
+ metadata.gz: 2aec706627d3d74a08ecbde54a801b58463968af93110422239c6556ba99a68f4a25079a1b3983f5c340e1ed5f769f0ab45fd4a6d691cd7cd69a2fcb3ed297ba
7
+ data.tar.gz: 88e21dc6963bff16be77d8ba3bc5db719d9063a59e67078654cd9ea6e6b3bc2625e78b70dc02982d7be835a79d8f6d7d60274188f5ad95dd2b1023ddd5b930fb
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.rubocop.yml ADDED
@@ -0,0 +1,37 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.3
3
+ Exclude:
4
+ - 'bin/**/*'
5
+ - 'db/**/*'
6
+ - 'vendor/**/*'
7
+ - 'tmp/**/*'
8
+ - 'test/test_helper.rb'
9
+ - 'spec/spec_helper.rb'
10
+ - 'spec/rails_helper.rb'
11
+ - 'node_modules/**/*'
12
+
13
+ AlignParameters:
14
+ Enabled: false
15
+
16
+ Metrics/LineLength:
17
+ Max: 100
18
+
19
+ Metrics/MethodLength:
20
+ Max: 20
21
+
22
+ Style/IndentHash:
23
+ EnforcedStyle: consistent
24
+
25
+ Style/ClassAndModuleChildren:
26
+ Enabled: false
27
+
28
+ Style/SpaceInsideHashLiteralBraces:
29
+ Enabled: true
30
+ Exclude:
31
+ - spec/**/*
32
+
33
+ Style/BlockComments:
34
+ Enabled: false
35
+
36
+ Documentation:
37
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.0
5
+ before_install: gem install bundler -v 1.12.5
data/CHANGELOG.md ADDED
@@ -0,0 +1,6 @@
1
+ # Release Dove Change log
2
+
3
+ ## [0.1.0] - 2016-10-14
4
+ ### Added
5
+ - Basic API which returns a collection of releases in JSON format
6
+ - Cover with basic funcitonal tests
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+ source 'https://rubygems.org'
3
+
4
+ # Specify your gem's dependencies in release_dove.gemspec
5
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Oleg
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,56 @@
1
+ # Release Dove
2
+ [![Build Status](https://travis-ci.org/gafrom/release_dove.svg)](https://travis-ci.org/gafrom/release_dove)
3
+
4
+ Dead-simple widget allowing you to receive notifications about new releases of your application in a form of nice pop-up bar.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's `Gemfile`:
9
+ ```ruby
10
+ gem 'release_dove'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install release_dove
20
+
21
+ Then drop a line to `routes.rb` to specify where you want your colleciton of releases:
22
+ ```ruby
23
+ mount ReleaseDove::Application => '/releases'
24
+ ```
25
+
26
+ Finally, include the front-end part:
27
+ ```javascript
28
+ TODO: include npm package 'release_dove'
29
+ ```
30
+
31
+ ## Usage
32
+
33
+ When running without from-end part, _https://you_app.com/releases_ will return a collection of releases in `JSON` format from your `CHANGELOG.md` file, providing the latter is maintained in a [conventional way](http://keepachangelog.com/en/0.3.0/).
34
+
35
+ ## Release attributes
36
+
37
+ Releases have the following attributes:
38
+
39
+ | Attribute | Description | Example |
40
+ |----------- |---------------------------------------- |--------------------------------------------------------- |
41
+ | `id` | number, starting from earliest release | 5 |
42
+ | `version` | version of release, if specified | 1.2.3 |
43
+ | `date` | release date | 2016-10-15 |
44
+ | `header` | content of release header tag | [1.2.3] - 2016-10-15 |
45
+ | `content` | full content of release | ## [1.2.3] - 2016-10-15 ### Added - Basic functionality |
46
+
47
+ TODO: Write usage instructions here with npm package included
48
+
49
+ ## Contributing
50
+
51
+ Bug reports and pull requests are welcome on GitHub at https://github.com/gafrom/release_dove.
52
+
53
+ ## License
54
+
55
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
56
+
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+ require 'bundler/gem_tasks'
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'release_dove'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require 'pry'
11
+ # Pry.start
12
+
13
+ require 'irb'
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,90 @@
1
+ # frozen_string_literal: true
2
+ require 'English'
3
+ class ReleaseDove::Release
4
+ attr_reader :id, :date, :version, :header, :content
5
+
6
+ CHANGELOG = './CHANGELOG.md'
7
+ TAG = /^.*(?<header>\[Unreleased\]|\[(?<version>\d+\.\d+\.\d+)\].*(?<date>\d{4}\-\d{2}\-\d{2}))$/i
8
+
9
+ class << self
10
+ def all
11
+ return @all if @all
12
+
13
+ @all = []
14
+ releases.each { |*args| @all << new(*args) }
15
+
16
+ @all
17
+ end
18
+
19
+ def take
20
+ all.first
21
+ end
22
+
23
+ alias last take
24
+
25
+ def first
26
+ all.last
27
+ end
28
+
29
+ def size
30
+ all.size
31
+ end
32
+ alias count size
33
+ alias length size
34
+
35
+ def find(id)
36
+ id = id.to_i
37
+ releases = all
38
+ length = releases.length
39
+ return unless (1..length).cover? id
40
+
41
+ i = length - id
42
+ releases.fetch(i)
43
+ end
44
+
45
+ private
46
+
47
+ def releases
48
+ return to_enum(:releases) unless block_given?
49
+
50
+ log_content, log_indices = read_from_file
51
+
52
+ log_indices.each_with_index do |position, i|
53
+ next_position = log_indices[i + 1]
54
+ length = next_position ? next_position - position : log_content.length - position
55
+ id = log_indices.size - i
56
+ content = log_content[position, length]
57
+
58
+ yield id, content
59
+ end
60
+ end
61
+
62
+ def read_from_file
63
+ file = File.open(CHANGELOG, 'rb', encoding: 'utf-8')
64
+ content = file.read
65
+ indices = content.enum_for(:scan, TAG).map { Regexp.last_match.begin(0) }
66
+ file.close
67
+
68
+ [content, indices]
69
+ end
70
+ end
71
+
72
+ def initialize(id, content)
73
+ @id = id
74
+ @content = content
75
+
76
+ return unless TAG =~ content
77
+
78
+ @version = $LAST_MATCH_INFO[:version]
79
+ @header = $LAST_MATCH_INFO[:header]
80
+ @date = begin
81
+ Date.parse $LAST_MATCH_INFO[:date].to_s
82
+ rescue ArgumentError
83
+ nil
84
+ end
85
+ end
86
+
87
+ def ==(other)
88
+ id == other.id
89
+ end
90
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+ module ReleaseDove
3
+ VERSION = '0.1.0'
4
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+ require 'release_dove/version'
3
+ require 'release_dove/release'
4
+
5
+ module ReleaseDove
6
+ class Application
7
+ def self.call(*)
8
+ ['200', { 'Content-Type' => 'application/json; charset=utf-8' }, [Release.all.to_json]]
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,37 @@
1
+ # coding: utf-8
2
+ # frozen_string_literal: true
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'release_dove/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'release_dove'
9
+ spec.version = ReleaseDove::VERSION
10
+ spec.authors = ['Oleg']
11
+ spec.email = ['gafrom@gmail.com']
12
+
13
+ spec.summary = 'Simple widget to notify about new releases of your applicaiton.'
14
+ spec.description = "This is a backend part of easy-to-embed widget with pop-up \
15
+ notifications about your application's new releases."
16
+ spec.homepage = 'https://github.com/gafrom/release_dove'
17
+ spec.license = 'MIT'
18
+
19
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
20
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
21
+ # if spec.respond_to?(:metadata)
22
+ # spec.metadata['allowed_push_host'] = 'https://mygemserver.com'
23
+ # else
24
+ # raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
25
+ # end
26
+
27
+ spec.files = `git ls-files -z`.split("\x0")
28
+ .reject { |f| f.match(%r{^(test|spec|features)/}) }
29
+ spec.bindir = 'exe'
30
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ['lib']
32
+
33
+ spec.add_development_dependency 'bundler', '~> 1.12'
34
+ spec.add_development_dependency 'rake', '~> 10.0'
35
+ spec.add_development_dependency 'rspec', '~> 3.0'
36
+ spec.add_development_dependency 'json', '~> 2.0.2'
37
+ end
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: release_dove
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Oleg
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-10-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.12'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.12'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: json
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 2.0.2
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 2.0.2
69
+ description: This is a backend part of easy-to-embed widget with pop-up notifications
70
+ about your application's new releases.
71
+ email:
72
+ - gafrom@gmail.com
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".rspec"
79
+ - ".rubocop.yml"
80
+ - ".travis.yml"
81
+ - CHANGELOG.md
82
+ - Gemfile
83
+ - LICENSE.txt
84
+ - README.md
85
+ - Rakefile
86
+ - bin/console
87
+ - bin/setup
88
+ - lib/release_dove.rb
89
+ - lib/release_dove/release.rb
90
+ - lib/release_dove/version.rb
91
+ - release_dove.gemspec
92
+ homepage: https://github.com/gafrom/release_dove
93
+ licenses:
94
+ - MIT
95
+ metadata: {}
96
+ post_install_message:
97
+ rdoc_options: []
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ requirements: []
111
+ rubyforge_project:
112
+ rubygems_version: 2.5.1
113
+ signing_key:
114
+ specification_version: 4
115
+ summary: Simple widget to notify about new releases of your applicaiton.
116
+ test_files: []