diaspora-prosody-config 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 319a9250508cce73f3c978639c549ab1421d7728
4
- data.tar.gz: 6c18153465e59487230afd35ddf4a7e1c40b755a
3
+ metadata.gz: 40adc978303dcd78192493dcdd63bb63bd6debff
4
+ data.tar.gz: 333053af4529faffc73f1169cf5f6d573e8c73d6
5
5
  SHA512:
6
- metadata.gz: 4823f31f908b9a8f27903f9e8b739da04b6f7ec712fe69974a7854873119524c56db52f412b8c4eb2ba7aa9f937adcff0899634a3c3f6b2a20b03709e8fae399
7
- data.tar.gz: 842c97b987c001745e78374d0033b72352b252bfb9cf53355783f5e996f838a8dc8ee5a82353af277b30d9b63e3552abdfa492f17b81ba429701d96377ee8c37
6
+ metadata.gz: 30a6128751b83256ff8855935300a2829d7d0243eca008a965c2caf8bf74192cc1f564b784fd62a64e4fe7b6e67fda21f40bca1ce30715fe61d71a64bb00b33a
7
+ data.tar.gz: 1139ceca50d3875471b597706d7072bba44b85f29ddb4ae45eb00d36799dc9fe9a31f2ebd996fc065eed191f5945abe208b5a0cd5ce91cda023ae51d5d3165f7
data/.gitignore CHANGED
@@ -2,3 +2,4 @@
2
2
  *.log
3
3
  tmp
4
4
  etc/prosody.cfg.lua
5
+ config/
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2016-04-05 16:12:03 +0200 using RuboCop version 0.39.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ # Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts.
11
+ Style/FileName:
12
+ Exclude:
13
+ - 'lib/diaspora-prosody-config.rb'
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1
4
+ script:
5
+ - bundle exec pronto run -f text -c ${TRAVIS_BRANCH}
6
+ - bundle exec rake
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,66 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ diaspora-prosody-config (0.0.4)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ addressable (2.4.0)
10
+ ast (2.2.0)
11
+ faraday (0.9.2)
12
+ multipart-post (>= 1.2, < 3)
13
+ gitlab (3.6.1)
14
+ httparty
15
+ terminal-table
16
+ httparty (0.13.7)
17
+ json (~> 1.8)
18
+ multi_xml (>= 0.5.2)
19
+ json (1.8.3)
20
+ minitest (5.8.4)
21
+ multi_xml (0.5.5)
22
+ multipart-post (2.0.0)
23
+ octokit (4.3.0)
24
+ sawyer (~> 0.7.0, >= 0.5.3)
25
+ parser (2.3.0.7)
26
+ ast (~> 2.2)
27
+ powerpack (0.1.1)
28
+ pronto (0.6.0)
29
+ gitlab (~> 3.6, >= 3.4.0)
30
+ octokit (~> 4.3, >= 4.1.0)
31
+ rugged (~> 0.24, >= 0.23.0)
32
+ thor (~> 0.19.0)
33
+ pronto-rubocop (0.6.1)
34
+ pronto (~> 0.6.0)
35
+ rubocop (~> 0.38, >= 0.35.0)
36
+ rainbow (2.1.0)
37
+ rake (10.5.0)
38
+ rubocop (0.39.0)
39
+ parser (>= 2.3.0.7, < 3.0)
40
+ powerpack (~> 0.1)
41
+ rainbow (>= 1.99.1, < 3.0)
42
+ ruby-progressbar (~> 1.7)
43
+ unicode-display_width (~> 1.0, >= 1.0.1)
44
+ ruby-progressbar (1.7.5)
45
+ rugged (0.24.0)
46
+ sawyer (0.7.0)
47
+ addressable (>= 2.3.5, < 2.5)
48
+ faraday (~> 0.8, < 0.10)
49
+ sqlite3 (1.3.11)
50
+ terminal-table (1.5.2)
51
+ thor (0.19.1)
52
+ unicode-display_width (1.0.3)
53
+
54
+ PLATFORMS
55
+ ruby
56
+
57
+ DEPENDENCIES
58
+ diaspora-prosody-config!
59
+ minitest
60
+ pronto
61
+ pronto-rubocop
62
+ rake
63
+ sqlite3
64
+
65
+ BUNDLED WITH
66
+ 1.10.6
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new(:test) do |test|
5
+ test.libs << 'test'
6
+ test.pattern = 'test/**/*_test.rb'
7
+ test.warning = false
8
+ end
9
+
10
+ task default: [:test]
@@ -1,12 +1,20 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'diaspora-prosody-config'
3
- s.version = '0.0.3'
3
+ s.version = '0.0.4'
4
4
  s.summary = 'A prosody config-wrapper for Diaspora'
5
5
  s.description = 'A prosody config-wrapper for Diaspora'
6
+ s.license = 'GPL-3.0'
7
+
6
8
  s.authors = ['Lukas Matt']
7
9
  s.email = 'lukas@zauberstuhl.de'
8
- s.files = `git ls-files`.split("\n")
9
- s.require_paths = ["lib"]
10
10
  s.homepage = 'https://github.com/zauberstuhl/gem_diaspora-prosody-config'
11
- s.license = 'GPL-3.0'
11
+
12
+ s.files = `git ls-files`.split("\n")
13
+ s.require_paths = ['lib']
14
+
15
+ s.add_development_dependency 'pronto'
16
+ s.add_development_dependency 'pronto-rubocop'
17
+ s.add_development_dependency 'sqlite3'
18
+ s.add_development_dependency 'minitest'
19
+ s.add_development_dependency 'rake'
12
20
  end
@@ -144,8 +144,8 @@ authentication = "internal_plain"
144
144
  -- Logging configuration
145
145
  -- For advanced logging see http://prosody.im/doc/logging
146
146
  log = {
147
- info = "prosody.log"; -- Change 'info' to 'debug' for verbose logging
148
- error = "prosody.err";
147
+ info = "log/prosody.log"; -- Change 'info' to 'debug' for verbose logging
148
+ error = "log/prosody.err";
149
149
  -- "*syslog"; -- Uncomment this for logging to syslog
150
150
  -- "*console"; -- Log to the console, useful for debugging with daemonize=false
151
151
  }
@@ -16,66 +16,77 @@
16
16
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
17
  #
18
18
 
19
- require "fileutils"
19
+ require 'fileutils'
20
20
 
21
- class Prosody
22
- PROSODYBIN = find_binary
23
- GEMDIR = Gem::Specification.find_by_name('diaspora-prosody-config').gem_dir
24
- WRAPPERCFG = "#{GEMDIR}/etc/prosody.cfg.lua"
25
- DIASPORACFG = "#{FileUtils.pwd}/config/prosody.cfg.lua"
21
+ module Prosody
22
+ GEMDIR = Gem::Specification.find_by_name(
23
+ 'diaspora-prosody-config'
24
+ ).gem_dir.freeze
26
25
 
27
- def initialize
28
- init_config
26
+ WRAPPERCFG = "#{GEMDIR}/etc/prosody.cfg.lua".freeze
27
+ DIASPORACFG = "#{FileUtils.pwd}/config/prosody.cfg.lua".freeze
28
+
29
+ def self.start
30
+ check_sanity && system("#{find_binary} --config #{WRAPPERCFG}")
29
31
  end
30
32
 
31
- def start
32
- system("#{PROSODYBIN} --config #{WRAPPERCFG}")
33
+ def self.update_configuration
34
+ # update prosody cfg in diaspora config dir
35
+ gemcfg = "#{WRAPPERCFG}.tpl"
36
+ unless File.exist?(DIASPORACFG)
37
+ FileUtils.cp(gemcfg, DIASPORACFG)
38
+ end
39
+
40
+ config = File.read(DIASPORACFG)
41
+ config_params.each do |k, v|
42
+ begin
43
+ v = 'MySQL' if v.include?('mysql2')
44
+ v = 'PostgreSQL' if v.include?('postgresql')
45
+ v = 'SQLite3' if v.include?('sqlite3')
46
+ rescue
47
+ warn("Warning! #{k} is empty")
48
+ end
49
+ config.gsub!(/\#\{#{k}\}/, "#{v}")
50
+ end
51
+ File.open(WRAPPERCFG, 'w') {|f| f.write(config) }
33
52
  end
34
53
 
35
54
  private
36
- def find_binary
55
+
56
+ def self.find_binary
37
57
  ENV['PATH'].split(':').each do |p|
38
58
  prosodybin = "#{p}/prosody"
39
- return prosodybin if File.exists?(prosodybin)
59
+ return prosodybin if File.exist?(prosodybin)
40
60
  end
41
- abort("Prosody executable is missing please update your PATH variable")
61
+ abort('Prosody executable is missing please update your PATH variable')
42
62
  end
43
63
 
44
- def init_config
45
- # do some sanity checks
46
- begin
47
- require "bcrypt"
48
- rescue LoadError
49
- abort("bcrypt is required for diaspora authentication")
64
+ def self.check_sanity
65
+ # check on bcrypt and warn
66
+ bcrypt_so = %x(find /usr/local/lib -name bcrypt.so) rescue ''
67
+ warn('bcrypt is required for diaspora authentication') if bcrypt_so.empty?
68
+ # check prosody version
69
+ about = %x(#{find_binary}ctl about)
70
+ version_string = begin
71
+ about.match(/prosody\s(\d+\.\d+\.\d+)/i).captures[0]
72
+ rescue
73
+ abort('something went wrong with prosdoyctl')
50
74
  end
51
- version = Gem::Version.new(0)
52
- about = %x(#{PROSODYBIN}ctl about)
53
- version_string = about.match(/prosody\s(\d+\.\d+\.\d+)/i).captures[0]
54
75
  version = Gem::Version.new(version_string)
55
- abort("wasn't able to detect prosody installation") if version == Gem::Version.new(0)
56
- abort("your're prosody version should be >= 0.9.0") if version < Gem::Version.new("0.9.0")
57
- # check if Diaspora-configuration is available
58
- abort("wasn't able to detect the Diaspora environment") unless defined?(AppConfig)
59
- abort("wasn't able to detect the Rails environment") unless defined?(Rails)
60
-
61
- # update prosody cfg in diaspora config dir
62
- gemcfg = "#{WRAPPERCFG}.tpl"
63
- unless File.exists?(DIASPORACFG)
64
- FileUtils.cp(gemcfg, DIASPORACFG)
76
+ if version < Gem::Version.new('0.9.0')
77
+ abort('your\'re prosody version should be >= 0.9.0')
65
78
  end
79
+ abort('wasn\'t able to detect the Diaspora environment') unless defined?(AppConfig)
80
+ abort('wasn\'t able to detect the Rails environment') unless defined?(Rails)
66
81
 
67
- config = File.read(DIASPORACFG)
68
- config_params.each do |k, v|
69
- config.gsub!(/\#\{#{k}\}/, "#{v}")
70
- end
71
- File.open(WRAPPERCFG, 'w') {|f| f.write(config) }
82
+ update_configuration
72
83
  end
73
84
 
74
- def config_params
85
+ def self.config_params
75
86
  db = Rails.application.config.database_configuration[Rails.env]
76
87
  hostname = AppConfig.environment.url
77
88
  .gsub(/^http(s){0,1}:\/\/|\/$/, '')
78
- .to_s rescue "localhost"
89
+ .to_s rescue 'localhost'
79
90
 
80
91
  return {
81
92
  plugin_path: "#{GEMDIR}/modules",
@@ -0,0 +1,17 @@
1
+ require 'test_helper'
2
+
3
+ describe Prosody do
4
+ def setup
5
+ FileUtils.mkdir_p('config')
6
+ ENV['PATH'] = 'test/scripts'
7
+ end
8
+
9
+ def test_working_setup
10
+ assert_equal 'Startup', %x(prosody)
11
+ assert_equal 'Prosody 0.9.0', %x(prosodyctl)
12
+ end
13
+
14
+ def test_dpc
15
+ assert_equal true, Prosody.start
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ #!/bin/sh
2
+
3
+ echo -n "Startup"
@@ -0,0 +1,3 @@
1
+ #!/bin/sh
2
+
3
+ echo -n "Prosody 0.9.0"
@@ -0,0 +1,29 @@
1
+ require 'diaspora-prosody-config'
2
+ require 'minitest/autorun'
3
+ require 'fileutils'
4
+
5
+ # AppConfig.environment.url
6
+ module AppConfig
7
+ module Url
8
+ def self.url; 'localhost'; end
9
+ end
10
+ def self.environment; Url; end
11
+ end
12
+
13
+ # Rails.application.config.database_configuration[Rails.env]
14
+ module Rails
15
+ module Config
16
+ module Db
17
+ def self.database_configuration
18
+ {
19
+ 'development' => {
20
+ 'adapter' => 'sqlite3',
21
+ 'database' => 'test.db'
22
+ }}
23
+ end
24
+ end
25
+ def self.config; Db; end
26
+ end
27
+ def self.env; 'development'; end
28
+ def self.application; Config; end
29
+ end
metadata CHANGED
@@ -1,15 +1,85 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: diaspora-prosody-config
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lukas Matt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-04 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2016-04-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pronto
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pronto-rubocop
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: sqlite3
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
13
83
  description: A prosody config-wrapper for Diaspora
14
84
  email: lukas@zauberstuhl.de
15
85
  executables: []
@@ -17,12 +87,21 @@ extensions: []
17
87
  extra_rdoc_files: []
18
88
  files:
19
89
  - ".gitignore"
90
+ - ".rubocop.yml"
91
+ - ".travis.yml"
92
+ - Gemfile
93
+ - Gemfile.lock
20
94
  - LICENSE
95
+ - Rakefile
21
96
  - diaspora-prosody-config.gemspec
22
97
  - etc/prosody.cfg.lua.tpl
23
98
  - lib/diaspora-prosody-config.rb
24
99
  - modules/mod_auth_diaspora.lua
25
100
  - modules/mod_diaspora_contacts.lua
101
+ - test/lib_dpc_test.rb
102
+ - test/scripts/prosody
103
+ - test/scripts/prosodyctl
104
+ - test/test_helper.rb
26
105
  homepage: https://github.com/zauberstuhl/gem_diaspora-prosody-config
27
106
  licenses:
28
107
  - GPL-3.0