melissadata 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. data/Gemfile +2 -0
  2. data/Gemfile.lock +46 -16
  3. data/README.md +50 -2
  4. data/Rakefile +58 -23
  5. data/Vagrantfile +12 -12
  6. data/bin/md_tcp_server +5 -0
  7. data/bin/md_unix_server +5 -0
  8. data/chef/cookbooks/apt/README.md +109 -0
  9. data/chef/cookbooks/apt/files/default/apt-cacher +9 -0
  10. data/chef/cookbooks/apt/files/default/apt-cacher.conf +144 -0
  11. data/chef/cookbooks/apt/files/default/apt-proxy-v2.conf +50 -0
  12. data/chef/cookbooks/apt/metadata.json +34 -0
  13. data/chef/cookbooks/apt/metadata.rb +13 -0
  14. data/chef/cookbooks/apt/providers/repository.rb +72 -0
  15. data/chef/cookbooks/apt/recipes/cacher-client.rb +37 -0
  16. data/chef/cookbooks/apt/recipes/cacher.rb +45 -0
  17. data/chef/cookbooks/apt/recipes/default.rb +33 -0
  18. data/chef/cookbooks/apt/resources/repository.rb +30 -0
  19. data/chef/cookbooks/build-essential/README.md +24 -0
  20. data/chef/cookbooks/build-essential/metadata.json +35 -0
  21. data/chef/cookbooks/build-essential/metadata.rb +10 -0
  22. data/chef/cookbooks/build-essential/recipes/default.rb +45 -0
  23. data/chef/cookbooks/melissadata/attributes/default.rb +5 -0
  24. data/chef/cookbooks/melissadata/metadata.rb +8 -0
  25. data/chef/cookbooks/melissadata/recipes/default.rb +37 -0
  26. data/chef/cookbooks/melissadata/templates/default/Makefile.erb +39 -0
  27. data/chef/cookbooks/melissadata/templates/default/md_tcp_server.init.erb +82 -0
  28. data/chef/cookbooks/melissadata/templates/default/md_unix_server.init.erb +81 -0
  29. data/chef/cookbooks/rvm/recipes/default.rb +1 -0
  30. data/chef/cookbooks/rvm/recipes/r187.rb +6 -0
  31. data/chef/cookbooks/rvm/recipes/r192.rb +6 -0
  32. data/chef/cookbooks/rvm/recipes/system.rb +28 -0
  33. data/chef/cookbooks/ubuntu/attributes/default.rb +24 -0
  34. data/chef/cookbooks/ubuntu/metadata.json +36 -0
  35. data/chef/cookbooks/ubuntu/metadata.rb +8 -0
  36. data/chef/cookbooks/ubuntu/recipes/default.rb +27 -0
  37. data/chef/cookbooks/ubuntu/templates/default/sources.list.erb +15 -0
  38. data/lib/melissadata.rb +1 -2
  39. data/lib/melissadata/client.rb +8 -0
  40. data/lib/melissadata/client/base.rb +56 -0
  41. data/lib/melissadata/client/tcp.rb +28 -0
  42. data/lib/melissadata/client/unix.rb +22 -0
  43. data/lib/melissadata/client/vagrant.rb +9 -0
  44. data/lib/melissadata/command.rb +1 -0
  45. data/lib/melissadata/command/base.rb +0 -1
  46. data/lib/melissadata/command/compile.rb +37 -0
  47. data/lib/melissadata/command/package.rb +32 -73
  48. data/lib/melissadata/constants.rb +6 -5
  49. data/lib/melissadata/melissadata.rb +26 -91
  50. data/lib/melissadata/native_object.rb +0 -8
  51. data/lib/melissadata/native_object/address.rb +2 -0
  52. data/lib/melissadata/native_object/base.rb +18 -5
  53. data/lib/melissadata/native_object/email.rb +2 -0
  54. data/lib/melissadata/native_object/geo.rb +2 -0
  55. data/lib/melissadata/native_object/ip_locator.rb +2 -0
  56. data/lib/melissadata/native_object/name.rb +2 -0
  57. data/lib/melissadata/native_object/phone.rb +2 -0
  58. data/lib/melissadata/server.rb +10 -0
  59. data/lib/melissadata/server/base.rb +145 -0
  60. data/lib/melissadata/server/tcp.rb +22 -0
  61. data/lib/melissadata/server/unix.rb +24 -0
  62. data/lib/melissadata/vagrant_plugin.rb +23 -0
  63. data/lib/melissadata/vagrant_plugin/actions.rb +9 -0
  64. data/lib/melissadata/vagrant_plugin/actions/base.rb +60 -0
  65. data/lib/melissadata/vagrant_plugin/actions/install.rb +78 -0
  66. data/lib/melissadata/vagrant_plugin/actions/update.rb +22 -0
  67. data/lib/melissadata/vagrant_plugin/command.rb +21 -0
  68. data/lib/melissadata/vagrant_plugin/config.rb +18 -0
  69. data/lib/melissadata/version.rb +1 -1
  70. data/locales/en.yml +16 -0
  71. data/melissadata.gemspec +11 -12
  72. data/pkg/melissadata-0.0.1.gem +0 -0
  73. data/spec/helpers/vagrant_helpers.rb +17 -0
  74. data/spec/melissadata/command/package_spec.rb +1 -1
  75. data/spec/melissadata/vagrant_plugin/actions/install_spec.rb +40 -0
  76. data/spec/melissadata/vagrant_plugin/config_spec.rb +17 -0
  77. data/spec/spec_helper.rb +12 -7
  78. metadata +201 -228
  79. data/bin/md +0 -4
  80. data/bin/md-rpc +0 -9
  81. data/bin/md-server +0 -18
  82. data/bin/melissadata +0 -4
  83. data/lib/melissadata/native_object/client.rb +0 -33
  84. data/lib/melissadata/prev/command_old.rb +0 -80
  85. data/lib/melissadata/prev/shared_objects.rb +0 -54
  86. data/lib/melissadata/rpc.rb +0 -39
  87. data/pkg/melissa-data-0.0.1.gem +0 -0
  88. data/pkg/melissa-data-0.0.2.gem +0 -0
  89. data/pkg/melissa-data-0.0.3.gem +0 -0
  90. data/templates/config.rb +0 -20
  91. data/templates/locales/en.yml +0 -4
@@ -0,0 +1,5 @@
1
+ default[:melissadata][:paths][:root_dir] = "/opt/melissadata"
2
+ default[:melissadata][:paths][:config_file] = "/opt/melissadata/config.yml"
3
+ default[:melissadata][:paths][:license_file] = "/opt/melissadata/license.txt"
4
+ default[:melissadata][:paths][:log_dir] = "/var/log/melissadata"
5
+ default[:melissadata][:runner_user] = "vagrant"
@@ -0,0 +1,8 @@
1
+ maintainer "JohnnyT"
2
+ maintainer_email "johnnyt@xan.do"
3
+ license "Apache 2.0"
4
+ description "Preps box for MelissaData"
5
+ depends "apt"
6
+ depends "build-essential"
7
+ depends "ubuntu"
8
+ depends "rvm"
@@ -0,0 +1,37 @@
1
+ include_recipe 'ubuntu'
2
+
3
+ package 'git-core'
4
+
5
+ %w[ rake bundler i18n thor activesupport multi_json yajl-ruby ].each{ |gem| gem_package gem }
6
+
7
+ include_recipe 'rvm::r192'
8
+
9
+ %w[ src lib data ].each do |subdir|
10
+ directory "/opt/melissadata/#{subdir}" do
11
+ owner 'vagrant'
12
+ group 'vagrant'
13
+ mode 0755
14
+ action :create
15
+ recursive true
16
+ end
17
+ end
18
+
19
+ template "/opt/melissadata/src/Makefile" do
20
+ owner 'vagrant'
21
+ group 'vagrant'
22
+ end
23
+
24
+ %w[ tcp unix ].each do |transport|
25
+ template "md_#{transport}_server.init" do
26
+ path "/etc/init.d/md_#{transport}_server"
27
+ owner "root"
28
+ group "root"
29
+ mode "0755"
30
+ action :create_if_missing
31
+ end
32
+
33
+ service "md_#{transport}_server" do
34
+ action :enable
35
+ end
36
+ end
37
+
@@ -0,0 +1,39 @@
1
+ DIR=/opt/melissadata/lib
2
+ RUBYDIR=<%= node[:languages][:ruby][:gems_dir].gsub('gems/', '') %>/<%= node[:languages][:ruby][:platform] %>
3
+ CXX=g++
4
+ LDLIBS=-L$(DIR) -Wl,-rpath,$(DIR)
5
+ FLAGS=-g -O -Wall -pthread -m64
6
+ CXXFLAGS=$(FLAGS) -fpic -c $(LDLIBS) -I$(DIR) -I$(RUBYDIR)
7
+ LDFLAGS=$(COMMONFLAGS) $(LDLIBS)
8
+
9
+ all: Addr Email Geo IpLocator Name Phone
10
+
11
+ Addr: mdAddrRubyWrapper.cpp mdAddr.h mdEnums.h
12
+ $(CXX) $(CXXFLAGS) mdAddrRubyWrapper.cpp
13
+ $(CXX) $(LDFLAGS) -lmdAddr -shared mdAddrRubyWrapper.o -o $(DIR)/mdAddrRubyWrapper.so
14
+ $(RM) mdAddrRubyWrapper.o
15
+
16
+ Email: mdEmailRubyWrapper.cpp mdEmail.h mdEnums.h
17
+ $(CXX) $(CXXFLAGS) mdEmailRubyWrapper.cpp
18
+ $(CXX) $(LDFLAGS) -lmdEmail -shared mdEmailRubyWrapper.o -o $(DIR)/mdEmailRubyWrapper.so
19
+ $(RM) mdEmailRubyWrapper.o
20
+
21
+ Geo: mdGeoRubyWrapper.cpp mdGeo.h mdEnums.h
22
+ $(CXX) $(CXXFLAGS) mdGeoRubyWrapper.cpp
23
+ $(CXX) $(LDFLAGS) -lmdGeo -shared mdGeoRubyWrapper.o -o $(DIR)/mdGeoRubyWrapper.so
24
+ $(RM) mdGeoRubyWrapper.o
25
+
26
+ IpLocator: mdIpLocatorRubyWrapper.cpp mdIpLocator.h mdEnums.h
27
+ $(CXX) $(CXXFLAGS) mdIpLocatorRubyWrapper.cpp
28
+ $(CXX) $(LDFLAGS) -lmdIpLocator -shared mdIpLocatorRubyWrapper.o -o $(DIR)/mdIpLocatorRubyWrapper.so
29
+ $(RM) mdIpLocatorRubyWrapper.o
30
+
31
+ Name: mdNameRubyWrapper.cpp mdName.h mdEnums.h
32
+ $(CXX) $(CXXFLAGS) mdNameRubyWrapper.cpp
33
+ $(CXX) $(LDFLAGS) -lmdName -shared mdNameRubyWrapper.o -o $(DIR)/mdNameRubyWrapper.so
34
+ $(RM) mdNameRubyWrapper.o
35
+
36
+ Phone: mdPhoneRubyWrapper.cpp mdPhone.h mdEnums.h
37
+ $(CXX) $(CXXFLAGS) mdPhoneRubyWrapper.cpp
38
+ $(CXX) $(LDFLAGS) -lmdPhone -shared mdPhoneRubyWrapper.o -o $(DIR)/mdPhoneRubyWrapper.so
39
+ $(RM) mdPhoneRubyWrapper.o
@@ -0,0 +1,82 @@
1
+ #! /bin/sh
2
+
3
+ ### BEGIN INIT INFO
4
+ # Provides: md_tcp_server
5
+ # Required-Start: $all
6
+ # Required-Stop: $all
7
+ # Default-Start: 2 3 4 5
8
+ # Default-Stop: 0 1 6
9
+ # Short-Description: Starts the MelissaData TCP server
10
+ # Description: Starts the MelissaData TCP server
11
+ ### END INIT INFO
12
+
13
+ NAME=md_tcp_server
14
+ SCRIPTNAME=/etc/init.d/$NAME
15
+ DAEMON=/usr/bin/$NAME
16
+ PID_FILE=/var/run/$NAME.pid
17
+ RUNASUSER=<%= node[:melissadata][:runner_user] %>
18
+ ARGS=""
19
+
20
+ # Define LSB log_* functions.
21
+ # Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
22
+ . /lib/lsb/init-functions
23
+
24
+ # Function that starts the daemon/service
25
+ do_start() {
26
+ start-stop-daemon \
27
+ --start --background \
28
+ --make-pidfile --pidfile $PID_FILE \
29
+ --chuid $RUNASUSER \
30
+ --exec $DAEMON -- $ARGS || true
31
+ }
32
+
33
+ # Function that stops the daemon/service
34
+ do_stop() {
35
+ start-stop-daemon --stop --pidfile $PID_FILE
36
+ }
37
+
38
+ case "$1" in
39
+ start)
40
+ [ "$VERBOSE" != no ] && log_daemon_msg "Starting $NAME"
41
+ do_start
42
+ case "$?" in
43
+ 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
44
+ 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
45
+ esac
46
+ ;;
47
+ stop)
48
+ [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $NAME"
49
+ do_stop
50
+ case "$?" in
51
+ 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
52
+ 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
53
+ esac
54
+ ;;
55
+
56
+ restart)
57
+ do_stop
58
+ case "$?" in
59
+ 0|1)
60
+ do_start
61
+ case "$?" in
62
+ 0) log_end_msg 0 ;;
63
+ 1) log_end_msg 1 ;; # Old process is still running
64
+ *) log_end_msg 1 ;; # Failed to start
65
+ esac
66
+ ;;
67
+
68
+ *)
69
+ # Failed to stop
70
+ log_end_msg 1
71
+ ;;
72
+ esac
73
+ ;;
74
+
75
+ *)
76
+ log_action_msg "Usage: $SCRIPTNAME {start|stop|restart}" >&2
77
+ exit 3
78
+ ;;
79
+ esac
80
+
81
+ exit 0
82
+
@@ -0,0 +1,81 @@
1
+ #! /bin/sh
2
+
3
+ ### BEGIN INIT INFO
4
+ # Provides: md_unix_server
5
+ # Required-Start: $all
6
+ # Required-Stop: $all
7
+ # Default-Start: 2 3 4 5
8
+ # Default-Stop: 0 1 6
9
+ # Short-Description: Starts the MelissaData UnixSocket server
10
+ # Description: Starts the MelissaData UnixSocket server
11
+ ### END INIT INFO
12
+
13
+ NAME=md_unix_server
14
+ SCRIPTNAME=/etc/init.d/$NAME
15
+ DAEMON=/usr/bin/$NAME
16
+ PID_FILE=/var/run/$NAME.pid
17
+ RUNASUSER=<%= node[:melissadata][:runner_user] %>
18
+ ARGS=""
19
+
20
+ # Define LSB log_* functions.
21
+ # Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
22
+ . /lib/lsb/init-functions
23
+
24
+ # Function that starts the daemon/service
25
+ do_start() {
26
+ start-stop-daemon \
27
+ --start --background \
28
+ --make-pidfile --pidfile $PID_FILE \
29
+ --chuid $RUNASUSER \
30
+ --exec $DAEMON -- $ARGS || true
31
+ }
32
+
33
+ # Function that stops the daemon/service
34
+ do_stop() {
35
+ start-stop-daemon --stop --pidfile $PID_FILE
36
+ }
37
+
38
+ case "$1" in
39
+ start)
40
+ [ "$VERBOSE" != no ] && log_daemon_msg "Starting $NAME"
41
+ do_start
42
+ case "$?" in
43
+ 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
44
+ 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
45
+ esac
46
+ ;;
47
+ stop)
48
+ [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $NAME"
49
+ do_stop
50
+ case "$?" in
51
+ 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
52
+ 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
53
+ esac
54
+ ;;
55
+
56
+ restart)
57
+ do_stop
58
+ case "$?" in
59
+ 0|1)
60
+ do_start
61
+ case "$?" in
62
+ 0) log_end_msg 0 ;;
63
+ 1) log_end_msg 1 ;; # Old process is still running
64
+ *) log_end_msg 1 ;; # Failed to start
65
+ esac
66
+ ;;
67
+
68
+ *)
69
+ # Failed to stop
70
+ log_end_msg 1
71
+ ;;
72
+ esac
73
+ ;;
74
+
75
+ *)
76
+ log_action_msg "Usage: $SCRIPTNAME {start|stop|restart}" >&2
77
+ exit 3
78
+ ;;
79
+ esac
80
+
81
+ exit 0
@@ -0,0 +1 @@
1
+ require_recipe "rvm:system"
@@ -0,0 +1,6 @@
1
+ require_recipe "rvm::system"
2
+
3
+ bash "RVM install 1.8.7" do
4
+ code "/usr/local/rvm/bin/rvm install 1.8.7 --with-readline-dir=$rvm_path/usr"
5
+ not_if "/usr/local/rvm/bin/rvm list | grep -q '1.8.7'"
6
+ end
@@ -0,0 +1,6 @@
1
+ require_recipe "rvm::system"
2
+
3
+ bash "RVM install 1.9.2" do
4
+ code "/usr/local/rvm/bin/rvm install 1.9.2 --with-readline-dir=$rvm_path/usr --with-zlib-dir=$rvm_path/usr"
5
+ not_if "/usr/local/rvm/bin/rvm list | grep -q '1.9.2'"
6
+ end
@@ -0,0 +1,28 @@
1
+ bash "Download and run rvm-install-system-wide" do
2
+ code "bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)"
3
+ not_if "[ -e /usr/local/rvm ]"
4
+ end
5
+
6
+ # %w[ readline zlib ].each do |rvm_package|
7
+ # bash "Install RVM #{rvm_package} package" do
8
+ # code "/usr/local/rvm/bin/rvm pkg install #{rvm_package}"
9
+ # not_if "[ -e $rvm_path/usr/lib/lib#{rvm_package}.so ]"
10
+ # end
11
+ # end
12
+
13
+ bash "Install RVM Readline package" do
14
+ code "/usr/local/rvm/bin/rvm pkg install readline"
15
+ not_if "[ -e $rvm_path/usr/lib/libreadline.so ]"
16
+ end
17
+
18
+ bash "Install RVM zlib package" do
19
+ code "/usr/local/rvm/bin/rvm pkg install zlib"
20
+ not_if "[ -e $rvm_path/usr/lib/libz.so ]"
21
+ end
22
+
23
+ (node[:accounts] || 'vagrant').each do |username, options|
24
+ group 'rvm' do
25
+ members username
26
+ append true
27
+ end
28
+ end
@@ -0,0 +1,24 @@
1
+ #
2
+ # Cookbook Name:: ubuntu
3
+ # Attribute File:: default
4
+ #
5
+ # Copyright 2011, Opscode, Inc.
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+
20
+ case platform
21
+ when "ubuntu"
22
+ set[:ubuntu][:archive_url] = "http://us.archive.ubuntu.com/ubuntu"
23
+ set[:ubuntu][:security_url] = "http://security.ubuntu.com/ubuntu"
24
+ end
@@ -0,0 +1,36 @@
1
+ {
2
+ "recommendations": {
3
+ },
4
+ "attributes": {
5
+ },
6
+ "maintainer": "Opscode, Inc.",
7
+ "suggestions": {
8
+ },
9
+ "dependencies": {
10
+ "apt": [
11
+
12
+ ]
13
+ },
14
+ "maintainer_email": "cookbooks@opscode.com",
15
+ "conflicting": {
16
+ },
17
+ "platforms": {
18
+ "ubuntu": [
19
+
20
+ ]
21
+ },
22
+ "license": "Apache 2.0",
23
+ "version": "0.99.0",
24
+ "providing": {
25
+ },
26
+ "recipes": {
27
+ "ubuntu": "Sets up sources for the node's ubuntu release"
28
+ },
29
+ "replacing": {
30
+ },
31
+ "name": "ubuntu",
32
+ "description": "Sets up sources for ubuntu",
33
+ "groupings": {
34
+ },
35
+ "long_description": ""
36
+ }
@@ -0,0 +1,8 @@
1
+ maintainer "Opscode, Inc."
2
+ maintainer_email "cookbooks@opscode.com"
3
+ license "Apache 2.0"
4
+ description "Sets up sources for ubuntu"
5
+ version "0.99.0"
6
+ depends "apt"
7
+ supports "ubuntu"
8
+ recipe "ubuntu", "Sets up sources for the node's ubuntu release"
@@ -0,0 +1,27 @@
1
+ #
2
+ # Cookbook Name:: ubuntu
3
+ # Recipe:: default
4
+ #
5
+ # Copyright 2008-2009, Opscode, Inc.
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+
20
+ include_recipe "apt"
21
+
22
+ template "/etc/apt/sources.list" do
23
+ mode 0644
24
+ variables :code_name => node[:lsb][:codename]
25
+ notifies :run, resources(:execute => "apt-get update"), :immediately
26
+ source "sources.list.erb"
27
+ end
@@ -0,0 +1,15 @@
1
+ #
2
+ # Ubuntu <%= @code_name %> - Generated by Chef
3
+ #
4
+
5
+ deb <%= node['ubuntu']['archive_url'] %> <%= @code_name %> main restricted universe multiverse
6
+ deb-src <%= node['ubuntu']['archive_url'] %> <%= @code_name %> main restricted universe multiverse
7
+
8
+ deb <%= node['ubuntu']['archive_url'] %> <%= @code_name %>-updates main restricted universe multiverse
9
+ deb-src <%= node['ubuntu']['archive_url'] %> <%= @code_name %>-updates main restricted universe multiverse
10
+
11
+ #
12
+ # Security updates
13
+ #
14
+ deb <%= node['ubuntu']['security_url'] %> <%= @code_name %>-security main restricted universe multiverse
15
+ deb-src <%= node['ubuntu']['security_url'] %> <%= @code_name %>-security main restricted universe multiverse
data/lib/melissadata.rb CHANGED
@@ -1,2 +1 @@
1
- # Load constants, be able to set environment
2
- require 'melissadata/melissadata'
1
+ require File.expand_path('melissadata/melissadata', File.dirname(__FILE__))
@@ -0,0 +1,8 @@
1
+ module MelissaData
2
+ module Client
3
+ autoload :Base, 'melissadata/client/base'
4
+ autoload :TCP, 'melissadata/client/tcp'
5
+ autoload :Unix, 'melissadata/client/unix'
6
+ autoload :Vagrant, 'melissadata/client/vagrant'
7
+ end
8
+ end